<!-- DTD (non-normative) for the W3C XML Processing Model language

     Minimal provision is made for user-defined steps - Users may override the
      definition of the parameter entity user-steps and step-option-attrs - see below.

     Even less provision is provided for extension elements and
       attributes - users may overrided the definitions of the
       parameter entities extra-elts and extra-attrs, but extra-elts does
       _not_ allow extras anywhere  - see below. 

     Likewise, for documentation, p and div are pre-allowed, others
      can be added via the entity doc-elts -->

<!ENTITY % p 'p:'> <!-- can be overriden in the internal subset of a
                         schema document to establish a different
                         namespace prefix -->
<!ENTITY % s ':p'> <!-- if %p is defined (e.g. as foo:) then you must
                         also define %s as the suffix for the appropriate
                         namespace declaration (e.g. :foo) -->
<!ENTITY % nds 'xmlns%s;'>

<!ENTITY % pipeline "%p;pipeline">
<!ENTITY % input "%p;input">
<!ENTITY % pipe "%p;pipe">
<!ENTITY % documentation "%p;documentation">
<!ENTITY % inline "%p;inline">
<!ENTITY % empty "%p;empty">
<!ENTITY % document "%p;document">
<!ENTITY % log "%p;log">
<!ENTITY % output "%p;output">
<!ENTITY % option "%p;option">
<!ENTITY % parameter "%p;parameter">
<!ENTITY % for-each "%p;for-each">
<!ENTITY % viewport "%p;viewport">
<!ENTITY % choose "%p;choose">
<!ENTITY % when "%p;when">
<!ENTITY % otherwise "%p;otherwise">
<!ENTITY % xpath-context "%p;xpath-context">
<!ENTITY % iteration-source "%p;iteration-source">
<!ENTITY % viewport-source "%p;viewport-source">
<!ENTITY % group "%p;group">
<!ENTITY % try "%p;try">
<!ENTITY % catch "%p;catch">
<!ENTITY % declare-step "%p;declare-step">
<!ENTITY % pipeline-library "%p;pipeline-library">
<!ENTITY % import "%p;import">

<!ENTITY % count "%p;count">
<!ENTITY % delete "%p;delete">
<!ENTITY % equal "%p;equal">
<!ENTITY % error "%p;error">
<!ENTITY % escape-markup "%p;escape-markup">
<!ENTITY % identity "%p;identity">
<!ENTITY % insert "%p;insert">
<!ENTITY % label-elements "%p;label-elements">
<!ENTITY % load "%p;load">
<!ENTITY % namespace-rename "%p;namespace-rename">
<!ENTITY % parameters "%p;parameters">
<!ENTITY % rename "%p;rename">
<!ENTITY % replace "%p;replace">
<!ENTITY % set-attributes "%p;set-attributes">
<!ENTITY % sink "%p;sink">
<!ENTITY % split-sequence "%p;subsequence">
<!ENTITY % store "%p;store">
<!ENTITY % string-replace "%p;string-replace">
<!ENTITY % unescape-markup "%p;parse">
<!ENTITY % unwrap "%p;unwrap">
<!ENTITY % wrap "%p;wrap">
<!ENTITY % wrap-sequence "%p;wrap-sequence">
<!ENTITY % xinclude "%p;xinclude">
<!ENTITY % xslt "%p;xslt">

<!ENTITY % http-request "%p;http-request">
<!ENTITY % relax-ng-validate "%p;validate-relax-ng">
<!ENTITY % xml-schema-validate "%p;validate-xml-schema">
<!ENTITY % xquery "%p;xquery">
<!ENTITY % xsl-formatter "%p;xsl-formatter">
<!ENTITY % xslt-2.0 "%p;xslt2">

<!ENTITY % user-steps "">
<!ENTITY % step-option-attrs "">
<!ENTITY % extra-attrs "">
<!ENTITY % extra-elts "">
<!ENTITY % doc-elts "">

<!ENTITY % step "(%count;|%delete;|%equal;|%error;|%escape-markup;|
                  %identity;|%insert;|%label-elements;|%load;|
                  %namespace-rename;|%parameters;|%rename;|%replace;|
                  %set-attributes;|%sink;|%split-sequence;|%store;|
                  %string-replace;|%unescape-markup;|%unwrap;|%wrap;|
                  %wrap-sequence;|%xinclude;|%xslt;|
                  %http-request;|%relax-ng-validate;|%xml-schema-validate;|
                  %xquery;|%xsl-formatter;|%xslt-2.0; %user-steps;)">
<!ENTITY % component
 "(%step;|%group;|%viewport;|%for-each;|%choose;|%try;)">
<!ENTITY % subpipeline
 "(%component; , (%component; | %documentation; %extra-elts;)* )?">
<!ENTITY % seqBinding
 "((%documentation;)*,
   ( ( %empty;,(%documentation;)* ) |
     ( (%document;|%pipe;|%inline;),
       (%document;|%pipe;|%inline;|%documentation;)*)))">
<!ENTITY % oneBinding
 "((%documentation;)*,(%document;|%pipe;|%inline;),(%documentation;)*)">
<!ENTITY % optBinding
 "((%documentation;)*,(%empty;|%document;|%pipe;|%inline;),(%documentation;)*)?">

<!ENTITY % NCName "NMTOKEN">
<!ENTITY % QName "NMTOKEN">
<!ENTITY % URIref "CDATA">
<!ENTITY % XPath_expression "CDATA">
<!ENTITY % port_name "%NCName;">
<!ENTITY % step_name "%NCName;">
<!ENTITY % string "CDATA">
<!ENTITY % param-spec "CDATA">

<!ENTITY % global-attrs
  "xml:id NMTOKEN #IMPLIED
   xml:base %URIref; #IMPLIED
   %extra-attrs;" >

<!ENTITY % step-model
 "((%input;)|
   (%option;) | 
   (%log;) |
   (%parameter;) |
   (%documentation;))*">
<!ENTITY % step-attrs
 "name %NCName; #IMPLIED
  %global-attrs;
  %step-option-attrs;" >

<!-- this is provided solely
      for the use of user-defined compound steps -->
<!ENTITY % compound-step-model
  "(((%input;) |
     (%output;) |
     (%option;) |
     (%log;) |
     (%documentation; %extra-elts;))*,
    %subpipeline;)">

<!ELEMENT %pipeline; 
   (((%input;) |
     (%output;) |
     (%option;) |
     (%import;) |
     (%declare-step;) |
     (%log;) |
     (%documentation;) %extra-elts;)*,
    %subpipeline;)>
<!ATTLIST %pipeline;
  name %NCName; #IMPLIED
  type %QName; #IMPLIED
  ignore-prefixes NMTOKENS #IMPLIED
  %global-attrs;
  %nds; %URIref; #FIXED 'http://www.w3.org/2007/03/xproc'
 >

<!ELEMENT %input; (%seqBinding;)?>
<!ATTLIST %input;  
  %global-attrs;
  port %NCName; #REQUIRED
  sequence (yes|no)  'no'
  primary (yes|no) 'no'
  kind (document|parameter) 'document'
  select %XPath_expression;  #IMPLIED>

<!ELEMENT %pipe; (%documentation;)*>
<!ATTLIST %pipe;
  %global-attrs;
  step %step_name; #REQUIRED
  port %port_name; #REQUIRED>

<!ELEMENT %document; (%documentation;)*>
<!ATTLIST %document;
  %global-attrs;
  href %URIref; #REQUIRED>

<!ELEMENT %empty; (%documentation;)*>
<!ATTLIST %empty;
  %global-attrs;>

<!ELEMENT %inline; ANY>
<!ATTLIST %inline; %global-attrs;>

<!ELEMENT %output; 
   (%seqBinding;)?>
<!ATTLIST %output;  
  %global-attrs;
  port %NCName; #REQUIRED
  sequence (yes|no)  'no'
  primary (yes|no) 'no'>

<!ELEMENT %log;
   (%documentation;)*>
<!ATTLIST %log;
  %global-attrs;
  port %NCName; #REQUIRED
  href %URIref; #REQUIRED>

<!ELEMENT %parameter; 
   (%optBinding;)>
<!ATTLIST %parameter;  
  %global-attrs;
  name %param-spec; #REQUIRED
  value %string; #IMPLIED
  select %XPath_expression;  #IMPLIED
 >

<!ELEMENT %option;
   (%optBinding;)>
<!ATTLIST %option;  
  %global-attrs;
  name %param-spec; #REQUIRED
  required (yes|no) 'no'
  value %string; #IMPLIED
  select %XPath_expression;  #IMPLIED
 >

<!ELEMENT %for-each; 
   ((%documentation; %extra-elts;)*,
    (%iteration-source;,(%documentation; %extra-elts;)*)?,
    (((%output;) |
      (%option;) |
      (%log;)),
     ((%output;) |
      (%option;) |
      (%log;) |
      (%documentation;) %extra-elts;)* )?,
    %subpipeline;)>
<!ATTLIST %for-each; 
  %step-attrs;
 >

<!ELEMENT %iteration-source; (%seqBinding;)?>
<!ATTLIST %iteration-source;  
  %global-attrs;
  select %XPath_expression;  #IMPLIED>

<!ELEMENT %viewport; 
   ((%documentation; %extra-elts;)*,
    (%viewport-source;,(%documentation; %extra-elts;)*)?,
    (%output;,(%documentation; %extra-elts;)*)?,
    (%log;,(%documentation; %extra-elts;)*)?,
    (%option;,((%option;) | (%documentation; %extra-elts;))* )?,
    %subpipeline;)>
<!ATTLIST %viewport; 
  %step-attrs;
  match %XPath_expression;  #REQUIRED
 >

<!ELEMENT %viewport-source; (%oneBinding;)?>
<!ATTLIST %viewport-source;  
  %global-attrs;>

<!ELEMENT %choose; 
   ((%documentation;)*,
    (%xpath-context;,(%documentation;)*)?,
    ( %when; ,((%when;) | (%documentation;))*)?,
    ( %otherwise;, (%documentation;)*)?)>
<!ATTLIST %choose; 
  %step-attrs;
 >

<!ELEMENT %when; 
   ((%documentation; %extra-elts;)*,
    (%xpath-context;)?,
    (((%output;) |
      (%option;) |
      (%log;)),
      ((%output;) |
       (%option;) |
       (%log;) |
       (%documentation; %extra-elts;) )* )?,
    %subpipeline;)>
<!ATTLIST %when; 
  %global-attrs;
  test %XPath_expression; #REQUIRED
 >

<!ELEMENT %otherwise; 
   (((%output;) |
     (%option;) |
     (%log;) |
     (%documentation; %extra-elts;) )*,
    %subpipeline;)>
<!ATTLIST %otherwise;
  %global-attrs; >

<!ELEMENT %xpath-context;
   (%optBinding;)>
<!ATTLIST %xpath-context;
  %global-attrs;>

<!ELEMENT %group; 
   (((%output;) |
     (%log;) |
     (%option;) |
     (%documentation; %extra-elts;) )*,
    %subpipeline;)>
<!ATTLIST %group; 
  %step-attrs;
 >

<!ELEMENT %try; 
   ((%documentation;)*,
    %group;,
    (%documentation;)*,
    %catch;,
    (%documentation;)*)>
<!ATTLIST %try; 
  %step-attrs;
 >

<!ELEMENT %catch; 
   (((%output;) |
     (%log;) |
     (%option;) |
     (%documentation; %extra-elts;) )*,
    %subpipeline;)>
<!ATTLIST %catch; 
  %step-attrs;
 >

<!ELEMENT %count; %step-model;>
<!ATTLIST %count; %step-attrs;>
<!ELEMENT %delete; %step-model;>
<!ATTLIST %delete; %step-attrs;
 match CDATA #IMPLIED>
<!ELEMENT %equal; %step-model;>
<!ATTLIST %equal; %step-attrs;
 fail-if-not-equal CDATA #IMPLIED>
<!ELEMENT %error; %step-model;>
<!ATTLIST %error; %step-attrs;
 code CDATA #IMPLIED
 description CDATA #IMPLIED>
<!ELEMENT %escape-markup; %step-model;>
<!ATTLIST %escape-markup; %step-attrs;>
<!ELEMENT %identity; %step-model;>
<!ATTLIST %identity; %step-attrs;>
<!ELEMENT %insert; %step-model;>
<!ATTLIST %insert; %step-attrs;
 match CDATA #IMPLIED
 at-start CDATA #IMPLIED>
<!ELEMENT %label-elements; %step-model;>
<!ATTLIST %label-elements; %step-attrs;
 suffix CDATA #IMPLIED
 prefix CDATA #IMPLIED
 select CDATA #IMPLIED>
<!ELEMENT %load; %step-model;>
<!ATTLIST %load; %step-attrs;
 validate CDATA #IMPLIED
 href CDATA #IMPLIED>
<!ELEMENT %namespace-rename; %step-model;>
<!ATTLIST %namespace-rename; %step-attrs;
 to CDATA #IMPLIED
 from CDATA #IMPLIED>
<!ELEMENT %parameters; %step-model;>
<!ATTLIST %parameters; %step-attrs;>
<!ELEMENT %rename; %step-model;>
<!ATTLIST %rename; %step-attrs;
 match CDATA #IMPLIED> <!-- Note, irritatingly, that 'name' cannot be
                            shorthanded -->
<!ELEMENT %replace; %step-model;>
<!ATTLIST %replace; %step-attrs;
 match CDATA #IMPLIED>
<!ELEMENT %set-attributes; %step-model;>
<!ATTLIST %set-attributes; %step-attrs;
 match CDATA #IMPLIED>
<!ELEMENT %sink; %step-model;>
<!ATTLIST %sink; %step-attrs;>
<!ELEMENT %split-sequence; %step-model;>
<!ATTLIST %split-sequence; %step-attrs;
 test CDATA #IMPLIED>
<!ELEMENT %store; %step-model;>
<!ATTLIST %store; %step-attrs;
 encoding CDATA #IMPLIED
 method CDATA #IMPLIED
 href CDATA #IMPLIED>
<!ELEMENT %string-replace; %step-model;>
<!ATTLIST %string-replace; %step-attrs;
 replace CDATA #IMPLIED
 match CDATA #IMPLIED>
<!ELEMENT %unescape-markup; %step-model;>
<!ATTLIST %unescape-markup; %step-attrs;
 content-type CDATA #IMPLIED
 namespace CDATA #IMPLIED>
<!ELEMENT %unwrap; %step-model;>
<!ATTLIST %unwrap; %step-attrs;
 match CDATA #IMPLIED>
<!ELEMENT %wrap-sequence; %step-model;>
<!ATTLIST %wrap-sequence; %step-attrs;
 wrapper CDATA #IMPLIED>
<!ELEMENT %wrap; %step-model;>
<!ATTLIST %wrap; %step-attrs;
 match CDATA #IMPLIED
 wrapper CDATA #IMPLIED
 group-by CDATA #IMPLIED>
<!ELEMENT %xinclude; %step-model;>
<!ATTLIST %xinclude; %step-attrs;>
<!ELEMENT %xslt; %step-model;>
<!ATTLIST %xslt; %step-attrs;>

<!ELEMENT %http-request; %step-model;>
<!ATTLIST %http-request; %step-attrs;>
<!ELEMENT %relax-ng-validate; %step-model;>
<!ATTLIST %relax-ng-validate; %step-attrs;
 dtd-compatibility CDATA #IMPLIED>
<!ELEMENT %xml-schema-validate; %step-model;>
<!ATTLIST %xml-schema-validate; %step-attrs;
 assert-valid CDATA #IMPLIED
 mode CDATA #IMPLIED>
<!ELEMENT %xquery; %step-model;>
<!ATTLIST %xquery; %step-attrs;>
<!ELEMENT %xsl-formatter; %step-model;>
<!ATTLIST %xsl-formatter; %step-attrs;
 output CDATA #IMPLIED
 uri CDATA #IMPLIED>
<!ELEMENT %xslt-2.0; %step-model;>
<!ATTLIST %xslt-2.0; %step-attrs;
 allow-collections CDATA #IMPLIED
 output-base-uri CDATA #IMPLIED
 allow-version-mismatch CDATA #IMPLIED
 template-name CDATA #IMPLIED
 initial-mode CDATA #IMPLIED>

<!ELEMENT %declare-step; 
   ((%input;) |
    (%output;) |
    (%option;) |
    (%documentation;))*>
<!ATTLIST %declare-step; 
  %global-attrs;
  type %QName; #REQUIRED
 >

<!ELEMENT %pipeline-library; 
   ((%import;) |
    (%declare-step;) |
    (%pipeline;) |
    (%documentation;) %extra-elts;)*>
<!ATTLIST %pipeline-library;
  %global-attrs;
  ignore-prefixes NMTOKENS #IMPLIED
  %nds; %URIref; #FIXED 'http://www.w3.org/2007/03/xproc'
  namespace %URIref; #IMPLIED>

<!ELEMENT %import; (%documentation;)*>
<!ATTLIST %import;
  %global-attrs;
  href %URIref; #REQUIRED
 >

<!ELEMENT %documentation; (p | div %doc-elts;)*>
<!ATTLIST %documentation;
  %global-attrs;>
