Hi All,
I am trying to create a Java extension function (which accepts a
string and returns a Node) and call it from an XSLT template. I have
managed to successfully do that before with Saxon but now with my
very simple example I am having problems and not sure why.
I am using Saxon 8.4 and JDK 1.4.2-50.
My stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" version="4.0"/>
<xsl:variable name="genericLinker" select="genericLinker:new()"
xmlns:genericLinker="java:GenericLinker"/>
<xsl:template match="text()">
<xsl:copy-of select="genericLinker:addLinks($genericLinker,.)"
xmlns:genericLinker="java:GenericLinker"/>
</xsl:template>
</xsl:stylesheet>
My GenericLinker java class:
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class GenericLinker{
public GenericLinker (){
}
public Element test(String a){
Element returnNode=null;
try{
org.w3c.dom.Document doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
returnNode = doc.createElement("div");
returnNode.appendChild(doc.createTextNode("test"));
}
catch(Exception e ){
}
return returnNode;
}
}
But applying the stylesheet above to a test document returns
something like:
<div>test</div>
I was hoping to get back a proper <div> node, instead of the returned
result. Can anybody spot an error either with my stylesheet or the
Java code?
Regards,
Yeliz
--------------------------------------------------------
School of Computer Science
The University of Manchester
Manchester
M13 9PL
--------------------------------------------------------
|