sboag 99/12/14 12:49:21
Modified: src/org/apache/xalan/xslt ElemCopyOf.java
Log:
Fix for xsl:copy-of for root node, if we just copy the whole document, a
startDoc and endDoc get, generated, so we need to only walk the child nodes.
Revision Changes Path
1.3 +15 -2 xml-xalan/src/org/apache/xalan/xslt/ElemCopyOf.java
Index: ElemCopyOf.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemCopyOf.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElemCopyOf.java 1999/11/28 10:26:22 1.2
+++ ElemCopyOf.java 1999/12/14 20:49:20 1.3
@@ -137,11 +137,24 @@
// System.out.println(value);
NodeList nl = value.nodeset();
int nChildren = nl.getLength();
- org.apache.xalan.xpath.xml.TreeWalker tw = new
org.apache.xalan.xpath.xml.TreeWalker(processor.m_resultTreeHandler);
+ org.apache.xalan.xpath.xml.TreeWalker tw
+ = new
org.apache.xalan.xpath.xml.TreeWalker(processor.m_resultTreeHandler);
for(int i = 0; i < nChildren; i++)
{
Node pos = (Node)nl.item(i);
- tw.traverse(pos);
+ // If we just copy the whole document, a startDoc and endDoc get
+ // generated, so we need to only walk the child nodes.
+ if(pos.getNodeType() == Node.DOCUMENT_NODE)
+ {
+ for(Node child = pos.getFirstChild(); child != null; child =
child.getNextSibling())
+ {
+ tw.traverse(child);
+ }
+ }
+ else
+ {
+ tw.traverse(pos);
+ }
}
break;