simple question

Mike King

Usenet Archive
Joined
May 25, 2000
Messages
69
Reaction score
0
I believe this is a simple question. I need a XSLT file that removes elements from a source file. I guess the tricky part is I need to use a variable to indicate which element to preserve. In the example below, I want to preserve the "/root/a[1]" element where "1" would be a variable. Can anyone help me? I'm having the hardest time figuring out template rules.

#### Input ####
<?xml version="1.0" ?>
<root>
<a id="1">
<b id="1"/>
</a>
<a id="2">
<b id="2"/>
</a>
<a id="3">
<b id="3"/>
</a>
</root>

#### Output ####
<?xml version="1.0" ?>
<root>
<a id="1">
<b id="1"/>
</a>
</root>
 

Martin Boehm

Usenet Archive
Joined
Sep 12, 2003
Messages
52
Reaction score
0
"/root/a[@id = '1']"

Or, with a variable:

<xsl:variable name="id" select="1" />
<xsl:apply-templates select="/root/a[@id = $id]"/>

Martin
 

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