[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: variable and match
Subject: RE: variable and match From: Kevin Williams <Kevin.Williams@xxxxxxxxxxxxxx> Date: Fri, 12 May 2000 11:20:45 -0400 |
One way I've done this is to use a two-step process; first, create your "dynamic" stylesheet by transforming your original XML into XSLT; then, apply the newly-created stylesheet to the original XML to produce your output. For your example, if you take the following "meta" stylesheet: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/ROWSET"> <xsl:element name="xsl:stylesheet"> <xsl:attribute name="version">1.0</xsl:attribute> <xsl:element name="xsl:template"> <xsl:attribute name="match">/ROWSET/<xsl:value-of select="REPLACE/@EL"/> </xsl:attribute> <xsl:element name="xsl:element"> <xsl:attribute name="name">ROWSET</xsl:attribute> <xsl:element name="xsl:element"> <xsl:attribute name="name">NEWELEMENT</xsl:attribute> <xsl:element name="xsl:copy-of"> <xsl:attribute name="select">*</xsl:attribute> </xsl:element> </xsl:element> </xsl:element> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> And use it to transform <ROWSET> <REPLACE EL="FOO"/> <FOO> <DATA1>data1</DATA1> <DATA1>data1</DATA1> </FOO> </ROWSET> The output is: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/ROWSET/FOO"> <xsl:element name="ROWSET"> <xsl:element name="NEWELEMENT"> <xsl:copy-of select="*"/> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> Using this output to style the original XML yields: <ROWSET> <NEWELEMENT> <DATA1>data1</DATA1> <DATA1>data1</DATA1> </NEWELEMENT> </ROWSET> A little cumbersome, perhaps, but it works for the example you give... - Kevin Kevin Williams XML Architect, Ultraprise Corporation > -----Original Message----- > From: Ross Cormier [mailto:merex@xxxxxxxx] > Sent: Friday, May 12, 2000 8:35 AM > To: xsl-list@xxxxxxxxxxxxxxxx > Subject: RE: variable and match > > > OK, then how can I dynamically create a template in XSLT? > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: variable and match, Kay Michael | Thread | HELP: How to get the value of the n, Cheun N Chong |
Re: XML slice design, Dan Morrison | Date | xsl:number question, Perry Molendijk |
Month |