XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Stephan KüblerSubject: Processing Nodes in Java extensions
Author: Stephan Kübler
Date: 25 Jan 2006 03:58 AM
Hi all,

i'm using the new SS 2006 Enterprise version to debug my XSLT-files. Now i want to process a selected node in my own Java extension like this:

<xsl:template match="REFERENCE">
<xsl:variable name="Ref" select="MyExt:getNodeForRef(.)"/>
<xsl:apply-templates select="$Ref"/>
</xsl:template>

My Java function look like this:

public static Object getNodeForRef(org.w3c.dom.Node nodeRef){
System.out.println("==== getNodeForRef() for " + nodeRef.getTextContent() + " called ====");
return XMLConverter.getInstance().getNodeForRef(nodeRef);
}

If i call nodeRef.getTextContent(), i get an exception:
Transform.xsl (253, 60): java.lang.RuntimeException: java.lang.AbstractMethodError: org.apache.xml.dtm.ref.DTMNodeProxy.getTextContent()Ljava/lang/String;

In my SS-environment im using the xalan-transformer. When i make the transformation in my own Java-application (with xalan-j_2_7_0) it works.

Can somebody help me, please!!!

Thanx!

Postnext
Ivan PedruzziSubject: Processing Nodes in Java extensions
Author: Ivan Pedruzzi
Date: 25 Jan 2006 11:53 AM
Hi Stephan,

XalanJ 2.5.2 relies on XercesJ 2.5 XML parser that doesn't support DOM level 3 features like getTextContent. But you can still achieve the same result with any XML parser with few changes

Change your Java function like the following

public Object getNodeForRef(org.w3c.dom.Node nodeRef, String value){
System.out.println("==== getNodeForRef() for " + value + " called ====");
return XMLConverter.getInstance().getNodeForRef(nodeRef);return nodeRef;
}

Change your XSLT like the following

<xsl:variable name="Ref" select="IntDate:getNodeForRef(., string(.))"/>

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Stephan KüblerSubject: Processing Nodes in Java extensions
Author: Stephan Kübler
Date: 26 Jan 2006 03:39 AM
Originally Posted: 26 Jan 2006 03:36 AM
Hi Ivan!! thanks for the quick reply! But i want not just call getTextContent() for my Node in my XMLConverter class, i want to call other functions, too. So my question is: is there a possibility to use the new Xalan 2.7.0 -version with the Stylusstudio, or, if not, can i get a documentation about the old DOM-API, so that i know, which functions of the org.w3c.dom.Node interface i can call with the older Xalan 2.5.0?!? Kind regards and thank you again!

Postnext
Tony LavinioSubject: Processing Nodes in Java extensions
Author: Tony Lavinio
Date: 26 Jan 2006 10:21 AM
The 2.6.x docs should be pretty close, since they still deal with
DOM 2 only.
See http://www.stylusstudio.com/api/xalan-j_2_6_0/index.htm

Postnext
Stephan KüblerSubject: Processing Nodes in Java extensions
Author: Stephan Kübler
Date: 26 Jan 2006 11:13 AM
Ok,
now my problem is that i have to read the entities of the ownerdocument of the Node-object. With Xalan 2.7.0 i can call getOwnerDocument().getDocumentType().getEntities()
Is there any possiblity to get this also with DOM2?? Otherwise it's not possible to debug my xsl-files :-(

Postnext
Ivan PedruzziSubject: Processing Nodes in Java extensions
Author: Ivan Pedruzzi
Date: 26 Jan 2006 04:27 PM

If you end up manipulating the DOM inside extension functions looks
like you are fighting the XSLT rather then take advantage of it.

Could you tell us more about what you are trying to achive?


Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Stephan KüblerSubject: Processing Nodes in Java extensions
Author: Stephan Kübler
Date: 27 Jan 2006 03:44 AM
yes, i believe that it must look like that!!
What i want to do inside my extension function is to get referenced nodes, that are inside another XML-document and transform these nodes also in my XSL-file. To look up for the referenced document i have to look inside the entity block of my XML-document where i find a system-id. With this system-id i have to look in a catalog-file(not a XML-catalog, but a SGML-catalog) for the path to the referenced file(the system-id could also be overwritten by a new system-id in another catalog-file). So i use the class CatalogResolver.
If i got the referenced document i can search the node via ID (the referenced node may also have references to another file).
So i decided to write an extension function because i found no way to get the system-id in the entity-block and to get the correct document via the catalog-file. The entity looks like this:
<!ENTITY nodereference PUBLIC "system-id" "./reference.xml" NDATA SGML>
Is this possible with XSLT? Maybe. I'm not a XSLT-guru :-)
So, i hope, you can understand this. It was quite long.

Postnext
Ivan PedruzziSubject: Processing Nodes in Java extensions
Author: Ivan Pedruzzi
Date: 27 Jan 2006 09:54 AM

If I have undestood what you are saying you want to access some XML stored inside an external entity

<!ENTITY nodereference PUBLIC "system-id" "./reference.xml" NDATA XML>

...

The unparsed-entity-uri function returns the entity URI that can be used as argument to the document function

<xsl:apply-templates select="document(unparsed-entity-uri('nodereference'))"/>


Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Stephan KüblerSubject: Processing Nodes in Java extensions
Author: Stephan Kübler
Date: 27 Jan 2006 10:38 AM
No, this won't work, because then i get ./reference.xml from the entity. I have to get the system-id and then look inside the catalog-files. So it's more complicated. Do you know if a new Stylus version is planned with the XalanJ 2.7.0??

Posttop
Ivan PedruzziSubject: Processing Nodes in Java extensions
Author: Ivan Pedruzzi
Date: 27 Jan 2006 02:52 PM
It may be useful to know that XalanJ supports a set of built-in functions based on the NodeInfo class
http://xml.apache.org/xalan-j/extensionslib.html#nodeinfo

For instance the following code returns the system ID of the given node including nodes created expanding an external reference.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:NodeInfo="org.apache.xalan.lib.NodeInfo">
...
<xsl:value-of select="NodeInfo:systemId(.)"/>


Adding support for XalanJ 2.7.0 is in our TO DO list but we don't have a firm plan for it yet.

You can still execute the newer XalanJ as custom processor (without debugging support) using the following settings

Command Line: java org.apache.xalan.xslt.Process -L -IN %1 -XSL %2 -OUT %3
Classpath: <xalan dir>\xalan.jar


Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.