boolean isOK = true; StringTokenizer tokenizer = new StringTokenizer(pi.getNodeValue(), " \t="); while(tokenizer.hasMoreTokens())
ProcessingInstruction pi = (ProcessingInstruction)child; if(pi.getNodeName().equals("xml-stylesheet") || pi.getNodeName().equals("xml:stylesheet"))
  public void process( XSLTInputSource inputSource,                       XSLTInputSource stylesheetSource,                       XSLTResultTarget outputTarget)    throws SAXException  {    try    {      Boolean totalTimeID = new Boolean(true);      pushTime(totalTimeID);      Node sourceTree = null;      if(null != inputSource)        sourceTree = getSourceTreeFromInput(inputSource);      Templates templates = null;      if (m_needToEval)      {        Node node = null;        if (null != stylesheetSource)        {          Source ssSource = stylesheetSource.getSourceObject();          if(ssSource instanceof DOMSource)          {            node = ((DOMSource)ssSource).getNode();          }        }        if (null == node)        {          node = new DOM2Helper().createDocument() ;         }        for (int i=0; i< m_evalList.size(); i++)        {          String name = (String)m_evalList.elementAt(i);          String expression = (String)m_stylesheetParams.get(name);          try{            org.apache.xpath.objects.XObject val = org.apache.xpath.XPathAPI.eval(node, expression);                        m_stylesheetParams.put(name, val);          }          catch(TransformerException te)          {}        }        m_needToEval = false;        m_evalList = null;      }      if(null != stylesheetSource)      {        try{        templates = m_tfactory.newTemplates(stylesheetSource.getSourceObject());        }        catch (TransformerConfigurationException tce)        {          throw new SAXException(tce);        }                }            else if(null != sourceTree)      {        String stylesheetURI = null;        Stack hrefs = new Stack();        for(Node child=sourceTree.getFirstChild(); null != child; child=child.getNextSibling())        {          if(Node.PROCESSING_INSTRUCTION_NODE == child.getNodeType())          {            ProcessingInstruction pi = (ProcessingInstruction)child;            if(pi.getNodeName().equals("xml-stylesheet")               || pi.getNodeName().equals("xml:stylesheet"))            {              boolean isOK = true;              StringTokenizer tokenizer = new StringTokenizer(pi.getNodeValue(), " \t=");              while(tokenizer.hasMoreTokens())              {                if(tokenizer.nextToken().equals("type"))                {                  String typeVal = tokenizer.nextToken();                  typeVal = typeVal.substring(1, typeVal.length()-1);                  if(!typeVal.equals("text/xsl"))                  {                    isOK = false;                  }                }              }              if(isOK)              {                tokenizer = new StringTokenizer(pi.getNodeValue(), " \t=");                while(tokenizer.hasMoreTokens())                {                  if(tokenizer.nextToken().equals("href"))                  {                    stylesheetURI = tokenizer.nextToken();                    stylesheetURI = stylesheetURI.substring(1, stylesheetURI.length()-1);                    hrefs.push(stylesheetURI);                  }                }                              }            }          }        } // end for(int i = 0; i < nNodes; i++)        boolean isRoot = true;        Stylesheet prevStylesheet = null;        while(!hrefs.isEmpty())        {          Stylesheet stylesheet = getStylesheetFromPIURL((String)hrefs.pop(), sourceTree,                                                         (null != inputSource)                                                         ? inputSource.getSystemId() : null,                                                         isRoot);          if(false == isRoot)          {            prevStylesheet.setImport((StylesheetComposed)stylesheet);          }          prevStylesheet = stylesheet;          isRoot = false;        }      }      else      {        error(XSLTErrorResources.ER_NO_INPUT_STYLESHEET); //"Stylesheet input was not specified!");      }                 if(null == templates)      {        if (m_stylesheetRoot != null)          templates = m_stylesheetRoot.getObject();        else        {            error(XSLTErrorResources.ER_FAILED_PROCESS_STYLESHEET); //"Failed to process stylesheet!");          return;        }        }      if(null != sourceTree)      {        try{          m_transformerImpl = (TransformerImpl)templates.newTransformer();           if (m_problemListener != null)            m_transformerImpl.setErrorListener(m_problemListener);          if (m_liaison != null)          m_transformerImpl.getXPathContext().setDOMHelper(m_liaison);           }        catch (TransformerConfigurationException tce)        {          throw new SAXException(tce);        }                  if (m_stylesheetParams != null)        {          Enumeration keys = m_stylesheetParams.keys();          while (keys.hasMoreElements())          {            String name = (String)keys.nextElement();            Object value = m_stylesheetParams.get(name);             m_transformerImpl.setParameter(name, null, value);          }         }                  try{          m_transformerImpl.transform(inputSource.getSourceObject(),                    outputTarget.getResultObject());        }        catch (TransformerException te)        {          throw new SAXException(te);        }          if(null != m_diagnosticsPrintWriter)        {          displayDuration("Total time", totalTimeID);        }      }    }    catch(MalformedURLException mue)    {      error(XSLTErrorResources.ERROR0000, new Object[] {mue.getMessage()}, mue);      // throw se;    }    catch(FileNotFoundException fnfe)    {      error(XSLTErrorResources.ERROR0000, new Object[] {fnfe.getMessage()}, fnfe);      // throw se;    }    catch(IOException ioe)    {      error(XSLTErrorResources.ERROR0000, new Object[] {ioe.getMessage()}, ioe);      // throw se;    }    catch(SAXException se)    {      error(XSLTErrorResources.ER_SAX_EXCEPTION, se); //"SAX Exception", se);      // throw se;    }  }