Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2009, 12:18 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rushman
Default Extensions in Java and null pointers

Hi!

I had to code an extension function in Java. The following is a basic example. Let's say:

myURI:getContent(node) which returns the text content of a node or null if it's an empty node.

In my code, I try the following:

<xsl:variable name="myContent">
<xsl:if test="myURI:getContent(//someNode) = 'US'">true</xsl:if>
</xsl:variable>

And it works.

But the following crashes:

<xsl:variable name="myContent" select="myURI:getContent(//someNode)"/>

The latter throws a NullPointerException.

From what I understand, extensions should never return null values but an empty String. Am I right?

Thanks for your time,

RushMan
__________________
Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.

Last edited by rushman; November 3rd, 2009 at 12:20 PM..
 
Old November 3rd, 2009, 12:35 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The behaviour of Java extension functions depends entirely on the XSLT processor you are using (which you haven't told us).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old November 3rd, 2009, 12:39 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rushman
Default

Hello Mr. Kay!

I'm using Xalan-Java. This is unfortunately not MY choice...

Rushman
 
Old November 3rd, 2009, 12:44 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I'm using Xalan-Java

Then I regret I can't help you. You may be better off asking on a forum specific to this product.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Jumping into java extensions to Saxon mphare XSLT 2 April 29th, 2008 10:02 PM
entity handling with java extensions stolte XSLT 2 January 23rd, 2008 05:31 AM
C/C++ Pointers reality_42000 C++ Programming 1 March 4th, 2007 01:26 AM
pointers Stuby085 Visual C++ 1 August 30th, 2003 11:58 PM
Pointers jake VB How-To 12 June 21st, 2003 11:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.