tmiller     02/03/05 11:26:35

  Modified:    java/src/org/apache/xalan/xsltc/trax DOM2SAX.java
                        SAX2DOM.java TransformerImpl.java
  Log:
  bug 6620 fix: DOMSource no longer requires
  Document nodes, fix contrib by Santiago Pericas-Geersten
  
  Revision  Changes    Path
  1.9       +4 -4      xml-xalan/java/src/org/apache/xalan/xsltc/trax/DOM2SAX.java
  
  Index: DOM2SAX.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/DOM2SAX.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DOM2SAX.java      8 Oct 2001 14:11:31 -0000       1.8
  +++ DOM2SAX.java      5 Mar 2002 19:26:35 -0000       1.9
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOM2SAX.java,v 1.8 2001/10/08 14:11:31 morten Exp $
  + * @(#)$Id: DOM2SAX.java,v 1.9 2002/03/05 19:26:35 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -85,11 +85,11 @@
   
   class DOM2SAX implements XMLReader , Locator {
   
  -    private Document _dom = null;
  +    private Node _dom = null;
       private ContentHandler _sax = null;
    
       public DOM2SAX(Node root) {
  -     _dom = (Document)root;
  +     _dom = root;
       }
   
       public ContentHandler getContentHandler() { 
  @@ -123,7 +123,7 @@
   
       private void parse(Node node) throws IOException, SAXException {
           Node first = null;
  -     if (node == null ) return;
  +     if (node == null) return;
   
           switch (node.getNodeType()) {
        case Node.ATTRIBUTE_NODE:         // handled by ELEMENT_NODE
  
  
  
  1.6       +2 -1      xml-xalan/java/src/org/apache/xalan/xsltc/trax/SAX2DOM.java
  
  Index: SAX2DOM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/SAX2DOM.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SAX2DOM.java      21 Feb 2002 16:36:43 -0000      1.5
  +++ SAX2DOM.java      5 Mar 2002 19:26:35 -0000       1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: SAX2DOM.java,v 1.5 2002/02/21 16:36:43 tmiller Exp $
  + * @(#)$Id: SAX2DOM.java,v 1.6 2002/03/05 19:26:35 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -101,6 +101,7 @@
   
       public void startDocument() {
        _document = _builder.newDocument();
  +     _nodeStk.push(_document);
        // bugfix 6417, contributed by Tim Elcott
       }
   
  
  
  
  1.35      +17 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- TransformerImpl.java      28 Feb 2002 19:16:39 -0000      1.34
  +++ TransformerImpl.java      5 Mar 2002 19:26:35 -0000       1.35
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TransformerImpl.java,v 1.34 2002/02/28 19:16:39 tmiller Exp $
  + * @(#)$Id: TransformerImpl.java,v 1.35 2002/03/05 19:26:35 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -409,8 +409,14 @@
            // Handle DOMSource input
            else if (source instanceof DOMSource) {
                final DOMSource   domsrc = (DOMSource)source;
  -             final Document    tree = (Document)domsrc.getNode();
  -             final DOM2SAX     dom2sax = new DOM2SAX(tree);
  +             final org.w3c.dom.Node node = domsrc.getNode();
  +
  +             boolean isComplete = true;
  +             if (node.getNodeType() != org.w3c.dom.Node.DOCUMENT_NODE) {
  +                 isComplete = false;
  +             }
  +
  +             final DOM2SAX     dom2sax = new DOM2SAX(node);
                final InputSource input = null; 
                final String      systemId = domsrc.getSystemId(); 
   
  @@ -425,7 +431,13 @@
                dom2sax.setContentHandler(builder);
   
                // Parse the input and build the internal DOM
  +             if (!isComplete) {
  +                 builder.startDocument();
  +             }
                dom2sax.parse(input); // need this parameter?
  +             if (!isComplete) {
  +                 builder.endDocument();
  +             }
                dom.setDocumentURI(systemId);
            }
            // Handle StreamSource input
  @@ -757,14 +769,13 @@
       private Properties createOutputProperties() {
        
        // Level3: Return the default property value
  -     // bug # 6751 fixed by removing setProperty lines for 
  -     //  OutputKeys.(DOCTYPE_PUBLIC|DOCTYPE_SYSTEM|CDATA_SECTION_ELEMENTS)
  -     //  instead of setting them to "" (EMPTY_STRING). Fix contributed
  -     //  by Derek Sayeau.   
        Properties third = new Properties();
        third.setProperty(OutputKeys.ENCODING, "UTF-8");
        third.setProperty(OutputKeys.METHOD, XML_STRING);
        third.setProperty(OutputKeys.INDENT, NO_STRING);
  +     third.setProperty(OutputKeys.DOCTYPE_PUBLIC, EMPTY_STRING);
  +     third.setProperty(OutputKeys.DOCTYPE_SYSTEM, EMPTY_STRING);
  +     third.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS, EMPTY_STRING);
        third.setProperty(OutputKeys.MEDIA_TYPE, "text/xml");
        third.setProperty(OutputKeys.OMIT_XML_DECLARATION, NO_STRING);
        third.setProperty(OutputKeys.STANDALONE, NO_STRING);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to