[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem setting part of xpath as parameter

Subject: Problem setting part of xpath as parameter
From: "Lillian Djurhuus" <lillian.djurhuus@xxxxxxx>
Date: Tue, 1 Jun 2004 08:48:08 +0200
xpath parameter
Hi all!

Im having a problem with a parameter set from java to a xsl document.
It used to work. But moving from version Xalan Java 1 to Xalan Java 2  it 
doesnt anymore.

I have the following Java testcode, that makes the transformation:

try {
         String fileName = 
"C:\\javadevelopSource\\Danskkaution8.1\\src\\web\\WEB-INF\\classes\\xsls\\topmenu.xsl";
         String xmlfile= 
"C:\\javadevelopSource\\Danskkaution8.1\\src\\web\\WEB-INF\\classes\\uniklink\\uniklink.xml";
         File file = new File(fileName);
         File file2 = new File(xmlfile);
         StreamSource source = new StreamSource(file);
         TransformerFactory f = TransformerFactory.newInstance();
         Transformer trans = f.newTransformer(source);
          StringWriter out=new StringWriter();
          StreamResult result=new StreamResult(out); 
          trans.setParameter("xpath", "Root[1]/Niv0[1]/Niv1[1]/");
          trans.transform(new StreamSource(file2),result);
          System.out.println(out);
        } catch (Exception e) {
            fail("Error on transforming xml with xsl "+e);
        }

in the xsl file I have the following:
.
.
.
<xsl:param  name="xpath" />
.
.
<xsl:for-each select="$xpath/child::node()[@Visible='true'].......more conditions...

The error I get is:
org.apache.xpath.XPathException: Can not convert #STRING to a NodeList!


Somehow it cant put the value of the xpath parameter in the select 
statement and interpret it as a nodelist.

I can output the value in the xsl by:

<xsl:value-of select="$xpath"/>

giving the String:
Root[1]/Niv0[1]/Niv1[1]/

In xalanJ version 1 I put the value set in java in qoutes (')
 trans.setParameter("xpath", " 'Root[1]/Niv0[1]/Niv1[1]/' ");

and it worked fine. 
This gives an error in version 2 and I read in the documentation, that ' 
no longer was necessary.

Anyway it still doesnt work!

Can anyone give me an explanation and solution?

Thanks in advance!


Lillian Djurhuus





Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.