How to get to XML node from an Xpath expressed in string

Murtaza Tinwala

Usenet Archive
Joined
Aug 18, 2004
Messages
4
Reaction score
0
Hi mates,

I have the following problem in XSLT. I have following variables:
ref-file = <path of XML document> eg "xmlDoc.xml"
repeatpath = <a repeat path expressed in Xpath like /root/person > eg "/root/person" node = <name of a child node in repeat path> eg" "name"

Now, I want to get to the 'node' in XSLT using Xpath.

Suppose, the following is the XML document.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person>
<name>Murtaza</name>
</person>
<person>
<name>Rishit</name>
</person>
<person>
<name>Nilesh</name>
</person>
<person>
<name>Chirag</name>
</person>
</root>

I can get the XML document into a variable using document function. Now, my problem is I have Xpath expressions in string form. I cannot use them where we have to use XSLT patterns and Xpath expressions.
How to solve this problem?

Murtaza Tinwala.
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Murtaza Tinwala wrote:

I have the following problem in XSLT. I have following variables:
ref-file = <path of XML document> eg "xmlDoc.xml"
repeatpath = <a repeat path expressed in Xpath like /root/person > eg "/root/person" node = <name of a child node in repeat path> eg" "name"

Now, I want to get to the 'node' in XSLT using Xpath.

Suppose, the following is the XML document.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person>
<name>Murtaza</name>
</person>
<person>
<name>Rishit</name>
</person>
<person>
<name>Nilesh</name>
</person>
<person>
<name>Chirag</name>
</person>
</root>

I can get the XML document into a variable using document function. Now, my problem is I have Xpath expressions in string form. I cannot use them where we have to use XSLT patterns and Xpath expressions.
How to solve this problem?

Some XSLT processors implement an extension function allowing you to dynamically evaluate a string as an XPath expression so that way you could solve that. I think Saxon from http://saxon.sf.net/ has such a function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top