jkesselm    01/11/07 06:42:26

  Modified:    java/src/org/apache/xalan/transformer
                        ClonerToResultTree.java ResultTreeHandler.java
  Log:
  Bugzilla 4607; allow explicitly cloning namespace nodes rather than
  throwing exception.
  
  Revision  Changes    Path
  1.12      +10 -4     
xml-xalan/java/src/org/apache/xalan/transformer/ClonerToResultTree.java
  
  Index: ClonerToResultTree.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ClonerToResultTree.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ClonerToResultTree.java   2001/10/05 16:33:14     1.11
  +++ ClonerToResultTree.java   2001/11/07 14:42:26     1.12
  @@ -206,7 +206,6 @@
           break;
         case DTM.DOCUMENT_FRAGMENT_NODE :
         case DTM.DOCUMENT_NODE :
  -
           // Can't clone a document, but refrain from throwing an error
           // so that copy-of will work
           break;
  @@ -221,9 +220,9 @@
             }
   
             String ns = dtm.getNamespaceURI(node);
  -       // JJK SAX apparently expects "no namespace" to be represented
  -       // as "" rather than null.
  -       if(ns==null)ns="";
  +          // JJK SAX apparently expects "no namespace" to be represented
  +          // as "" rather than null.
  +          if(ns==null)ns="";
   
             String localName = dtm.getLocalName(node);
   
  @@ -238,6 +237,13 @@
         case DTM.ATTRIBUTE_NODE :
           rth.addAttribute(node);
           break;
  +                     case DTM.NAMESPACE_NODE:
  +                             // %REVIEW% Normally, these should have been 
handled with element.
  +                             // It's possible that someone may write a 
stylesheet that tries to
  +                             // clone them explicitly. If so, we need the 
equivalent of
  +                             // rth.addAttribute().
  +                     rth.processNSDecls(node,DTM.NAMESPACE_NODE,dtm);
  +                             break;
         case DTM.COMMENT_NODE :
           XMLString xstr = dtm.getStringValue (node);
           xstr.dispatchAsComment(rth);
  
  
  
  1.51      +14 -0     
xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java
  
  Index: ResultTreeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- ResultTreeHandler.java    2001/10/11 12:49:44     1.50
  +++ ResultTreeHandler.java    2001/11/07 14:42:26     1.51
  @@ -1193,6 +1193,9 @@
   
     /**
      * Copy <KBD>xmlns:</KBD> attributes in if not already in scope.
  +   * 
  +   * As a quick hack to support ClonerToResultTree, this can also be used
  +   * to copy an individual namespace node.
      *
      * @param src Source Node
      * NEEDSDOC @param type
  @@ -1224,6 +1227,17 @@
             }
           }
         }
  +      else if (type == DTM.NAMESPACE_NODE)
  +                     {
  +          String prefix = dtm.getNodeNameX(src);
  +          String desturi = getURI(prefix);
  +          String srcURI = dtm.getNodeValue(src);
  +
  +          if (!srcURI.equalsIgnoreCase(desturi))
  +          {
  +            this.startPrefixMapping(prefix, srcURI, false);
  +          }
  +                     }
       }
       catch (org.xml.sax.SAXException se)
       {
  
  
  

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

Reply via email to