XSLT Transformation (relatively easy, I think) ?

Discussion in 'XML' started by gregfocker@earthlink.net, Feb 14, 2007.

  1. Guest

    I have a node like this:

    <content>
    <![CDATA[global text]]>
    <custom id="blah">
    <![CDATA[custom text]]>
    </custom>
    <![CDATA[more global text]]>
    <custom id="blah">
    <![CDATA[more customtext]]>
    </custom>
    <![CDATA[still more global text]]>
    </content>

    For the <content> node, I'm trying to write XSL that will always
    display the text OUTSIDE of the <custom> tags (global text), as well
    as conditionally display the text INSIDE the <custom> tags (based on a
    parameter matching the "id" attribute). Any ideas?

    If a minor change in structure would help, I'm certainly open to
    that. Thanks for any input.
     
    , Feb 14, 2007
    #1
    1. Advertising

  2. Guest

    On Feb 14, 5:43 am, ""
    <> wrote:
    > <content>
    > <![CDATA[global text]]>
    > <custom id="blah">
    > <![CDATA[custom text]]>
    > </custom>
    > <![CDATA[more global text]]>
    > <custom id="blah">
    > <![CDATA[more customtext]]>
    > </custom>
    > <![CDATA[still more global text]]>
    > </content>
    >
    > For the <content> node, I'm trying to write XSL that will
    > always display the text OUTSIDE of the <custom> tags
    > (global text), as well as conditionally display the text
    > INSIDE the <custom> tags (based on a parameter matching
    > the "id" attribute). Any ideas?


    What have you tried and what didn't seem to work?

    <xsl:template match="content">
    <xsl:param name="id"/>
    <xsl:apply-templates select="text()|custom[@id=$id]"/>
    </xsl:template>

    --
    Pavel Lepin
     
    , Feb 14, 2007
    #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. Annie
    Replies:
    3
    Views:
    7,526
    Annie
    Sep 11, 2005
  2. Woolly Mittens
    Replies:
    8
    Views:
    436
    Woolly Mittens
    Sep 22, 2003
  3. Fat, Dumb and Happy
    Replies:
    2
    Views:
    400
    Fat, Dumb and Happy
    Mar 1, 2005
  4. Replies:
    2
    Views:
    8,739
  5. TokiDoki
    Replies:
    10
    Views:
    724
    Micah Elliott
    Oct 20, 2005
Loading...

Share This Page