Mixing SAX and DOM
Example of a pipeline mixing SAX and DOM
Index > Books > Cocoon 2 NetKernel Adaption Kit > Example Pipelines > Mixing SAX and DOM


<idoc>
  <comment>Initialise Cocoon if necessary</comment>
  <instr>
    <type>cocoon.Initialise</type>
    <operand>cocoon.xconf</operand>
  </instr>
  <comment>Read XML document from a URI</comment>
  <instr>
    <type>cocoon.generator.FileGenerator</type>
    <src>data.xml</src>
    <target>var:a</target>
  </instr>
  <comment>Transform with STM (Simple Tree Manipulation) with implicit conversion to DOM</comment>
  <instr>
    <type>stm</type>
    <operand>var:a</operand>
    <operator>
      <stm:group xmlns:stm="http://1060.org/stm">
        <stm:set xpath="/root/message">hello from DOM</stm:set>
      </stm:group>
    </operator>
    <target>var:b</target>
  </instr>
  <comment>Transform with Cocoon XSLT with implicit conversion back to SAX</comment>
  <instr>
    <type>cocoon.transformer.TraxTransformer</type>
    <src>simple.xsl</src>
    <operand>var:b</operand>
    <target>var:c</target>
  </instr>
  <comment>Serialise to HTML</comment>
  <instr>
    <type>cocoon.serializer.HTMLSerializer</type>
    <operand>var:c</operand>
    <configuration>
      <configuration mime-type="text/html">
        <doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
        <doctype-system>http://www.w3.org/TR/html4/loose.dtd</doctype-system>
      </configuration>
    </configuration>
    <target>this:response</target>
  </instr>
</idoc>
© 2003,2004, 1060 Research Limited
1060 registered trademark, NetKernel trademark of 1060 Research Limited