[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: variable and match

Subject: RE: variable and match
From: Kevin Williams <Kevin.Williams@xxxxxxxxxxxxxx>
Date: Fri, 12 May 2000 11:20:45 -0400
xsl element name variable
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.