cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Chamberlain <an...@comsine.co.uk>
Subject Re: Passing a node-set from XSLT to Java
Date Thu, 03 Jul 2008 11:16:14 GMT
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?  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>

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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message