<!-- 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.
       extra-elts only allows extensions at the beginning of
       p:pipeline, and within p:pipeline-library

     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 % serialization "%p;serialization">
<!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 % namespaces "%p;namespaces">
<!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 % add-attribute "%p;add-attribute">
<!ENTITY % add-xml-base "%p;add-xml-base">
<!ENTITY % count "%p;count">
<!ENTITY % compare "%p;compare">
<!ENTITY % delete "%p;delete">
<!ENTITY % directory-list "%p;directory-list">
<!ENTITY % error "%p;error">
<!ENTITY % escape-markup "%p;escape-markup">
<!ENTITY % http-request "%p;http-request">
<!ENTITY % identity "%p;identity">
<!ENTITY % insert "%p;insert">
<!ENTITY % label-elements "%p;label-elements">
<!ENTITY % load "%p;load">
<!ENTITY % make-absolute-uris "%p;make-absolute-uris">
<!ENTITY % namespace-rename "%p;namespace-rename">
<!ENTITY % pack "%p;pack">
<!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;split-sequence">
<!ENTITY % store "%p;store">
<!ENTITY % string-replace "%p;string-replace">
<!ENTITY % unescape-markup "%p;unescape-markup">
<!ENTITY % unwrap "%p;unwrap">
<!ENTITY % wrap "%p;wrap">
<!ENTITY % wrap-sequence "%p;wrap-sequence">
<!ENTITY % xinclude "%p;xinclude">
<!ENTITY % xslt "%p;xslt">

<!ENTITY % exec "%p;exec">
<!ENTITY % hash "%p;hash">
<!ENTITY % relax-ng-validate "%p;validate-relax-ng">
<!ENTITY % uuid "%p;uuid">
<!ENTITY % validate-with-schematron "%p;validate-with-schematron">
<!ENTITY % www-form-urldecode "%p;www-form-urldecode">
<!ENTITY % www-form-urlencode "%p;www-form-urlencode">
<!ENTITY % xml-schema-validate "%p;validate-with-xml-schema">
<!ENTITY % xquery "%p;xquery">
<!ENTITY % xsl-formatter "%p;xsl-formatter">

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

<!ENTITY % step "(%add-attribute;|%add-xml-base;|%compare;|%count;|%delete;|
                  %directory-list;|%error;|%escape-markup;|%http-request;|
                  %identity;|%insert;|%label-elements;|%load;|
                  %make-absolute-uris;|%namespace-rename;|%pack;|%parameters;|%rename;|%replace;|
                  %set-attributes;|%sink;|%split-sequence;|%store;|
                  %string-replace;|%unescape-markup;|%unwrap;|%wrap;|
                  %wrap-sequence;|%xinclude;|%xslt;|
                  %exec;|%hash;|%relax-ng-validate;|%uuid;|%validate-with-schematron;|
                  %www-form-urldecode;|%www-form-urlencode;|%xml-schema-validate;|
                  %xquery;|%xsl-formatter; %user-steps;)">
<!ENTITY % component
 "(%step;|%group;|%viewport;|%for-each;|%choose;|%try;)">
<!ENTITY % subpipeline
 "(%component; , (%component; | %documentation;)* )?">
<!ENTITY % seqBinding
 "((%documentation;)*,
   ( ( %empty;,(%documentation;)* ) |
     ( (%document;|%pipe;|%inline;),
       (%document;|%pipe;|%inline;|%documentation;)*)))">
<!ENTITY % oneBinding
 "((%documentation;)*,(%document;|%pipe;|%inline;),(%documentation;)*)">
<!ENTITY % optBinding
 "((%documentation;|%namespaces;)*,
   ((%empty;|%document;|%pipe;|%inline;),
    (%documentation;|%namespaces;)*)?)">

<!ENTITY % NCName "NMTOKEN">
<!ENTITY % QName "NMTOKEN">
<!ENTITY % URIref "CDATA">
<!ENTITY % XPath_expression "CDATA">
<!ENTITY % XPath_match_pattern "CDATA">
<!ENTITY % port_name "%NCName;">
<!ENTITY % step_name "%NCName;">
<!ENTITY % string "CDATA">
<!ENTITY % param-spec "CDATA">
<!ENTITY % boolean "(true|false|0|1)">

<!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;))*,
    %subpipeline;)">

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

<!ELEMENT %input; (%seqBinding;)?>
<!ATTLIST %input;  
  %global-attrs;
  port %NCName; #REQUIRED
  sequence %boolean; 'false'
  primary %boolean; 'false'
  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 %boolean;  'false'
  primary %boolean; 'false'>

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

<!ELEMENT %serialization; (%documentation;)*>
<!ATTLIST %serialization;
  %global-attrs;
  port %NCName; #REQUIRED
  byte-order-mark %boolean; #IMPLIED
  cdata-section-elements NMTOKENS #IMPLIED
  doctype-public CDATA #IMPLIED
  doctype-system %URIref; #IMPLIED
  encoding NMTOKEN #IMPLIED
  escape-uri-attributes %boolean; #IMPLIED
  include-content-type %boolean; #IMPLIED
  indent %boolean; #IMPLIED
  media-type CDATA #IMPLIED
  method %QName; #IMPLIED
  normalization-form NMTOKEN #IMPLIED
  omit-xml-declaration %boolean; #IMPLIED
  standalone (true|false|omit) #IMPLIED
  undeclare-prefixes %boolean; #IMPLIED
  version CDATA #IMPLIED>
 <!-- normalization-form: NFC|NFD|NFKC|NFKD|fully-normalized|none|impl-def. . . -->

<!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 %boolean; 'false'
  value %string; #IMPLIED
  select %XPath_expression;  #IMPLIED
 >

<!ELEMENT %namespaces;
   (%documentation;)*>
<!ATTLIST %namespaces;
  %global-attrs;
  option %QName; #IMPLIED
  element %XPath_expression; #IMPLIED
  except-prefixes NMTOKENS #IMPLIED>

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

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

<!ELEMENT %viewport; 
   ((%documentation;)*,
    (%viewport-source;,(%documentation;)*)?,
    (%output;,(%documentation;)*)?,
    (%log;,(%documentation;)*)?,
    (%option;,((%option;) | (%documentation;))* )?,
    %subpipeline;)>
<!ATTLIST %viewport; 
  %step-attrs;
  match %XPath_match_pattern;  #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;)*,
    (%xpath-context;)?,
    (((%output;) |
      (%option;) |
      (%log;)),
      ((%output;) |
       (%option;) |
       (%log;) |
       (%documentation;) )* )?,
    %subpipeline;)>
<!ATTLIST %when; 
  %global-attrs;
  test %XPath_expression; #REQUIRED
 >

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

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

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

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

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

<!ELEMENT %add-attribute; %step-model;>
<!ATTLIST %add-attribute; %step-attrs;
 match CDATA #IMPLIED
 attribute-name %QName; #IMPLIED
 attribute-value CDATA #IMPLIED>
<!ELEMENT %add-xml-base; %step-model;>
<!ATTLIST %add-xml-base; %step-attrs;
 all %boolean; #IMPLIED
 relative %boolean; #IMPLIED>
<!ELEMENT %compare; %step-model;>
<!ATTLIST %compare; %step-attrs;
 fail-if-not-equal %boolean; #IMPLIED>
<!ELEMENT %count; %step-model;>
<!ATTLIST %count; %step-attrs;>
<!ELEMENT %delete; %step-model;>
<!ATTLIST %delete; %step-attrs;
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %directory-list; %step-model;>
<!ATTLIST %directory-list; %step-attrs;
 filter 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;
 cdata-section-elements NMTOKENS #IMPLIED
 doctype-public CDATA #IMPLIED
 doctype-system %URIref; #IMPLIED
 encoding NMTOKEN #IMPLIED
 escape-uri-attributes %boolean; #IMPLIED
 include-content-type %boolean; #IMPLIED
 indent %boolean; #IMPLIED
 media-type CDATA #IMPLIED
 method %QName; #IMPLIED
 omit-xml-declaration %boolean; #IMPLIED
 standalone (true|false|omit) #IMPLIED
 undeclare-prefixes %boolean; #IMPLIED
 version CDATA #IMPLIED>
<!ELEMENT %http-request; %step-model;>
<!ATTLIST %http-request; %step-attrs;
 byte-order-mark %boolean; #IMPLIED
 cdata-section-elements NMTOKENS #IMPLIED
 doctype-public CDATA #IMPLIED
 doctype-system %URIref; #IMPLIED
 encoding NMTOKEN #IMPLIED
 escape-uri-attributes %boolean; #IMPLIED
 include-content-type %boolean; #IMPLIED
 indent %boolean; #IMPLIED
 media-type CDATA #IMPLIED
 method %QName; #IMPLIED
 normalization-form NMTOKEN #IMPLIED
 omit-xml-declaration %boolean; #IMPLIED
 standalone (true|false|omit) #IMPLIED
 undeclare-prefixes %boolean; #IMPLIED
 version CDATA #IMPLIED>
<!ELEMENT %identity; %step-model;>
<!ATTLIST %identity; %step-attrs;>
<!ELEMENT %insert; %step-model;>
<!ATTLIST %insert; %step-attrs;
 match %XPath_match_pattern; #IMPLIED
 position (first-child|last-child|before|after) #IMPLIED>
<!ELEMENT %label-elements; %step-model;>
<!ATTLIST %label-elements; %step-attrs;
 attribute %QName; #IMPLIED
 suffix CDATA #IMPLIED
 prefix CDATA #IMPLIED
 select CDATA #IMPLIED
 scheme %QName; #IMPLIED>
<!ELEMENT %load; %step-model;>
<!ATTLIST %load; %step-attrs;
 validate %boolean; #IMPLIED
 href %URIref; #IMPLIED>
<!ELEMENT %make-absolute-uris; %step-model;>
<!ATTLIST %make-absolute-uris; %step-attrs;
 match %XPath_match_pattern; #IMPLIED
 base-uri %URIref; #IMPLIED>
<!ELEMENT %namespace-rename; %step-model;>
<!ATTLIST %namespace-rename; %step-attrs;
 to %URIref; #IMPLIED
 from %URIref; #IMPLIED
 elements-only %boolean; #IMPLIED>
<!ELEMENT %pack; %step-model;>
<!ATTLIST %pack; %step-attrs;
 wrapper %QName; #IMPLIED>
<!ELEMENT %parameters; %step-model;>
<!ATTLIST %parameters; %step-attrs;>
<!ELEMENT %rename; %step-model;>
<!ATTLIST %rename; %step-attrs;
 match %XPath_match_pattern; #IMPLIED
 new-name %QName; #IMPLIED>
<!ELEMENT %replace; %step-model;>
<!ATTLIST %replace; %step-attrs;
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %set-attributes; %step-model;>
<!ATTLIST %set-attributes; %step-attrs;
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %sink; %step-model;>
<!ATTLIST %sink; %step-attrs;>
<!ELEMENT %split-sequence; %step-model;>
<!ATTLIST %split-sequence; %step-attrs;
 test %XPath_expression; #IMPLIED>
<!ELEMENT %store; %step-model;>
<!ATTLIST %store; %step-attrs;
 href %URIref; #IMPLIED
 byte-order-mark %boolean; #IMPLIED
 cdata-section-elements NMTOKENS #IMPLIED
 doctype-public CDATA #IMPLIED
 doctype-system %URIref; #IMPLIED
 encoding NMTOKEN #IMPLIED
 escape-uri-attributes %boolean; #IMPLIED
 include-content-type %boolean; #IMPLIED
 indent %boolean; #IMPLIED
 media-type CDATA #IMPLIED
 method %QName; #IMPLIED
 normalization-form NMTOKEN #IMPLIED
 omit-xml-declaration %boolean; #IMPLIED
 standalone (true|false|omit) #IMPLIED
 undeclare-prefixes %boolean; #IMPLIED
 version CDATA #IMPLIED>
<!ELEMENT %string-replace; %step-model;>
<!ATTLIST %string-replace; %step-attrs;
 replace CDATA #IMPLIED
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %unescape-markup; %step-model;>
<!ATTLIST %unescape-markup; %step-attrs;
 content-type CDATA #IMPLIED
 encoding NMTOKEN #IMPLIED
 charset NMTOKEN #IMPLIED>
<!ELEMENT %unwrap; %step-model;>
<!ATTLIST %unwrap; %step-attrs;
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %wrap; %step-model;>
<!ATTLIST %wrap; %step-attrs;
 match %XPath_match_pattern; #IMPLIED
 wrapper %QName; #IMPLIED
 group-adjacent %XPath_expression; #IMPLIED>
<!ELEMENT %wrap-sequence; %step-model;>
<!ATTLIST %wrap-sequence; %step-attrs;
 wrapper CDATA #IMPLIED
 group-adjacent %XPath_expression; #IMPLIED>
<!ELEMENT %xinclude; %step-model;>
<!ATTLIST %xinclude; %step-attrs;>
<!ELEMENT %xslt; %step-model;>
<!ATTLIST %xslt; %step-attrs;
 output-base-uri %URIref; #IMPLIED
 version CDATA #IMPLIED
 template-name %QName; #IMPLIED
 initial-mode %QName; #IMPLIED>

<!ELEMENT %exec; %step-model;>
<!ATTLIST %exec; %step-attrs;
 command CDATA #IMPLIED
 args CDATA #IMPLIED
 cwd CDATA #IMPLIED
 source-is-xml %boolean; #IMPLIED
 result-is-xml %boolean; #IMPLIED
 wrap-result-lines %boolean; #IMPLIED
 errors-is-xml %boolean; #IMPLIED
 wrap-error-lines %boolean; #IMPLIED
 fix-slashes %boolean; #IMPLIED
 byte-order-mark %boolean; #IMPLIED
 cdata-section-elements NMTOKENS #IMPLIED
 doctype-public CDATA #IMPLIED
 doctype-system %URIref; #IMPLIED
 encoding NMTOKEN #IMPLIED
 escape-uri-attributes %boolean; #IMPLIED
 include-content-type %boolean; #IMPLIED
 indent %boolean; #IMPLIED
 media-type CDATA #IMPLIED
 method %QName; #IMPLIED
 normalization-form NMTOKEN #IMPLIED
 omit-xml-declaration %boolean; #IMPLIED
 standalone (true|false|omit) #IMPLIED
 undeclare-prefixes %boolean; #IMPLIED
 version CDATA #IMPLIED>
<!ELEMENT %hash; %step-model;>
<!ATTLIST %hash; %step-attrs;
 value CDATA #IMPLIED
 algorithm CDATA #IMPLIED
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %uuid; %step-model;>
<!ATTLIST %uuid; %step-attrs;
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %validate-with-schematron; %step-model;>
<!ATTLIST %validate-with-schematron; %step-attrs;>
<!ELEMENT %www-form-urldecode; %step-model;>
<!ATTLIST %www-form-urldecode; %step-attrs;
 value CDATA #IMPLIED>
<!ELEMENT %www-form-urlencode; %step-model;>
<!ATTLIST %www-form-urlencode; %step-attrs;
 match %XPath_match_pattern; #IMPLIED>
<!ELEMENT %relax-ng-validate; %step-model;>
<!ATTLIST %relax-ng-validate; %step-attrs;
 dtd-compatibility %boolean; #IMPLIED
 assert-valid %boolean; #IMPLIED>
<!ELEMENT %xml-schema-validate; %step-model;>
<!ATTLIST %xml-schema-validate; %step-attrs;
 assert-valid %boolean; #IMPLIED
 mode (strict|lax) #IMPLIED>
<!ELEMENT %xquery; %step-model;>
<!ATTLIST %xquery; %step-attrs;>
<!ELEMENT %xsl-formatter; %step-model;>
<!ATTLIST %xsl-formatter; %step-attrs;
 content-type CDATA #IMPLIED
 uri %URIref; #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
  xpath-version CDATA "1.0"
  %nds; %URIref; #FIXED 'http://www.w3.org/ns/xproc'
  namespace %URIref; #IMPLIED
  name %NCName; #IMPLIED>

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

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