473,513 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath expression and xsl:when


What xpath expression would return the category-item having uid sps002
?
<category-list>
<category>
<uid>GRIDS_MAIN_CATEGORY_UID</uid>
<uid-type>Categories</uid-type>
<category-item-list>
<category-item>
<uid>sps0002</uid>
<uid-type>Grids</uid-type>
</category-item>
<category-item>
<uid>sps0005style0003</uid>
<uid-type>Grids</uid-type>
</category-item>
</category>
<category>
<uid>GRIDS_MAIN_CATEGORY_UID</uid>
<uid-type>Categories</uid-type>
<category-item-list>
<category-item>
<uid>sps0002</uid>
<uid-type>Grids</uid-type>
</category-item>
<category-item>
<uid>sps0005style0003</uid>
<uid-type>Grids</uid-type>
</category-item>
</category>
</category-list>

I've tried the following Xpath expression ... :

<xsl:when
test="'sps0002'=//category-list/category/category-item-list/category-item/uid">
<xsl:value-of select="./uid"/>

Which doesn't work. (Help!)

But actually, what I'd really like is an Xpath expression
that would fetch this node directly without using a xsl:when.

What I'm actually doing is checking if a node with an id of sps002
exists in a JDOM Element using it's the JDOM XPath object. This returns
either an Element or an Attribute. But right now I'm having to
fetch all the category-item Elements and iterate through them to
determine
if one with an sps002 id exists.

Thanks.

Jul 20 '05 #1
2 1626
What xpath expression would return the category-item having uid sps002


/category-list/category/category-item-list/category-item[uid='sps2002']

<xsl:when
test="'sps0002'=//category-list/category/category-item-list/category-item/uid">
That tests if there us any uid anywhere in the document that has this
value, so it will be always true or always false depending on whether
such a node exists.

<xsl:value-of select="./uid"/>

so this will select the uid child of the current node whether or not
this is the node taht has the specified uid.

David
Jul 20 '05 #2
Man .. The people on this list are *so* helpful. Thanks.

Jul 20 '05 #3

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

Similar topics

3
7186
by: Rupa | last post by:
Hi, I'm trying to write an xslt to convert an email in xml format to a new xml format. <descr> <xsl:choose> <xsl:value-of select="body"> </xsl:value-of select> <xsl:when test=" <xsl:value-of...
1
5446
by: kurt hansen | last post by:
hi I thought that this would be easy, but maybe not so much. I want to: pass an xpath expression and a string value to a stylesheet and copy the source xml document, changing the value of...
4
2016
by: renderman | last post by:
Hi, I looked through a computergenerated code because I had to edit something manually. I found this line: <xsl:when test="''='FALSE'"> I don't get what this means.
2
6141
by: David Williams | last post by:
I have a simple XML file that I have been using: <component name="test"> <class name="class"/> <component> Up till now, the Xpath of "//component/class" worked well to select the <class>...
4
1914
by: David Thielen | last post by:
I have the following xml: <root> <name>abc "123" xyz</name> </root> When I get an XPathNavigator to root and then call navigator.Evaluate("name = \"abc \\\"123\\\" xyz"), I get an...
2
1708
by: Doug | last post by:
I've been researching the answer to this without luck. I need to use <xsl:when and use an OR condition. Either it can't be done or I just haven't figured out the syntax. <xsl:when test="xyz =...
2
2570
by: Kniffel | last post by:
Hi Is there a possibility to make an <xsl:whenon more than one Selection? Not that way: <xsl:choose> <xsl:when a=test> Do this <xsl:when a=test2>
0
1325
by: Amit00 | last post by:
Hi, I'm performing an xsl transformation in a page I built, and would like to use some custom controls in it (or asp controls, for that matter). I looked this issue up, and understood that it...
2
2859
by: JamesDelaney | last post by:
Hi all, I'm creating a number of fragments to calculate various presence numbers. I'm creating variables from the results of these fragments then doing simple math to give the results. I'm...
0
7160
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
7384
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
7537
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...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3233
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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...

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.