473,666 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:styleshe et
version="1.0"
xmlns:java="htt p://xml.apache.org/xslt/java"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:param name="requestCo ntext"/>
<xsl:variable name="site" select="java:$r equestContext.g etCurrentSite() "/>
</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 3166
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:styleshe et
version="1.0"
xmlns:java="htt p://xml.apache.org/xslt/java"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:param name="requestCo ntext"/>
<xsl:variable name="site" select="java:$r equestContext.g etCurrentSite() "/>
</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:$r equestContext.g etCurrentSite() "/>


Did you mean:

<xsl:variable
name="site">jav a:$requestConte xt.getCurrentSi te()</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="requestCo ntext"/>
missed that one...
<xsl:variable name="site" select="java:$r equestContext.g etCurrentSite() "/>


Did you mean:

<xsl:variable name="site">jav a:$requestConte xt.getCurrentSi te()</xsl:variable>


or:

<xsl:variable name="site">jav a:<xsl:value-of
select="$reques tContext"/>.getCurrentSit e()</xsl:variable>

I think it should be the same:

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

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****@netscap e.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:styleshe et
version="1.0"
xmlns:java="htt p://xml.apache.org/xslt/java"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:param name="requestCo ntext"/>
<xsl:variable name="site" select="java:$r equestContext.g etCurrentSite() "/>
</xsl:stylesheet>


you have to use select="java:ge tCurrentSite($r equestContext)"

regards
frank

Jul 20 '05 #7

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

Similar topics

0
6803
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 the issue is. Thanks Ravi
1
3039
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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" xmlns="http://www.w3.org/1999/xhtml">
0
2911
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 transformation. However, the transformation does not work. None of the templates in the XSLT source are Matched, except for the root template. The code is as follows:
1
2269
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 (java.lang.ExceptionInInitializerError): null test.html is created, but it is a blank file. Any ideas?? //------------- test.xml --------------------- <source>
4
1734
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 essence of XML. It would be greatful if anyone can respond back positively with some useful stuff. Thank You.
0
1259
by: Bloody Viking | last post by:
I'm using a variation on Donald Leslie's JAXPTransletMultipleTransformations.java (http://www.cs.helsinki.fi/group/xmltools/formatters/xalan/xalan-j_2_1_0/samples/translets/JAXPTransletMultipleTransformations.java), and it seems to work just fine. But then I copied it, the xml and the xslt over to another machine (both SPARC boxes) and got a strange result: character entities are getting translated strangely. For instance, &ecirc; is...
0
3017
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 around it. the XSL is given below: <xsl:transform version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xhtml" omit-xml-declaration="yes"/> <xsl:strip-space elements="*"/>
3
5058
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 XSL element 'http://www.w3.org/1999/XSL/Transform:document' Transformation finished.
8
3707
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 editors such as emacs (PSGML), Oxygen and Microsoft Visual Studio parse the DTD and offer me context sensitive menus to insert the right elements and the right attributes in the right places. So the DTD really is there and really can be parsed....
0
8360
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8784
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8642
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.