Subject: [xsl] Global, dynamically-named variables (or equiv) in XSL From: Mark Miller <joup@xxxxxxxx> Date: Thu, 19 Jun 2003 11:59:53 -0700 (PDT) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Fw: omitting empty elemen, David Carlisle | Thread | Re: [xsl] Global, dynamically-named, Wendell Piez |
RE: [xsl] xsl:number problem, Yan, Charlene | Date | [xsl] GetParameter from XSL, Claudio Russo |
Month |