% \iffalse meta-comment
% An Infrastructure for marking up PhysML in LaTeX documents
% $URL: https://svn.kwarc.info/repos/stex/trunk/sty/physml/physml.dtx $ 
% $Rev: 1671 $; last modified by $Author: kohlhase $ 
% $Date: 2010-11-06 08:05:15 +0100 (Sat, 06 Nov 2010) $
% Copyright (c) 2008 Michael Kohlhase, all rights reserved
%               this file is released under the
%               LaTeX Project Public License (LPPL)
% \fi
% 
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] 
%<package>\ProvidesPackage{physml}[2010/06/24 v0.1 PhysML in sTeX]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{dcm,url,array,float}
\usepackage{stex,physml}
\usepackage[show]{ed} 
\usepackage[hyperref=auto,style=alphabetic]{biblatex}
\bibliography{kwarc}
\usepackage{../ctansvn}
\usepackage{hyperref}
\usepackage[eso-foot,today]{svninfo}
\svnInfo $Id: physml.dtx 1671 2010-11-06 07:05:15Z kohlhase $
\svnKeyword $HeadURL: https://svn.kwarc.info/repos/stex/trunk/sty/physml/physml.dtx $
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example} 
\RecordChanges
\EnableCrossrefs         
\def\tracissue#1{\cite{sTeX:online}, \hyperlink{http://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
\begin{document}\DocInput{physml.dtx}\end{document}
%</driver>
% \fi
%
%\iffalse\CheckSum{104}\fi
%
% \changes{v0.1}{2008/09/07}{First Version with Documentation}
% \changes{v0.1}{2008/11/11}{Modularized documentation}
% 
% \GetFileInfo{physml.dtx}
% 
% \MakeShortVerb{\|}
% \def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}}
% \def\latexml{\scsys{LaTeXML}}
%
% \title{{{\texttt{physml.sty}}}: An Infrastructure for Marking Up {\physml} in {\TeX/\LaTeX}\thanks{Version {\fileversion} (last revised
%        {\filedate})}}
% \author{Michael Kohlhase\\
%         Jacobs University, Bremen\\
%         \url{http://kwarc.info/kohlhase}}
% \date{\today}
% \maketitle
%
% \begin{abstract}
%   The |physml| package allows mark up PhysML structures in {\LaTeX} documents that can be
%   harvested by automated tools or exported to PDF, while at the same time generating
%   conventional title information.
% \end{abstract}
% 
% \setcounter{tocdepth}{2}\tableofcontents\newpage
%
%\section{Introduction}\label{sec:presentation}
% 
% The |physml| package is part of the {\sTeX} project
% (see~\cite{sTeX:online,Kohlhase:ulsmf08}) and extends {\sTeX} with an infrastructure
% for creating {\physml} markup~\cite{PhysML:webpage,HilKohSta:copmem06} from {\LaTeX}
% sources.
%
% \section{The User Interface}\label{sec:user}
%
% \ednote{document the functionality here}
%
% \subsection{Package Options}\label{sec:user:options}
% 
% The |physml| package takes a single option: \DescribeMacro{showmeta}|showmeta|. If this
% is set, then the metadata keys are shown (see~\cite{Kohlhase:metakeys:ctan} for details and
% customization options).
%
% \subsection{Observables}\label{sec:user:observables}
% \subsection{Systems}\label{sec:user:systems}
% \subsection{Values}\label{sec:user:values}
% \subsection{Experiments}\label{sec:user:experiments}
% 
% \section{Limitations}\label{sec:limitations}
% 
% In this section we document known limitations. If you want to help alleviate them,
% please feel free to contact the package author. Some of them are currently discussed in
% the \sTeX TRAC~\cite{sTeX:online}. 
% \begin{compactenum}
% \item none reported yet
% \end{compactenum}
% 
% \StopEventually{\printbibliography}\newpage
%
% \section{The Implementation}\label{sec:implementation}
%
% The |sref| package generates two files: the {\LaTeX} package (all the code between
% {\textsf{$\langle$*package$\rangle$}} and {\textsf{$\langle$/package$\rangle$}}) and the
% {\latexml} bindings (between {\textsf{$\langle$*ltxml$\rangle$ and
%     $\langle$/ltxml$\rangle$}}). We keep the corresponding code fragments together,
% since the documentation applies to both of them and to prevent them from getting out of
% sync.
%
% We first set up header information for the {\latexml} binding file. 
%    \begin{macrocode}
%<*ltxml>
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
%</ltxml>
%    \end{macrocode}
% 
% \subsection{Package Options}\label{sec:impl:options}
%
% We declare some switches which will modify the behavior according to the package
% options. Generally, an option |xxx| will just set the appropriate switches to true
% (otherwise they stay false).\ednote{need an implementation for {\latexml}}
%    \begin{macrocode}
%<*package>
\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
\ProcessOptions
%</package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package>
\RequirePackage{sref}
%</package>
%    \end{macrocode}
%
%\begin{macro}{physml}
%    \begin{macrocode}
%<package>\newcommand{\physml}{PhysML}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Observables}\label{sec:impl:observables}
%
% \begin{environment}{observable}
%    \begin{macrocode}
%<*package>
\srefaddidkey{obs}
\addmetakey{obs}{algebra}
\newenvironment{observable}[1][]% keyword args
{\metasetkeys{obs}{#1}{\bf{Observable (\obs@id):}}\begin{description}}
{\end{description}}
%</package>
%<*ltxml>
DefKeyVal('obs','name','Semiverbatim');
DefKeyVal('obs','algebra','Semiverbatim');
DefEnvironment('{observable} OptionalKeyVals:obs',
       "<omdoc:observable name='&KeyVal(#1,'name')'"
     .                    "?&defined(&KeyVal(#1,'algebra'))(algebra='&KeyVal(#1,'algebra')')()>"
     .   "#body"
     . "</omdoc:observable>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
%<*package>
\newcommand{\obsref}[1]{ref: #1}
%</package>
%<*ltxml>
DefConstructor('\obsref{}',"<omdoc:observable xref='#1'/>");
%</ltxml>
%    \end{macrocode}
%
% \begin{environment}{refinement}
%    \begin{macrocode}
%<*package>
\srefaddidkey{refinement}
\newenvironment{refinement}[1][]{\item[Refinement]}{}
%</package>
%<*ltxml>
DefKeyVal('refinement','id','Semiverbatim');
DefEnvironment('{refinement} OptionalKeyVals:refinement',
	       "<omdoc:refinement ?&defined(&KeyVal(#1,'id))(xml:id='&KeyVal(#1,'id')')()>"
	     . "#body"
	     . "</omdoc:refinement>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{opdef}
%    \begin{macrocode}
%<*package>
\newenvironment{opdef}[1][]{\item[Opdef:]}{}
%</package>
%<*ltxml>
DefKeyVal('opdef,'id','Semiverbatim');
DefEnvironment('{opdef} OptionalKeyVals:opdef',
	       "<omdoc:opdef ?&defined(&KeyVal(#1,'id))(xml:id='&KeyVal(#1,'id')')()>"
	     . "#body"
	     . "</omdoc:opdef>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \subsection{Systems}\label{sec:impl:systems}
%
% \begin{environment}{system}
%    \begin{macrocode}
%<*package>
\srefaddidkey{system}
\newenvironment{system}[1][]% keyword args
{\metasetkeys{system}{#1}{\bf{System (\system@id):}}\begin{description}}
{\end{description}}
%</package>
%<*ltxml>
DefKeyVal('system,'id','Semiverbatim');
DefEnvironment('{system} OptionalKeyVals:id',
	       "<omdoc:system ?&defined(&KeyVal(#1,'id))(xml:id='&KeyVal(#1,'id)')()>"
	     . "#body"
	     . "</omdoc:system>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
% \ednote{need to implement this in |LaTeXML|}
%    \begin{macrocode}
%<*package>
\newcommand{\sysref}[1]{ref: #1}
%</package>
%<*ltxml>
%</ltxml>
%    \end{macrocode}
%
% \begin{environment}{realization}
%    \begin{macrocode}
%<*package>
\newenvironment{realization}[1][]{\item[Realization]}{}
%</package>
%<*ltxml>
DefKeyVal('realization,'id','Semiverbatim');
DefEnvironment('{realization} OptionalKeyVals:realization,
	       "<omdoc:realization ?&defined(&KeyVal(#1,'id))(xml:id='&KeyVal(#1,'id')')()>"
	     . "#body"
	     . "</omdoc:realization>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{preparation}
%    \begin{macrocode}
%<*package>
\newenvironment{preparation}[1][]{\item[Preparation]}{}
%</package>
%<*ltxml>
DefKeyVal('preparation,'id','Semiverbatim');
DefEnvironment('{preparation} OptionalKeyVals:preparation',
	       "<omdoc:preparation ?&defined(&KeyVal(#1,'id))(xml:id='&KeyVal(#1,'id')')()>"
	     . "#body"
	     . "</omdoc:preparation>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{state}
%    \begin{macrocode}
%<*package>
\srefaddidkey{state}
\addmetakey{state}{of}
\newenvironment{state}[1][]% keyword args
{{\bf{State:}}}{\par\noindent}
%</package>
%<*ltxml>
DefKeyVal('state','id','Semiverbatim');
DefKeyVal('state','of','Semiverbatim');
DefEnvironment('{state} OptionalKeyVals:state',
	       "<omdoc:state ?&defined(&KeyVal(#1,'id))(xml:id='&KeyVal(#1,'id)')()"
	     .              "?&defined(&KeyVal(#1,'of))(of='&KeyVal(#1,'of)')()>"
	     .   "#body"
	     . "</omdoc:state>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \subsection{Values}\label{sec:impl:values}
%
% \begin{environment}{statevalue}
%    \begin{macrocode}
%<*package>
\newcommand{\statevalue}[2]{{\tt{#1}}$\rightarrow${#2}}
% \srefaddidkey{value}
% \addmetakey{value}{for}
% \newenvironment{value}[1][]% keyword args
% {{\bf{Value:}}}{\par\noindent}
%</package>
%<*ltxml>
DefKeyVal('value','id','Semiverbatim');
DefKeyVal('value','for','Semiverbatim');
DefEnvironment('{state} OptionalKeyVals:value',
	       "<omdoc:value ?&defined(&KeyVal(#1,'id'))(xml:id='&KeyVal(#1,'id)')()"
	     .              "?&defined(&KeyVal(#1,'for'))(for='&KeyVal(#1,'of)')()>"
	     .   "#body"
	     . "</omdoc:value>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \subsection{Experiments}\label{sec:impl:experiments}
%
% \begin{environment}{measurement}
%    \begin{macrocode}
%<*package>
\srefaddidkey{measurement}
\newenvironment{measurement}[1][]% keyword args
{{\bf{Measurement:}}}{\par\noindent}
%</package>
%<*ltxml>
DefKeyVal('measurement,'id','Semiverbatim');
DefEnvironment('{measurement} OptionalKeyVals:measurement,
	       "<omdoc:measurement ?&defined(&KeyVal(#1,'id'))(xml:id='&KeyVal(#1,'id)')()>"
	     .   "#body"
	     . "</omdoc:measurement>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{experiment}
%    \begin{macrocode}
%<*package>
\srefaddidkey{experiment}
\newenvironment{experiment}[1][]% keyword args
{{\bf{Experiment:}}}{\par\noindent}
%</package>
%<*ltxml>
DefKeyVal('experiment,'id','Semiverbatim');
DefEnvironment('{experiment} OptionalKeyVals:experiment,
	       "<omdoc:experiment ?&defined(&KeyVal(#1,'id'))(xml:id='&KeyVal(#1,'id)')()>"
	     . "#body"
	     . "</omdoc:experiment>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{evidence}
%    \begin{macrocode}
%<*package>
\srefaddidkey{evidence}
\newenvironment{evidence}[1][]% keyword args
{{\bf{Evidence:}}}{\par\noindent}
%</package>
%<*ltxml>
DefKeyVal('evidence,'id','Semiverbatim');
DefEnvironment('{evidence} OptionalKeyVals:evidence,
	       "<omdoc:evidence ?&defined(&KeyVal(#1,'id'))(xml:id='&KeyVal(#1,'id)')()>"
	     . "#body"
	     . "</omdoc:evidence>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{interpretation}
%    \begin{macrocode}
%<*package>
\srefaddidkey{interpretation}
\newenvironment{interpretation}[1][]% keyword args
{{\bf{Interpretation:}}}{\par\noindent}
%</package>
%<*ltxml>
DefKeyVal('interpretation,'id','Semiverbatim');
DefEnvironment('{interpretation} OptionalKeyVals:interpretation,
	       "<omdoc:interpretation ?&defined(&KeyVal(#1,'id'))(xml:id='&KeyVal(#1,'id)')()>"
	     . "#body"
	     . "</omdoc:interpretation>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
%
%\subsection{Bookkeeping}
%
% We declare all tags as receiving |xml:id| and |stex:sref| attributes, pinpointing a unique identifier 
% and their location in the {\LaTeX} source.
%    \begin{macrocode}
%<*ltxml>
Tag('omdoc:observable',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:realization',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:preparation',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:state',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:value',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:measurement',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:experiment',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:evidence',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:interpretation',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:refinement',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:opdef',afterOpen=>\&numberIt,afterClose=>\&locateIt);
Tag('omdoc:system',afterOpen=>\&numberIt,afterClose=>\&locateIt);
%</ltxml>
%    \end{macrocode}
%\subsection{Finale}
%
% Finally, we need to terminate the file with a success mark for perl.
%    \begin{macrocode}
%<ltxml>1;
%    \end{macrocode}
% \Finale
\endinput
% \iffalse
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi

% LocalWords:  physml dtx keyval CPERL DefKeyVal Semiverbatim DefEnvironment sc
% LocalWords:  OptionalKeyVals omdoc KeyVal DefConstructor xml Opdef opdef Thu
% LocalWords:  iffalse kohlhase scsys sc latexml texttt fileversion maketitle
% LocalWords:  setcounter tocdepth tableofcontents newpage ulsmf08 HilKohSta tt
% LocalWords:  copmem06 ednote printbibliography sref ltxml newcommand obsref
% LocalWords:  srefaddidkey newenvironment xref sysref
% LocalWords:  noindent statevalue rightarrow stex kwarc doctex
