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

M

Murtaza Tinwala

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.
 
M

Martin Honnen

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
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top