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

Global, dynamically-named variables (or equiv) in XSL

Subject: Global, dynamically-named variables (or equiv) in XSL
From: Mark Miller <joup@xxxxxxxx>
Date: Thu, 19 Jun 2003 11:59:53 -0700 (PDT)
to store global variables dynamically
Hi,

I'm working with an XML Schema document (.xsd), and I'm having trouble
dealing with the idea of types and references to them.  My example xsd
(from w3schools) creates several named types, e.g.

<xs:simpleType name="stringtype">
 <xs:restriction base="xs:string"/>
</xs:simpleType>

which are then referenced elsewhere in the document like this:

...
  <xs:element name="orderperson" type="stringtype"/>
...

My plan of attack to handle this was to have a template like this, which
creates a global variable based on the the "name" attribute of the named
type:

  <xsl:template match="xs:simpleType|xs:complexType">
    <xsl:variable name="@name">
      <xsl:apply-templates/>
    </xsl:variable>
  </xsl:template>

This would process the children of the named type, and store the results
to a variable named (in the example) 'stringtype'.  A later template for
xs:element would look something like

<xsl:template match="xs:element">
  <xsl:value-of select="$@type"/>
</xsl:template>

The problem is that none of this works as I had hoped.  First off, it
seems like I can't declare a variable that is named dynamically (based on
the document being transformed); and second, I can't access that variable
because it goes out of scope when the xs:simpleType template finishes.

I keep thinking that I'm just missing something; is there an alternative
way to accomplish this?  Any attempts to set me on the right track would
be sorely appreciated.

TIA,
Mark

 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.