xsl-list
[Top] [All Lists]

Re: Ouput escaping / XPath

2005-11-15 11:45:45

<xsl:message>
  <xsl:copy-of (or xsl:copy or whatever you need) select="."/>
</xsl:message>

  <xsl:copy-of select="./child::node()"/>

  This obviously copies everything, even the comment. Apparently I would
  like to copy everything except the comment as to get the result:

you never need to start an XPath with ./ (unless it starts with .//) and
 child:: is also the default so that is

 <xsl:copy-of select="node()"/>


However you don't want to use copy-of at all as you do not want copies
of the child nodes, youneed to transform them. So you want

<xsl:apply-templates mode="copy"/>

where mode="copy" is the identity transform, but just on elements and
text:

<xsl:template match="*" mode="copy">
 <xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template>


The element() function seems to copy the comment
as well. What am I doing wrong here?

If you copy an element node then the copy has exatly the same children
as the original (or rather has copies of those children) so it has teh
smae text, comments and child elements.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>