473,320 Members | 2,147 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,320 software developers and data experts.

XSLT 1.0: Select children based on arbitrary node?

I want to select some nodes based on whether or not another node
exists in another part of the document with the exact same name.
For example,

<special-location>
<special-element value="some-element"/>
<special-element value="some-element-two"/>
</special-location>

<root>
<some-element .../>
<some-element-two .../>
<some-other-element .../>
</root>
What I want to do is select only the first and second elements under
<root>, and ignore the third element since there is no <special-
elementnode with @value=some-other-element.

Is this possible with a simple XPath, or do I need to use more
complicated logic and branching structures?

May 30 '07 #1
1 2540
* Zachary Turner wrote in comp.text.xml:
>I want to select some nodes based on whether or not another node
exists in another part of the document with the exact same name.

For example,

<special-location>
<special-element value="some-element"/>
<special-element value="some-element-two"/>
</special-location>

<root>
<some-element .../>
<some-element-two .../>
<some-other-element .../>
</root>
What I want to do is select only the first and second elements under
<root>, and ignore the third element since there is no <special-
elementnode with @value=some-other-element.
Well it would be something like

*[ //special-element/@value = local-name() ]

This selects a child element of the context node if there is a special-
element element whose value attribute has the same value as the local-
name of the current node.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
May 30 '07 #2

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

Similar topics

3
by: Philipp Lenssen | last post by:
I have this XML file which I would like to XSLT-sort based on the string contained within the item-children elements using basic MSXML (no recent version of IIS, so it might be an outdated MSXML --...
5
by: Ruthless | last post by:
hello. All XML and XSLT are processed by preprocessor as a trees. How can i simply display my XML as some kind of tree. given xml: <struct> <node level="1" no="1">
1
by: Martin Bright | last post by:
I am trying to write an XSLT template which creates a subtree of an input document, which is a simple tree. For example, the input might be <node name="1"/> <node name="2"> <node name="2.1"/>...
5
by: inquirydog | last post by:
Hi- Does anyone know a way to compare whether two nodes contain the same information in xslt (the name, attributes, and all content recursivly should be the same. I am interested in the case...
4
by: Ian Vaughan | last post by:
Any ideas why I am not getting any results back in my HTML via XSLT from my XML doc. It is not returning any errors just no matches when it should return a value of DATA for SchemeName ?? ...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
18
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
3
by: gregmcmullinjr | last post by:
Hi All, I would like to use XSLT to replace all <unodes that are children of a <bnode with a new <headingnode. Also, if the <bnode has no other children than remove it as well. For example: ...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.