Sticker, Markus / Kuehne + Nagel / Ham MI-EC /external schrieb am 17.01.2011 um 14:16 (+0100): > > I tried to have a copy of some nodes from the source xml, and push them to > my java field.
> XSL > --------------------------------------------------------------------- Not well-formed. I tidied this up a bit: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:ext="ext.core" exclude-result-prefixes="xalan" extension-element-prefixes="ext"> <xalan:component prefix="ext" elements="init line" functions="read"> <xalan:script lang="javaclass" src="ext.core"/> </xalan:component> <xsl:template match="/"> <root> <xsl:variable name="varA" select="/bookstore/book" /> <ext:dispatcher> <xsl:copy-of select="$varA"/> </ext:dispatcher> </root> </xsl:template> </xsl:stylesheet> > 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. Well, your extension element has one child element node, the local name of which is copy-of. <ext:dispatcher> <xsl:copy-of select="$varA"/> </ext:dispatcher> I'm not sure you're aware of what technological choices are available for handling XML, and which ones are best suited for certain tasks. The XSLT extension mechanism you're using here is rather advanced and probably not the most suitable facility for extracting information from an XML file as per the example you gave. Actually, XSLT is overkill for that. XPath is still high-level and would probably suffice: import org.w3c.dom.*; import org.apache.xpath.*; ... Node contextNode = dom.getDocumentElement(); NodeList nl = XPathAPI.selectNodeList(contextNode, ".//book"); Possibly even plain DOM could be an option? To get better help, you might want to clarify your actual requirements. Hope this helps! -- Michael Ludwig