xsl-list
[Top] [All Lists]

RE: transform only a section of xml

2002-11-11 10:24:32
I am sure this is a FAQ but I am not sure how to ask this 
question properly without illustrating it. I would like to 
transform only a portion of an xml document while mainting 
the rest of the structure.

Write the identity template rule as the default rule for all elements:

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

and then supplement it with rules for the elements you want to modify:

<xsl:template match="form">
  ...
</xsl:template>

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 



<!-- original -->
<xml>
    <section>
        <title>title</title>
        <para>
            <form id="1"/> <!-- item to transform -->
        </para>
    </section>
</xml>

<!-- transform to -->
<xml>
    <section>
        <title>title</title>
        <para>
            <form method="post">
                <input type="text" name="NAME" />
            </form>
        </para>
    </section>
</xml>


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




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



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