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
John van HaandelSubject: Crash while invoking Java Extension function that returns NodeList
Author: John van Haandel
Date: 24 Jun 2005 06:09 AM
Hello,

Can anyone help me with the following problem.
Via an xslt map, I try to invoke a Java extension class. But Stylus Studio crashes while invoking the method of this class. Does anybody know what I'm doning wrong ?

Thanks

John van Haandel


I'm using Stylus Studio 6 XML Professional Edition Release 2
Framework version Build 287m
and JVM : 1.4.2_07-b05 Java HotSpot(TM) Client VM Sun Microsystems Inc.

I've written the following class:
import org.w3c.dom.*;
import javax.imageio.metadata.IIOMetadataNode;

public class TestValueMapping {

public TestValueMapping(){
}

public static Object returnNodeSet(String firstString, String secondString){

IIOMetadataNode retFrag = new IIOMetadataNode("John0001");
DocumentFragment df = null;
IIOMetadataNode myNode = new IIOMetadataNode(firstString);
IIOMetadataNode my2Node = new IIOMetadataNode(secondString);
myNode.setNodeValue(firstString);
retFrag.appendChild(myNode);
my2Node.setNodeValue(secondString);
retFrag.appendChild(my2Node);
Node realNode = (Node) retFrag.cloneNode(true);
return retFrag.getChildNodes();



I invoke the java extension class via the following lines in an XSLT mapping:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:com_philips_pbas_xi_general_DateTimeISO8601="com.philips.pbas.xi.general.DateTimeISO8601" xmlns:com_philips_pbas_xi_general_EscapeString="com.philips.pbas.xi.general.EscapeString" xmlns:com_philips_pbas_xi_general_TestClass="com.philips.pbas.xi.general.TestClass" xmlns:com_philips_pbas_xi_xslt_lookup_TestValueMapping="com.philips.pbas.xi.xslt.lookup.TestValueMapping">
<xsl:template match="/">
<cXML version="1.2.009">
<xsl:attribute name="version">
<xsl:for-each select="com_philips_pbas_xi_xslt_lookup_TestValueMapping:returnNodeSet(string('John3'),string('Johannes3'))">
*<xsl:copy-of select="."/>*
</xsl:for-each>
</xsl:attribute>


Unknownstruzzo(176).log
struzzo.log

Unknownhs_err_pid1396.log
hs_err_pid1396.log

Posttop
Ivan PedruzziSubject: Crash while invoking Java Extension function that returns NodeList
Author: Ivan Pedruzzi
Date: 24 Jun 2005 04:13 PM
John

The Stylus Studio built-in processor doesn't support creation of XML fragments. Even so it should not crash, the problem will be fixed in future update.

Still you can run your extension function using the XalanJ processor (click "..." -> processors -> XalanJ)

There are two additional problems:

1) Your XSLT is trying to insert nodes under an attribute which doesn't make sense. Change your code like this

<cXML version="1.2.009">
<xsl:attribute name="version"/>
<xsl:for-each select="com_philips_pbas_xi_xslt_lookup_TestValueMapping:returnNodeSet(string('John3'),string('Johannes3'))">
<xsl:copy-of select="."/>
</xsl:for-each>
</cXML>


2) the Java extension is trying to call setNodeVale on an Element that does nothing. setNodeVale only works on Text node.
In alternative you can use attributes like that:

public static Object returnNodeSet(String firstString, String secondString) throws ParserConfigurationException
{
IIOMetadataNode retFrag = new IIOMetadataNode("John0001");
IIOMetadataNode myNode = new IIOMetadataNode(firstString);
IIOMetadataNode my2Node = new IIOMetadataNode(secondString);
// Use Attributes instead
retFrag.setAttribute(firstString, firstString);
retFrag.setAttribute(secondString, secondString);
return retFrag;
}

Be carefull because as you can read from IIOMetadataNode javaDoc

http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/metadata/IIOMetadataNode.html

<<"
This class is not intended to be used for general XML processing. In particular, Element nodes created within the Image I/O API are not compatible with those created by Sun's standard implementation of the org.w3.dom API. In particular, the implementation is tuned for simple uses and may not perform well for intensive processing.
">>


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.