12.07.2015 Views

A Tutorial on XProc - HCIM

A Tutorial on XProc - HCIM

A Tutorial on XProc - HCIM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Outline• Pipeline C<strong>on</strong>cepts• Syntax Overview• Steps• Other Pipeline Elements• Standard Step Library• Recipes


<strong>XProc</strong>: Background


• XML processing is becoming mainstream• XSLT, XQuery, Schema validati<strong>on</strong>, etc.• How to glue them all coherently, in orderto create (complex) XML applicati<strong>on</strong>s?


XML Pipelines.http://www.w3.org/XML/<strong>XProc</strong>/docs/langspec.html


<strong>XProc</strong>: C<strong>on</strong>cepts


Step (Pipeline)Step (Choose)StylesheetSourceV1.0 Schema/*[@versi<strong>on</strong>


C<strong>on</strong>cepts: Steps• Compound (e.g., Pipeline, Choose)• C<strong>on</strong>tainers for other steps (definedthrough subpipelines)• Atomic (e.g., Validate, XSLT)• Referenced by name


C<strong>on</strong>cepts: I/O• XML documents (i.e., infosets) flow inside apipeline• A step definiti<strong>on</strong> states which inputs andoutputs it requires (single or sequence)• Steps are c<strong>on</strong>nected together throughpipes between inputs and outputs, defininga pipeline’s flow• No loops (directed acyclic graph)• As streamable as possible (huge datasets)


C<strong>on</strong>cepts: I/O• Steps have primary inputs and outputs (andmay have sec<strong>on</strong>dary)• Steps may accept opti<strong>on</strong>s (name/valuepairs)• Steps may accept parameters (name/valuepairs)


C<strong>on</strong>cepts: XPath c<strong>on</strong>text• May occur in several places:• Compound steps, compute opti<strong>on</strong> andparameter values, values passed to steps• XPath 1.0 or 2.0 (depending <strong>on</strong>implementati<strong>on</strong>s)


C<strong>on</strong>cepts: XPath c<strong>on</strong>text• Processor vs. step c<strong>on</strong>text levels• XPath extensi<strong>on</strong> functi<strong>on</strong>s• System properties• Step available• Iterati<strong>on</strong> positi<strong>on</strong>• Iterati<strong>on</strong> size


<strong>XProc</strong>: Syntax


Simplified(<strong>on</strong>e has to say)


Extended(<strong>on</strong>e wants to mean)


Syntax: Verbosity• Simple pipelines stay simple• Defaults take care of all the acti<strong>on</strong>• Complex pipelines require “unleashing thebeast”, becoming more verbose• Explicit c<strong>on</strong>texts, pipes, additi<strong>on</strong>alnamespaces


Syntax: NamespacesFeatureCore vocabularyURIhttp://www.w3.org/ns/xprocStep specific vocabulary http://www.w3.org/ns/xproc-stepErrorsStandard step libraryhttp://www.w3.org/ns/xproc-errorhttp://www.w3.org/ns/xproc/1.0


Syntax: Scopes• Step types must have unique names withinthe running envir<strong>on</strong>ment• Step names must be unique, to bereferenced within their envir<strong>on</strong>ment (i.e.,everything in the pipeline)• Step opti<strong>on</strong>s are <strong>on</strong>ly visible bydescendants


Syntax: Binding by URI


Syntax: Binding by source


Syntax: Inline binding. . .


Syntax: Empty binding


Syntax: Other things• Globally accepted attributes• xml:id, xml:base• Documentati<strong>on</strong>• • Extensi<strong>on</strong> elements and attributes


<strong>XProc</strong>: Steps


foo.xmlSteps: p:pipelinefoo.xhtmlImplicit primary ports: source and result


Steps: p:for-eachfoo1.xmlfoo2.xml. . .fo<strong>on</strong>.xmlfoo1.xhtmlfoo2.xhtml. . .fo<strong>on</strong>.xhtmlImplicit primary input port: current


Steps: p:for-eachfoo1.xmlfoo2.xmlfoo1.xhtml foo2.xhtml foo3.xhtml foo4.xhtmlTransform nodes into documents through select


Steps: p:for-eachfoo1.xmlfoo2.xmlfoo1.xhtmlfoo3.xhtmlfoo2.xhtmlfoo4.xhtmlSupports multiple output bindings


Steps: p:for-eachfoo1.xmlfoo2.xmlfoo1.xhtmlfoo3.xhtmlfoo1.fofoo3.fofoo2.xhtmlfoo4.xhtmlfoo2.fofoo4.foSupports multiple output bindings


Steps: p:viewportImplicit primary input port: current


Steps: p:choose.........


Steps: p:choose............Expressi<strong>on</strong>s default to a comm<strong>on</strong> XPath c<strong>on</strong>text


Steps: p:choose..................But can target multiple XPath c<strong>on</strong>texts


Steps: p:groupEncapsulator for local scopes (e.g., p:opti<strong>on</strong>s)


Steps: p:try...error getting resourceerrorgetting resourcePrevents and c<strong>on</strong>trols errors within pipelines


Steps: p:tryResource not found.p:catch default readable port: error


<strong>XProc</strong>: Other elements


Other elements: InputDocuments (declare) p:empty, p:pipe, p:document, p:inline (use)Iterati<strong>on</strong> source p:empty, p:pipe, p:document, p:inline (declare)Viewport source p:pipe, p:document, p:inline (declare)


Other elements: OutputDocuments (declare) p:empty, p:pipe, p:document,p:inline (use, <strong>on</strong>ly compound steps)Logging (declare, can occur in any step)Serialisati<strong>on</strong> (huge set of opti<strong>on</strong>s, declare, can occur just in p:pipeline)


Other elements:Opti<strong>on</strong>s and ParametersOpti<strong>on</strong>s p:empty, p:pipe, p:document, p:inline,p:namespaces p:namespaces Parameters p:empty, p:pipe, p:document, p:inline,p:namespaces p:namespaces


Other elements:Declaring Stepsp:inputp:outputp:opti<strong>on</strong>p:importp:declare-stepp:logp:serializati<strong>on</strong>subpipeline


Other elements: LibrariesLibraryp:importp:declare-stepImport


<strong>XProc</strong>:Standard Step Library


Standard Step Library:Required Stepsp:add-attribute, p:add-xml-base, p:compare, p:count,p:delete, p:directory-list, p:error, p:escape-markup,p:http-request, p:identity, p:insert, p:label-elements, p:load,p:make-absolute-uris, p:namespace-rename, p:pack,p:parameters, p:rename, p:replace, p:set-attributes, p:sink,p:split-sequence, p:store, p:unescape-markup,p:string-replace, p:unwrap, p:wrap, p:wrap-sequence,p:xinclude, p:xslt


Standard Step Library:Opti<strong>on</strong>al Stepsp:exec, p:hash, p:uuid, p:validate-with-relax-ng,p:validate-with-schematr<strong>on</strong>, p:validate-with-xml-schema,p:www-form-urldecode, p:www-form-urlencode,p:xquery, p:xsl-formatter


<strong>XProc</strong>: Recipes


Recipes:Include, Validate, Transform


Recipes:Safe processing...


Recipes:RemovalElements (including subtrees)Elements (excluding subtrees)Attributes


Recipes:Transform set of files


Thank you.Working Group Homepagehttp://www.w3.org/XML/Processing/Current state of the spechttp://www.w3.org/XML/<strong>XProc</strong>/docs/langspec.htmlOfficial URL for the spechttp://www.w3.org/TR/xproc/Known implementati<strong>on</strong>s (not up-to-date with spec)http://del.icio.us/ndw/xprocimpl

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!