[dsdl-discuss] DSDL Use Case on NetKernel: Part 2

From: Peter Rodgers <pjr@1060.org>
Date: Tue Mar 22 2005 - 15:08:11 UTC

This example shows the same 'pipeline' as we showed in Part 1. Here it
is written using an asynchronous process pattern. Each sub-part of the
use-case is executed asynchronously in forked sub-processes.

To illustrate how XML pipelining is generally not language specific we
have written the sub-processes in different languages - it is frequently
very valuable to be able to move back and forth between declarative and
procedural approaches within the same XML process.

In the parent process we are asynchronously invoking sub-processes and
passing an argument 'parameter' to the child process. Each child process
accesses the argument within their execution context with the URI
'this:param:parameter' - just a named argument on the active URI.

<idoc>
        <seq>
                <comment>
                **************
                A. Fork an asynchronous DPML process to process the HTML
                **************
                </comment>
                <instr>
                        <type>async</type>
                        <uri>active:dpml</uri>
                        <operand>html-process.idoc</operand>
                        <parameter>this:param:input</parameter>
                        <target>var:html-proc</target>
                </instr>
                <comment>
                **************
                B. Fork an asynchronous Beanshell (scripted Java)
                process to process the SVG
                **************
                </comment>
                <instr>
                        <type>async</type>
                        <uri>active:beanshell</uri>
                        <operand>svg-process.bsh</operand>
                        <parameter>this:param:input</parameter>
                        <target>var:svg-proc</target>
                </instr>
                <comment>
                **************
                C. Fork an asynchronous Python process to process the
                MathML
                **************
                </comment>
                <instr>
                        <type>async</type>
                        <uri>active:python</uri>
                        <operand>mathml-process.py</operand>
                        <parameter>this:param:input</parameter>
                        <target>var:mathml-proc</target>
                </instr>
                <comment>
                **************
                D. Continue with the Docbook processing in this
                parent...
                **************
                </comment>
                <comment>
                **************
                8. Use the DSRL definitions in convert-mynames.xml to
                convert the tags in the local nameset to the form that
                can be used to validate the remaining part of the
                document using docbook.dtd.
                **************
                </comment>
                <instr>
                        <type>nvdl</type>
                        <source>this:param:input</source>
                        <rules>nvdl-docbook-processing-rules.xml</rules>
                        <target>var:docbook</target>
                </instr>
                <instr>
                        <type>dsrl</type>
                        <source>var:docbook</source>
                        <rules>convert-mynames.xml</rules>
                        <target>var:docbook</target>
                </instr>
                <instr>
                        <type>validate-DTD</type>
                        <source>var:docbook</source>
                        <schema>docbook-validation.dtd</schema>
                        <target>var:docbook-validated</target>
                </instr>
                <comment>
                **************
                9. Use the CRDL rules defined in mycharacter-checks.xml
                to validate that the correct character sets have been
                used for text identified as being Greek and Cyrillic.
                Note here we target to the same variable like x=f(x)
                **************
                </comment>
                <instr>
                        <type>crdl</type>
                        <source>var:docbook-validated</source>
                        <crdl-rules>mycharacter-checks.xml</crdl-rules>
                        <target>var:docbook-validated</target>
                </instr>
                <comment>
                **************
                10. Convert the Docbook tags to HTML so that they can be displayed
in a web browser using the docbook-html.xslt
                transformation rules.
                **************
                </comment>
                <instr>
                        <type>transform-XSLT</type>
                        <source>var:docbook-validated</source>
                        <transform>docbook-html.xslt</transform>
                        <target>var:docbook-as-html</target>
                </instr>
                <comment>
                **************
                E. Rejoin all asynchronous processes...
                **************
                </comment>
                <instr>
                  <type>join</type>
                  <operand>var:html-proc</operand>
                  <target>var:html</target>
                </instr>
                <instr>
                  <type>join</type>
                  <operand>var:svg-proc</operand>
                  <target>var:svg</target>
                </instr>
                <instr>
                  <type>join</type>
                  <operand>var:mathml-proc</operand>
                  <target>var:mathml</target>
                </instr>
                <comment>
                **************
                After completion of step 10 the HTML (both streams), and
                SVG (both streams) should be recombined to produce a
                single stream that can fed to a web browser.
                **************
                </comment>
                <instr>
                        <type>transform-XSLT</type>
                        <source>var:docbook</source>
                        <transform>
                                stylesheet-to-aggregate-everything.xslt
                        </transform>
                        <html-param>var:html</html-param>
                        <svg-param>var:svg</svg-param>
                        <mathml-param>var:mathml</mathml-param>
                        <target>this:response</target>
                </instr>
                <exception>
                        <comment>
                         **************
                        Here we are catching any exception in this
                        pipeline or any of the asynchronous child
                        pipelines - we are simply logging it and then
                        rethrowing it to the process which called this
                        pipeline. We could start the exectuion of an
                        error handling process here.
                        **************
                        </comment>
                        <instr>
                                <type>log</type>
                                <operand>this:exception</operand>
                        </instr>
                        <instr>
                                <type>throw</type>
                                <operand>this:exception</operand>
                        </instr>
                </exception>
        </seq>
</idoc>

html-process.idoc : An HTML Pipeline Process in DPML
----------------------------------------------------
<idoc>
        <seq>
                <comment>
                **************
                1. Use NVDL to split out the parts of the document that
                are encoded using HTML, SVG and MathML from the bulk of
                the document, whose tags are defined using a
                user-defined set of markup tags.
                **************
                </comment>
                <instr>
                        <type>nvdl</type>
                        <source>this:param:parameter</source>
                        <rules>nvdl-html-processing-rules.xml</rules>
                        <target>var:html</target>
                </instr>
                <comment>
                **************
                2. Validate the HTML elements and attributes using the
                HTML 4.0 DTD (W3C XML DTD).
                **************
                </comment>
                <instr>
                        <type>validate-DTD</type>
                        <source>var:html</source>
                        <schema>DTD-schema.dtd</schema>
                        <target>var:html</target>
                </instr>
                <comment>
                **************
                3. Use a set of Schematron rules stored in
                check-metadata.xml to ensure that the metadata
                of the HTML elements defined using Dublin Core semantics
                conform to the information in the document about the
                document's title and subtitle, author, encoding type,
                etc.
                **************
                </comment>
                <instr>
                        <type>validate-Schematron</type>
                        <source>var:html</source>
                        <schema>check-metadata.xml</schema>
                        <target>this:response</target>
                </instr>
        </seq>
</idoc>

svg-process.bsh : An SVG Pipeline Process in Beanshell (Scripted Java)
----------------------------------------------------------------------

main()
{ //Execute NVDL to extract SVG
        req=context.createSubRequest();
        req.setURI("nvdl");
        req.addArgument("source", "this:param:parameter");
        req.addArgument("rules", "nvdl-svg-processing-rules.xml");
        result=context.issueSubRequest(req);

        //Validate with XML Schema
        req=context.createSubRequest();
        req.setURI("validate-XSD");
        req.addArgument("source", result);
        req.addArgument("schema", "svg-1.2.xsd");
        result=context.issueSubRequest(req);

        //Validate with Schematron
        req=context.createSubRequest();
        req.setURI("validate-Schematron");
        req.addArgument("source", result);
        req.addArgument("schema", "SVG-subset.xml");
        result=context.issueSubRequest(req);

        //Issue response
        response=context.createResponseFrom(result);
        context.setResponse(response);
}

mathml-process.py : A MathML Pipeline Process - in Python
---------------------------------------------------------

#Execute NVDL to extract MathML
req=context.createSubRequest()
req.setURI("nvdl")
req.addArgument("source", "this:param:parameter")
req.addArgument("rules", "nvdl-mathml-processing-rules.xml")
result=context.issueSubRequest(req)

#Validate with Relax NG
req=context.createSubRequest()
req.setURI("validate-RelaxNG")
req.addArgument("source", result)
req.addArgument("schema", "mathml-1.0.rng")
result=context.issueSubRequest(req)

#Transform MathML to SVG
req=context.createSubRequest()
req.setURI("transform-XSLT")
req.addArgument("source", result)
req.addArgument("transform", "MathML-SVG.xslt")
result=context.issueSubRequest(req)

#Issue Response
response=context.createResponseFrom(result)
context.setResponse(response)

--
DSDL members discussion list
To unsubscribe, please send a message with the
command  "unsubscribe" to dsdl-discuss-request@dsdl.org
(mailto:dsdl-discuss-request@dsdl.org?Subject=unsubscribe)
Received on Tue Mar 22 16:08:36 2005

This archive was generated by hypermail 2.1.8 : Tue Mar 22 2005 - 15:13:01 UTC