XSLT Transformation (relatively easy, I think) ?

G

gregfocker

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.
 
P

p.lepin

<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>
 

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
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top