473,386 Members | 1,819 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,386 software developers and data experts.

How to resolve a XPath in XSLT

I have a data file like this.....

<top>
<graph>
<part>
<param name="mass">1 </param>
</part>
<body name="nut">
<link href="#/top/graph['1']/part['1']"/>
</body>
</graph>
</top>

Notice the "link" is a path to another node in the file. I want to use
XSLT to process this file to print a table with the name of each body
and it's mass. But I cannot figure out how to do it. This is what I
tried......

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="top//body">

<p/> <xsl:value-of select="@name"/> has mass
<xsl:variable name="var" select="substring(link/@href,2)"/>
<xsl:value-of select="$var/param"/>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
But this doesn't work because it says $var/param is a syntax error. Any
ideas? Am I trying to do the impossible? I do not have any control of
the input data representation.

TIA, john
Feb 2 '06 #1
4 1571


John Henckel wrote:

Notice the "link" is a path to another node in the file. I want to use
XSLT to process this file to print a table with the name of each body
and it's mass.


There is no dynamic XPath evaluation in XSLT unless your processor
provides an extension function e.g. like Saxon here
<http://saxon.sourceforge.net/saxon6.5.5/extensions.html#evaluate>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 2 '06 #2
Martin Honnen wrote:


John Henckel wrote:

Notice the "link" is a path to another node in the file. I want to
use XSLT to process this file to print a table with the name of each
body and it's mass.

There is no dynamic XPath evaluation in XSLT unless your processor
provides an extension function e.g. like Saxon here
<http://saxon.sourceforge.net/saxon6.5.5/extensions.html#evaluate>

I suppose this one could be resolved by generating an XSL stylesheet
using XSL (or whatever...), stuffing in the XPath there, and then
executing that on the original document.

There is a prefix anti-aliasing feature, of which I can never remember
the name, to enable you to write stylesheet-spewing stylesheets
(distinguish output from instructions)

Soren
Feb 2 '06 #3


Soren Kuula wrote:

I suppose this one could be resolved by generating an XSL stylesheet
using XSL (or whatever...), stuffing in the XPath there, and then
executing that on the original document.


Yes, that is also possible, most things done by an extension function
you can be solved without it by doing two or more transformation steps.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 3 '06 #4
> There is no dynamic XPath evaluation in XSLT unless your processor
provides an extension function


The "semi-standard" dynamic XPath extension is the one in the EXSLT
library. Some processors ship with part or all of EXSLT, some don't.
Check the docs.

Another solution is to use a stylesheet to generate a stylesheet with
your desired XPath, then apply that stylesheet as a separate pass.
--
Joe Kesselman / Beware of Blueshift!
(And don't confuse an institution's stated values with its policies.)
Feb 3 '06 #5

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

Similar topics

6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
1
by: DV | last post by:
Hello, can anyone tell me or point me to somewhere what the exact differences (in terms of when would I use what) between XPath, XLink, XPointer and DOM are? Does it require special software...
14
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following...
1
by: Murtaza Tinwala | last post by:
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 >...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.