You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/06/18 23:43:06 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath SourceTreeManager.java

sboag       01/06/18 14:43:05

  Modified:    java/src/org/apache/xalan/processor ProcessorInclude.java
                        TransformerFactoryImpl.java
               java/src/org/apache/xalan/templates ElemChoose.java
               java/src/org/apache/xalan/transformer
                        TransformerIdentityImpl.java TransformerImpl.java
               java/src/org/apache/xml/dtm/ref DTMManagerDefault.java
               java/src/org/apache/xpath SourceTreeManager.java
  Log:
  In response to bugzilla bug #2124.  Don't set dynamic validation to
  true if the XMLReader was handed in via a SAXSource.
  
  Revision  Changes    Path
  1.19      +5 -2      xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java
  
  Index: ProcessorInclude.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ProcessorInclude.java	2001/04/11 16:02:21	1.18
  +++ ProcessorInclude.java	2001/06/18 21:42:42	1.19
  @@ -260,6 +260,8 @@
           reader = saxSource.getXMLReader(); // may be null
         }
         
  +      boolean isUserReader = (reader != null);
  +      
         InputSource inputSource = SAXSource.sourceToInputSource(source);
   
         if (null == reader)
  @@ -291,8 +293,9 @@
           reader.setContentHandler(handler);
           try
           {
  -          reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  -                            true);
  +          if(!isUserReader)
  +            reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  +                              true);
           }
           catch(org.xml.sax.SAXException se) {}
           
  
  
  
  1.34      +5 -2      xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- TransformerFactoryImpl.java	2001/06/12 19:14:48	1.33
  +++ TransformerFactoryImpl.java	2001/06/18 21:42:43	1.34
  @@ -829,6 +829,8 @@
   
         if (source instanceof SAXSource)
           reader = ((SAXSource) source).getXMLReader();
  +        
  +      boolean isUserReader = (reader != null);
   
         if (null == reader)
         {
  @@ -865,8 +867,9 @@
         // reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
         try
         {
  -        reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  -                          true);
  +        if(!isUserReader)
  +          reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  +                            true);
         }
         catch (org.xml.sax.SAXException ex)
         {
  
  
  
  1.12      +4 -4      xml-xalan/java/src/org/apache/xalan/templates/ElemChoose.java
  
  Index: ElemChoose.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemChoose.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemChoose.java	2001/06/12 19:15:07	1.11
  +++ ElemChoose.java	2001/06/18 21:42:49	1.12
  @@ -152,15 +152,12 @@
   
             if (test.bool())
             {
  +            transformer.getTraceManager().fireTraceEvent(when);
               transformer.executeChildTemplates(when, true);
   
               return;
             }
   
  -          // I don't think we want this.  -sb
  -          //  if (TransformerImpl.S_DEBUG)
  -          //    transformer.getTraceManager().fireSelectedEvent(sourceNode, when,
  -          //            "endTest", when.getTest(), test);
           }
           else if (when.getTest().bool(xctxt, sourceNode, when))
           {
  @@ -172,6 +169,9 @@
         else if (Constants.ELEMNAME_OTHERWISE == type)
         {
           found = true;
  +
  +        if (TransformerImpl.S_DEBUG)
  +          transformer.getTraceManager().fireTraceEvent(childElem);
   
           // xsl:otherwise                
           transformer.executeChildTemplates(childElem, true);
  
  
  
  1.14      +5 -2      xml-xalan/java/src/org/apache/xalan/transformer/TransformerIdentityImpl.java
  
  Index: TransformerIdentityImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerIdentityImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TransformerIdentityImpl.java	2001/06/18 20:51:46	1.13
  +++ TransformerIdentityImpl.java	2001/06/18 21:42:52	1.14
  @@ -361,6 +361,8 @@
     
           if (source instanceof SAXSource)
             reader = ((SAXSource) source).getXMLReader();
  +          
  +        boolean isUserReader = (reader != null);
     
           if (null == reader)
           {
  @@ -398,8 +400,9 @@
           {
             reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
                               true);
  -          reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  -                            true);
  +          if(!isUserReader)
  +            reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  +                              true);
           }
           catch (org.xml.sax.SAXException se)
           {
  
  
  
  1.100     +0 -144    xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- TransformerImpl.java	2001/06/15 21:18:35	1.99
  +++ TransformerImpl.java	2001/06/18 21:42:54	1.100
  @@ -851,150 +851,6 @@
       return (Properties) getOutputFormat().getProperties().clone();
     }
   
  -  // %REVIEW% OK to delete?  Who needs this?
  -  //  /**
  -  //   * <meta name="usage" content="internal"/>
  -  //   * Process the an input source to a DOM node.  FOR INTERNAL USE ONLY.
  -  //   * 
  -  //   * @param xmlSource  The input for the source tree.
  -  //   *
  -  //   * @return The Node result of the parse, never null.
  -  //   *
  -  //   * @throws TransformerException
  -  //   */
  -  //  public Node parseToNode(Source source) throws TransformerException
  -  //  {
  -  //    if(source instanceof DOMSource)
  -  //      return ((DOMSource)source).getNode();
  -  //    
  -  //    InputSource xmlSource = SAXSource.sourceToInputSource(source);
  -  //    if(null == xmlSource)
  -  //    {
  -  //      throw new TransformerException("Can't transform a Source of type "+
  -  //        source.getClass().getName()+"!");
  -  //    }
  -  //
  -  //    // Duplicate code from above... but slightly different.  
  -  //    // TODO: Work on this...
  -  //    if (null != xmlSource.getSystemId())
  -  //      m_urlOfSource = xmlSource.getSystemId();
  -  //
  -  //    Node doc = null;
  -  //    try
  -  //    {
  -  //      // Get an already set XMLReader, or create one.
  -  //      XMLReader reader = null;
  -  //      if(source instanceof SAXSource)
  -  //        reader = ((SAXSource)source).getXMLReader();
  -  //
  -  //      if (null == reader)
  -  //      {
  -  //        // Use JAXP1.1 ( if possible )
  -  //        try {
  -  //          javax.xml.parsers.SAXParserFactory factory=
  -  //                                                     javax.xml.parsers.SAXParserFactory.newInstance();
  -  //          factory.setNamespaceAware( true );
  -  //          javax.xml.parsers.SAXParser jaxpParser=
  -  //                                                 factory.newSAXParser();
  -  //          reader=jaxpParser.getXMLReader();
  -  //          
  -  //        } catch( javax.xml.parsers.ParserConfigurationException ex ) {
  -  //          throw new org.xml.sax.SAXException( ex );
  -  //        } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
  -  //            throw new org.xml.sax.SAXException( ex1.toString() );
  -  //        } catch( NoSuchMethodError ex2 ) {
  -  //        }
  -  //        catch (AbstractMethodError ame){}
  -  //      }
  -  //
  -  //      if (null == reader)
  -  //      {
  -  //        reader = XMLReaderFactory.createXMLReader();
  -  //      }
  -  //
  -  //      try
  -  //      {
  -  //        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
  -  //                          true);
  -  //        reader.setFeature(
  -  //                          "http://apache.org/xml/features/validation/dynamic", true);
  -  //      }
  -  //      catch (org.xml.sax.SAXException se)
  -  //      {
  -  //
  -  //        // What can we do?
  -  //        // TODO: User diagnostics.
  -  //      }
  -  //
  -  //      // TODO: Handle Xerces DOM parser.
  -  //      // Get the input content handler, which will handle the 
  -  //      // parse events and create the source tree.
  -  //      ContentHandler inputHandler = getInputContentHandler();
  -  //      Class inputHandlerClass = ((Object) inputHandler).getClass();
  -  //
  -  //      inputHandler = (ContentHandler) inputHandlerClass.newInstance();
  -  //
  -  //      reader.setContentHandler(inputHandler);
  -  //      if(inputHandler instanceof org.xml.sax.DTDHandler)
  -  //        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
  -  //      try
  -  //      {
  -  //        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  -  //          reader.setProperty("http://xml.org/sax/properties/lexical-handler",
  -  //                             inputHandler);
  -  //        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  -  //          reader.setProperty("http://xml.org/sax/properties/declaration-handler",
  -  //                             inputHandler);
  -  //      }
  -  //      catch(SAXNotRecognizedException snre){}
  -  //      try
  -  //      {
  -  //        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  -  //          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler",
  -  //                             inputHandler);
  -  //        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  -  //          reader.setProperty("http://xml.org/sax/handlers/DeclHandler",
  -  //                             inputHandler);
  -  //      }
  -  //      catch(org.xml.sax.SAXNotRecognizedException snre)
  -  //      {
  -  //      }
  -  //      getXPathContext().setPrimaryReader(reader);
  -  //
  -  //      // ...and of course I need a standard way to get a node...
  -  //      if (inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)
  -  //      {
  -  //
  -  //        // Kick off the parse.  When the ContentHandler gets 
  -  //        // the startDocument event, it will call transformNode( node ).
  -  //        reader.parse(xmlSource);
  -  //
  -  //        doc =
  -  //             ((org.apache.xalan.stree.SourceTreeHandler) inputHandler).getRoot();
  -  //      }
  -  //
  -  //    }
  -  //    catch (java.lang.IllegalAccessException iae)
  -  //    {
  -  //      throw new TransformerException(iae);
  -  //    }
  -  //    catch (InstantiationException ie)
  -  //    {
  -  //      throw new TransformerException(ie);
  -  //    }
  -  //    catch(org.xml.sax.SAXException se)
  -  //    {
  -  //      throw new TransformerException(se);
  -  //    }
  -  //    catch (IOException ioe)
  -  //    {
  -  //      throw new TransformerException(ioe);
  -  //    }
  -  //
  -  //
  -  //    return doc;
  -  //  }
  -
     /**
      * Create a result ContentHandler from a Result object, based
      * on the current OutputProperties.
  
  
  
  1.7       +14 -9     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DTMManagerDefault.java	2001/06/15 18:46:41	1.6
  +++ DTMManagerDefault.java	2001/06/18 21:42:59	1.7
  @@ -475,6 +475,8 @@
       {
         XMLReader reader = (inputSource instanceof SAXSource)
                            ? ((SAXSource) inputSource).getXMLReader() : null;
  +                         
  +      boolean isUserReader = (reader != null);
   
         if (null == reader)
         {
  @@ -516,16 +518,19 @@
           // TODO: User diagnostics.
         }
   
  -      try
  +      if(!isUserReader)
         {
  -        reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  -                          true);
  -      }
  -      catch (org.xml.sax.SAXException se)
  -      {
  -
  -        // What can we do?
  -        // TODO: User diagnostics.
  +        try
  +        {
  +          reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  +                            true);
  +        }
  +        catch (org.xml.sax.SAXException se)
  +        {
  +  
  +          // What can we do?
  +          // TODO: User diagnostics.
  +        }
         }
   
         return reader;
  
  
  
  1.27      +5 -2      xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java
  
  Index: SourceTreeManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/SourceTreeManager.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- SourceTreeManager.java	2001/06/12 19:16:07	1.26
  +++ SourceTreeManager.java	2001/06/18 21:43:03	1.27
  @@ -383,6 +383,8 @@
       {
         XMLReader reader = (inputSource instanceof SAXSource)
                            ? ((SAXSource) inputSource).getXMLReader() : null;
  +                         
  +      boolean isUserReader = (reader != null);
   
         if (null == reader)
         {
  @@ -409,8 +411,9 @@
         {
           reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
                             true);
  -        reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  -                          true);
  +        if(!isUserReader)
  +          reader.setFeature("http://apache.org/xml/features/validation/dynamic",
  +                            true);
         }
         catch (org.xml.sax.SAXException se)
         {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org