Andrew Chamberlain wrote:
Hi Luca/All,
Sorry. On further testing, we're still not getting through the full
tree fragment to Java.
I've adapted the java method to give details of what it receives:
public String addGML(org.w3c.dom.Node myNode)
{
System.out.println("Class = "+node.getClass().getName());
System.out.println("Name = "+node.getNodeName());
System.out.println("Has children =
"+(node.hasChildNodes()?"Yes":"No"));
System.out.println("First Child Name =
"+node.getFirstChild().getNodeName());
System.out.println("First Child Text =
"+node.getFirstChild().getTextContent());
}
and from this comes the following output:
Class = org.apache.xml.dtm.ref.DTMNodeProxy
Name = gml:Polygon
Has children = Yes
First Child Name = #text
The last line (which uses the getTextContent() method) throws the
following exception:
javax.xml.transform.TransformerException: java.lang.AbstractMethodError:
org.apache.xml.dtm.ref.DTMNodeProxy.getTextContent()Ljava/lang/String;
at
org.apache.xalan.extensions.ExtensionHandlerJavaClass.callFunction(ExtensionHandlerJavaClass.java:396)
...
Firstly, I was expecting the Class to be "org.w3c.dom.Node", so does
anyone know how I can enable this?
DTMNodeProxy is the concrete implementation class, so it makes sense
that you get that. org.w3c.dom.Node would just be one of the (possibly
many) interfaces it implements so I wouldn't expect getClass().getName()
to return it. I think what you're really wanting is node.getNodeType()
which returns one of the node type constants (see the Node javadoc).
I was also expecting the name of the
first child to be "gml:exterior" instead of a "#text". The XML I'm
sending is given below:
<gml:Polygon gml:id="GATS1153_10">
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">-155.42 55.58</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
My guess is that the first child of gml:Polygon is actually the
whitespace text node before the gml:exterior element. Pretty easy to
test by looking at the length of getChildNodes() which would be 3. To
get straight to the gml:exterior you could use getElementsByTagNameNS,
or check each child node's nodeType for ELEMENT_NODE.
Is it possible I actually need to pass a tree fragment, rather than a
node-set?
As a reminder, the XSLT given below. Any help would me greatly
appreciated. In simple terms, I'm just trying to pass the above XML
from XSLT to Java, preferably as a w3c Node.
Kind regards,
Andy
The XSLT:
<xsl:stylesheet ... myClass="xalan://my.package.name.MyClass">
...
<xsl:variable name="gmlAdder" select="myClass:new()"/>
<xsl:variable name="gml">
<xsl:copy-of select="@* | node()"/>
</xsl:variable>
<xsl:variable name="result" select="myClass:addGML($gmlAdder,$gml)"/>
...
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]