473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Problem calling Java method in XSLT (Xalan)

Hi -

I'm a bit of a newbie to the world of XSLTs but am trying to call a Java method on a parameter passed into an XSLT but
am having problems.

I've stripped the XSLT down to its bare bones:

<xsl:stylesheet
version="1.0"
xmlns:java="http://xml.apache.org/xslt/java"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="requestContext"/>
<xsl:variable name="site" select="java:$requestContext.getCurrentSite()"/>
</xsl:stylesheet>

But xsl:variable line produces the error:

"A node test that matches either NCName:* or QName was expected."

Can anyone spot where I'm going wrong?

Thanks for any suggestions.
Robbie
Jul 20 '05 #1
6 3144
Robbie Baldock <me@privacy.net> writes:
Hi -

I'm a bit of a newbie to the world of XSLTs but am trying to call a Java method on a parameter passed into an XSLT but
am having problems.

I've stripped the XSLT down to its bare bones:

<xsl:stylesheet
version="1.0"
xmlns:java="http://xml.apache.org/xslt/java"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="requestContext"/>
<xsl:variable name="site" select="java:$requestContext.getCurrentSite()"/>
</xsl:stylesheet>

But xsl:variable line produces the error:

"A node test that matches either NCName:* or QName was expected."

Can anyone spot where I'm going wrong?

Thanks for any suggestions.
Robbie


function names in xslt (as in C or java o most other languages) are
single tokens you can't use an expression to generate the name and you
can't replace part of teh name by a variable reference.

so you can use java:foo(....) if you have a method foo available but you
can't generate a funtion name from a parameter (unless you use an
evaluet() extension function taht parses a string as an Xpath
expression.

David

Jul 20 '05 #2
/Robbie Baldock/:
<xsl:variable name="site" select="java:$requestContext.getCurrentSite()"/>


Did you mean:

<xsl:variable
name="site">java:$requestContext.getCurrentSite()</xsl:variable>

or (the same):

<xsl:variable name="site"
select="'java:$requestContext.getCurrentSite()'"/>

?

--
Stanimir
Jul 20 '05 #3
/Stanimir Stamenkov/:
/Robbie Baldock/:
<xsl:param name="requestContext"/>
missed that one...
<xsl:variable name="site" select="java:$requestContext.getCurrentSite()"/>


Did you mean:

<xsl:variable name="site">java:$requestContext.getCurrentSite()</xsl:variable>


or:

<xsl:variable name="site">java:<xsl:value-of
select="$requestContext"/>.getCurrentSite()</xsl:variable>

I think it should be the same:

<xsl:variable name="site" select="concat('java:', $requestContext,
'.getCurrentSite()'"/>

But reading through the David Carlisle's reply I realize you may be
trying something different.

--
Stanimir
Jul 20 '05 #4
On Thu, 24 Feb 2005 22:09:54 GMT, David Carlisle <da****@nag.co.uk>
wrote:
so you can use java:foo(....) if you have a method foo available but you
can't generate a funtion name from a parameter (unless you use an
evaluet() extension function taht parses a string as an Xpath
expression.


OK, I think I understand...!

Thanks for the info.
Robbie
Jul 20 '05 #5
On Fri, 25 Feb 2005 00:37:13 +0200, Stanimir Stamenkov
<s7****@netscape.net> wrote:
But reading through the David Carlisle's reply I realize you may be
trying something different.


I shall try your various suggestions.

Thanks for the response.
Robbie
Jul 20 '05 #6
hi,
I've stripped the XSLT down to its bare bones:

<xsl:stylesheet
version="1.0"
xmlns:java="http://xml.apache.org/xslt/java"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="requestContext"/>
<xsl:variable name="site" select="java:$requestContext.getCurrentSite()"/>
</xsl:stylesheet>


you have to use select="java:getCurrentSite($requestContext)"

regards
frank

Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: hongping | last post by:
I am having problems transforming a xml doc into html with proper indenting. Here is the xslt <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
0
by: Dominique Bejean | last post by:
Hello, I am having a problem doing an XSLT transformation using Java. I have a XML document as a DOM Document object, wrap the Document object with a DOMSource object, and do the...
1
by: Matt | last post by:
I run the xalan-java v2.60 command line: java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl -out test.html But it has the following error: (Location of error unknown)XSLT Error...
4
by: Venkata Ramana Kala | last post by:
Can any one please let me know where to start from and code xml in java and vb? please suggest me some good sites and books to start with(from scratch to advanced). I would like to get the exact...
0
by: Bloody Viking | last post by:
I'm using a variation on Donald Leslie's JAXPTransletMultipleTransformations.java...
0
by: Xiaolei Li | last post by:
first off, i'm a total newbie at this stuff so excuse any wrong usage of terminology or whatever else. i have a XSL to transform a Document such that all "text" nodes will have a "SPAN" inserted...
3
by: Petterson Mikael | last post by:
Hi, I was running the following in Netbeans 5.5: sing com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl - default JRE XSLT processor. Creating output/NcmiSigTest.java Unsupported...
8
by: Simon Brooke | last post by:
I have a DTD. If I declare it at the top of my XML file, as so: <!DOCTYPE application PUBLIC "-//CYGNETS//DTD ADL 0.1//EN" "http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtd"> then...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.