simple question

Discussion in 'XML' started by Mike King, Oct 7, 2003.

  1. Mike King

    Mike King Guest

    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>
    Mike King, Oct 7, 2003
    #1
    1. Advertising

  2. Mike King

    Martin Boehm Guest

    "Mike King" <> wrote in message
    news:

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

    Or, with a variable:

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

    Martin
    Martin Boehm, Oct 7, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    550
  2. Kevin Spencer

    Re: Simple Simple question!!!

    Kevin Spencer, Jun 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    655
    Kevin Spencer
    Jun 25, 2004
  3. Daniel Frey

    Simple Question - Simple Answer?

    Daniel Frey, Dec 28, 2004, in forum: XML
    Replies:
    4
    Views:
    835
    Daniel Frey
    Jan 12, 2005
  4. Oli

    simple simple question

    Oli, Jan 26, 2004, in forum: ASP General
    Replies:
    10
    Views:
    367
    Roland Hall
    Jan 26, 2004
  5. Peter Bailey

    simple, simple array question

    Peter Bailey, Apr 8, 2008, in forum: Ruby
    Replies:
    7
    Views:
    210
    Peter Bailey
    Apr 8, 2008
Loading...

Share This Page