Re: [xsl] grouping problem

Subject: Re: [xsl] grouping problem
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Nov 2007 17:54:54 -0500
At 2007-11-28 10:46 -0500, Terry Ofner wrote:
I do have a more general question/clarification that perhaps someone
can address.

Say I want to replace an element and its attributes with a new
element name and attribute(s). Say I also want to keep the mark-up of
the content. I have noticed that if I use <xsl:value-of select "."/>
the content mark-up is stripped out. So with this content:

<test>
  <selection name="u1pt01">
    <para> text, more text, <i>italic text.</i> </para>
  </selection>

</test>

The following template would strip out the <i> tags,

<xsl:template match="selection">
        <para aim:pstyle='bodytext'><xsl:value-of select "para"/><para>
</xsl:template>

producing

<test>
  <selection name="u1pt01">
    <para aim:pstyle='bodytext'> text, more text, italic text. </para>
  </selection>

</test>

Am I correct?

Yes. The value of an element node is the concatenation in document order of all descendent text nodes.


To avoid stripping content mark-up, I need to use <xsl:copy-of select
"para"/>. When I do that, however, I get two <para> tags.

You could use <xsl:copy-of select="para/node()"/> if you don't need to intervene on the descendent nodes, but perhaps using apply-templates and the identity template you would have a more general solution.


With copy-of, is it still possible to replace elements and
attributes?

No.


I suspect that I am missing something very basic. Some
clarification would be great.

copy-of copies the nodes without an opportunity for intervention ... for intervention, use apply-templates.


I hope this helps.

. . . . . . . . . . . . Ken

--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread