xsl-list
[Top] [All Lists]

Re: [xsl] replacing nodes during xsl:copy-of

2011-01-06 08:16:05
From a high-level, non-technical, viewpoint, what I need to do is convert the 
XML to HTML  and either during the process, or after replace everything in 
the <replace> elements with something else.

Ok this is your starting point - its an "identity transform" which
copies the input to the output node by node.  The more specific
template which matches the "replace" element takes precedence over the
"identity template":

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    exclude-result-prefixes="xs">

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

<xsl:template match="replace">
  [ something else ]    
</xsl:template>

</xsl:stylesheet>

If you run that transform on this input:

<foo>hello <replace>world</replace></foo>

you get this output:

<foo>hello
  [ whatever ]  
</foo>






-- 
Andrew Welch
http://andrewjwelch.com

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