xsl-list
[Top] [All Lists]

RE: xsl:value-of select : how to make some tags printed and othersnot

2003-10-07 05:06:16

Hi,
Could anyone help me with the following?

Suppose I have the following XML:

<book>
   <title>My first book</title>
   <chapter>
     <nr>1</nr>
     <text> This is the <sw>content</sw> of my first book, where
<sub>I</sub> would like to leave in the sub-tag, but leave out the
sw-tag.</text>
   </chapter>
</book>

Is it possible to make an xsl statement that would print the content
of
the <text> tag and all sub tags (<xsl:value of select="text"/>) but
then
somehow leave the html formatting tags <sub> in the output? 

You want to use the basic identity transform, with a template matching
the elements you don't want to copy through.

So,

<!--the basic identity transform-->
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<!--template that copies contents only-->
<xsl:template match="sw|others">
  <xsl:apply-templates select="@*|node()"/>
</xsl:template/>

cheers
andrew

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • RE: xsl:value-of select : how to make some tags printed and othersnot, Andrew Welch <=