XALAN Extension: xsl:copy-of beteewn some costum tags
"Sticker, Markus / Kuehne + Nagel / Ham MI-EC /external" <[email protected]> Mon, 17 Jan 2011 15:03:25 +0100
| Newsgroups | gmane.text.xml.xalan.java.user |
|---|---|
| Message-ID | <8BE1FACDAC82D647B750825BCA346AE202CED385@w3hamboex11.ger.win.int.kn> |
Hello,
I tried to have a copy of some nodes from the source xml, and push them to my java field.
XML
---------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?> <bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<ISBN>3543554362345</ISBN>
<author>J K. Rowling</author>
<author>James Linn</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<ISBN>76842354362345</ISBN>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
</bookstore>
XSL
---------------------------------------------------------------------
<?xml version='1.0' ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="ext.core" xmlns:saxon="http://saxon.sf.net/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xalan="http://xml.apache.org/xalan" extension-element-prefixes="ext saxon" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="xalan exslt fn saxon" >
<xalan:component prefix="ext" elements="init line" functions="read">
<xalan:script lang="javaclass" src="ext.core"/>
</xalan:component>
<xsl:output method="xml"/>
<xsl:template match="/">
<root>
<xsl:variable name="varA" select="/bookstore/book" />
<ext:dispatcher>
<xsl:copy-of select="$varA"
</ext:dispatcher>
</dispatcher>
</root>
JAVA
---------------------------------------------------------------------
package ext;
import java.text.ParseException;
import org.w3c.dom.NodeList;
import javax.xml.transform.TransformerException;
public class core {
private NodeList nl;
public void dispatcher(
org.apache.xalan.extensions.XSLProcessorContext context,
org.apache.xalan.templates.ElemExtensionCall call) {
nl = call.getChildNodes();
}
}
The result is that there are some Nodes with copy of inside "nl".
So maybe somebody can tell me why this will happen.
best regards
markus
Kuehne + Nagel (AG & Co.) KG, Geschaeftsleitung: Hans-Georg Brinkmann (Vors.), Dirk Blesius, Reiner Heiken, Bruno Mang, Alfred Manke, Christian Marnetté, Mark Reinhardt, Jens Wollesen, Klaus Jaeger (stellv.), Sitz: Bremen, Registergericht: Bremen, HRA 21928, USt-IdNr.: DE 812773878, Persoenlich haftende Gesellschaft: Kuehne & Nagel A.G., Sitz: Contern/Luxemburg Geschaeftsfuehrender Verwaltungsrat: Klaus-Michael Kuehne