By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,190 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,190 IT Pros & Developers. It's quick & easy.

simple question

P: n/a
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>
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Mike King" <em*****@excite.com> wrote in message
news:vo************@corp.supernews.com

"/root/a[@id = '1']"

Or, with a variable:

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

Martin
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.