mmidy       01/02/15 13:53:49

  Modified:    java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java
  Log:
  Fix problem with processing an input source created from a reader with no 
systemId
  Fix problem with reading an input source file twice if it has a PI
  
  Revision  Changes    Path
  1.23      +43 -12    
xml-xalan/java/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
  
  Index: XSLTEngineImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- XSLTEngineImpl.java       2001/02/12 16:14:34     1.22
  +++ XSLTEngineImpl.java       2001/02/15 21:53:45     1.23
  @@ -200,7 +200,8 @@
       throws org.xml.sax.SAXException
     {    
       m_tfactory = TransformerFactory.newInstance();
  -    m_problemListener = new ProblemListenerDefault();    
  +    m_problemListener = new ProblemListenerDefault();
  +    //m_liaison =  (DOM2Helper)createLiaison();
     }
   
     /**
  @@ -294,6 +295,15 @@
   
       //xctxt.setDOMHelper(m_liaison);    
     }
  +  
  +  /** 
  +   * Get a Liaison class
  +   */
  +  public XMLParserLiaison createLiaison()
  +    throws org.xml.sax.SAXException
  +  {
  +    return new org.apache.xalan.xpath.xml.XMLParserLiaisonDefault();    
  +  }
    
     /**
      * Reset the state.  This needs to be called after a process() call
  @@ -355,11 +365,16 @@
               m_stylesheetParams.put(name, val);
             }
             catch(TransformerException te)
  -          {}
  +          {
  +            throw new SAXException(te);
  +          }
           }
           m_needToEval = false;
           m_evalList = null;
         }
  +      
  +      sourceTree = getSourceTreeFromInput(inputSource);
  +      
         if(null != stylesheetSource)
         {
           try{
  @@ -371,9 +386,8 @@
           }  
           
         }      
  -      else if(null != inputSource)
  -      {        
  -        sourceTree = getSourceTreeFromInput(inputSource);
  +      else if( null != inputSource)
  +      { 
           if(null != sourceTree)
           {
             String stylesheetURI = null;
  @@ -394,7 +408,7 @@
                     {
                       String typeVal = tokenizer.nextToken();
                       typeVal = typeVal.substring(1, typeVal.length()-1);
  -                    if(!typeVal.equals("text/xsl"))
  +                    if(!typeVal.equals("text/xsl") && 
!typeVal.equals("text/xml") && !typeVal.equals("application/xml+xslt"))
                       {
                         isOK = false;
                       }
  @@ -432,7 +446,7 @@
               prevStylesheet = stylesheet;
               isRoot = false;
             }
  -        }
  +        }        
         }
         else
         {
  @@ -478,7 +492,7 @@
           }  
           
           try{
  -          m_transformerImpl.transform(inputSource.getSourceObject(),
  +          m_transformerImpl.transform(new DOMSource(sourceTree),
                       outputTarget.getResultObject());
           }
           catch (TransformerException te)
  @@ -534,6 +548,25 @@
         throw new SAXException(tce);
       }
     }
  +  
  +  /**
  +   * Bottleneck the creation of the stylesheet for derivation purposes.
  +   */
  +  StylesheetRoot createStylesheetRoot(String baseIdentifier, XSLTInputSource 
source)
  +    throws MalformedURLException, FileNotFoundException,
  +           IOException, SAXException
  +  {
  +    try{
  +      Source inSource = source.getSourceObject();
  +      Templates templates = m_tfactory.newTemplates(inSource);
  +      StylesheetRoot stylesheet = new 
StylesheetRoot((org.apache.xalan.templates.StylesheetRoot)templates);      
  +      return stylesheet;      
  +    }
  +    catch (TransformerConfigurationException tce)
  +    {
  +      throw new SAXException(tce);
  +    }
  +  }
   
     /**
      * Given a URI to an XSL stylesheet,
  @@ -586,7 +619,7 @@
         }
         else
         {
  -        m_stylesheetRoot = 
createStylesheetRoot(stylesheetSource.getSystemId());
  +        m_stylesheetRoot = 
createStylesheetRoot(stylesheetSource.getSystemId(), stylesheetSource);
           addTraceListenersToStylesheet();
           
           
  @@ -786,7 +819,6 @@
       FileNotFoundException,
       IOException
     {
  -    StylesheetRoot m_stylesheetRoot = null;
       Stylesheet stylesheet = null;
       String[] stringHolder =
       {
  @@ -945,8 +977,7 @@
         URL xslURL = getURLFromString(xslURLString, xmlBaseIdent);
   
         XSLTInputSource inputSource = new XSLTInputSource(xslURL.toString());
  -      String liaisonClassName = m_liaison.getClass().getName();
  -
  +      
         if(null != m_liaison)
         {
           try{
  
  
  

Reply via email to