3.6 Conditional ‘if’ statements

Execute the enclosed instructions provided the named XML code satisfied the named DTD conditions.

<if xml="..." dtd="..." root="..." >  
   ...  
</if>

<..xtpipes entries..>+
 | if
 -_-_-

<..xtpipes.dtd..>+
 <!ELEMENT if (#PCDATA <.xtpipes entries.>)* >
 <!ATTLIST if
           xml CDATA #REQUIRED
           dtd CDATA #REQUIRED
           root CDATA #REQUIRED
 >
 -_-_-

<..execute if..>
 try{
    <.doc = dtd + xml.>
    byte [] bytes = doc.getBytes("UTF-8");
    ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
    InputSource in = new InputSource( bais );
    SAXParser saxParser = saxFactory.newSAXParser();
    XMLReader xmlReader = saxParser.getXMLReader();
    xmlReader.parse( in );
    <.trace if true.>
    execute( node.getFirstChild() );
 } catch ( Exception e ){ <.trace if false.> }
 -_-_-

<..doc = dtd + xml..>
 String xml = node.getAttributes()
                  .getNamedItem( "xml" ).getNodeValue();
 String dtd = node.getAttributes()
                  .getNamedItem( "dtd" ).getNodeValue();
 // String root = node.getAttributes()
 //                 .getNamedItem( "root" ).getNodeValue();
 String doc = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
              + "<!DOCTYPE doc [\n"
              + (String) map.get(dtd)
              + "\n]>\n"
              + (String) map.get(xml) ;
 -_-_-

<..xtpipes initialization..>+
 saxFactory = SAXParserFactory.newInstance();
 saxFactory.setValidating(true);
 -_-_-

<..xtpipes fields..>+
 private static SAXParserFactory saxFactory;
 -_-_-