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 January 9th, 2008, 04:38 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default calling java extension

I have built a java extension, but am receiving an error when calling the function.

The XSLT:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" version="2.0"
      xmlns:parse="java:ParseNodeSet">

      <xsl:template match="/">
            <xsl:variable name="table" select="parse:buildAndParseNodeset(//schedule)"/>

            <html>
                  <head/>
                  <body><xsl:copy-of select="$table"/></body>
            </html>

      </xsl:template>

</xsl:stylesheet>

The error msg:

C:\Users\Deep\Desktop\saxonsa8-9-0-4j>java -jar saxon8.jar template.xml generate
Table.xsl
Error at xsl:variable on line 9 of file:/C:/Users/Deep/Desktop/saxonsa8-9-0-4j/g
enerateTable.xsl:
  XPST0003: XPath syntax error at char 48 on line 9 in {...eNodeset(//ns1:Energy
Schedu...}:
    Cannot find a matching 1-argument function named {java:ParseNodeSet}buildAnd
ParseNodeset()
Failed to compile stylesheet. 1 error detected.

Does anyone have any ideas why saxon is not able to locate the function?

The class and java files are stored within the saxon folder, and the cass has been defined on the classpath.

Any help is greatly appreciated.
 
Old January 9th, 2008, 04:44 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

A common mistake - when you use the -jar option to run a Java application, the classpath is ignored, so only the classes in the JAR file are available. You need to use the

java -cp... net.sf.saxon.Transform

approach.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 9th, 2008, 04:50 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forgive me I am new to calling java extensions, how would I call that from the command line? I tried

>java net.sf.saxon.Transform file.xml file.xsl

but received the same message
 
Old January 10th, 2008, 09:04 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

java net.sf.saxon.Transform -s:source -xsl:stylesheet -o:output

http://www.saxonica.com/documentatio...mmandline.html

/- Sam Judson : Wrox Technical Editor -/
 
Old January 10th, 2008, 01:03 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Possible reasons for failing to find a class are that the class isn't on the classpath (OK, you say it is, but we've all been wrong on this); that the class isn't public; that the method isn't public; that the method isn't static.

Using the -TJ option on the command line will produce diagnostics that may help you to distinguish these possible causes.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
CALLING A TEMPLATE WITHIN JAVA SCRIPT SOMANATHAN10 XSLT 6 February 14th, 2007 02:10 AM
calling crystal report from java radha Crystal Reports 1 May 24th, 2006 09:55 AM
calling java function from xsl pandian XSLT 1 December 21st, 2005 12:59 PM
Java Extension Function in XSLT Mostafa XSLT 1 January 18th, 2005 11:13 AM
Calling Java from PL/SQL cooldude87801 Oracle 0 August 20th, 2003 05:42 PM





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