[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Global, dynamically-named variables (or equiv) in XSL
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
|
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
|