|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl, and different xml versions
Jake, the "poor man's solution" is to use modes, as follows: we'll transform
doc.xml (below) using doc.xsl; doc.xsl imports 2 xsl files doc-a.xsl and
doc-b.xsl with their respective templates marked as mode="a" and mode="b".
Please see below:
The input file (doc.xml): ===== <doc> <foo/> </doc> Imported file (doc-a.xsl): ===== <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:template match="foo" mode="a">
<foo v="a"/>
</xsl:template>
</xsl:stylesheet>Imported file (doc-b.xsl): ===== <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:template match="foo" mode="b">
<foo v="b"/>
</xsl:template>
</xsl:stylesheet>The main xsl (doc.xsl): ===== <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="doc-a.xsl"/> <xsl:import href="doc-b.xsl"/> <xsl:output method="xml"/> <xsl:template match="/">
<xsl:variable name="mode" select="'b'"/>
<xsl:choose>
<xsl:when test="$mode = 'a'">
<xsl:apply-templates mode="a"/>
</xsl:when>
<xsl:when test="$mode = 'b'">
<xsl:apply-templates mode="b"/>
</xsl:when>
</xsl:choose></xsl:template> </xsl:stylesheet> A more sophisticated and elegant--if less simple and transparent--approach would be to dynamically dispatch processing to different stylesheets based on a stylesheet-specific "property". Regards, --A From: Jake Briggs <jakbri@xxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: xsl, and different xml versions Date: Fri, 15 Apr 2005 14:27:34 +1200 _________________________________________________________________ Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








