7.2 The Search Engine

<..xtpipes fields DELETED..>
 private static class XtPipesSearch extends DefaultHandler {
    public void  endElement(String uri,
                            String localName, String qName){
      <.extract root element name.>
    }
    public void processingInstruction(String target, String attrs) {
      if( !needScript && target.equals("xtpipes") ){
         <.extract script file name.>
 }  } }
 -_-_-

The input file is searched for an alternative script within a processing instruction of the form <?xtpipes file="..." ?>.

<..extract root element name..>
 rootName = qName;
 -_-_-

<..extract script file name..>
 try {
    <.get sax reader.>
    saxReader.setContentHandler(new DefaultHandler() {
       public void startElement(String uri, String localName,
          String qName, Attributes atts) {
          String filename = atts.getValue("file");
          if( filename != null ){
             scriptFile = filename;
             <.show script file name in log file.>
             needScript = true;
       }  }
    });
    String str = "<xtpipes " + attrs + "/>";
    StringReader reader = new StringReader(str);
    InputSource in = new InputSource(reader);
    saxReader.parse(in);
    saxReaderStack.push( saxReader );
 } catch(Exception e){
    System.err.println( "--- Error 10 --- " + e );
 }
 -_-_-

<..xtpipes fields..>+
 private static String  rootName;
 -_-_-

<..init fields..>+
 rootName = null;
 -_-_-