|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Global, dynamically-named variables (or equiv) in
Mark,
The trick here is the relation between the XSD simpleType element, and the element that refers to it (the xs:element element). This relation is established by the fact that the @type attribute value on xs:element is the same as the @name attribute value on the corresponding xsl:simpleType element. This kind of cross-reference relation is very conveniently managed with XSLT keys. So: <xsl:key name="types-by-name" match="xs:simpleType | xs:complexType" use="@name"/> establishes an XSLT key which you can use to retrieve any node in the document (here, any simpleType or complexType element) using an associated value (here, the value of its @name attribute). Then when you match the xs:element element, you have a way of getting to the corresponding type declaration: <xsl:template match="xs:element">
<xsl:apply-templates select="key('types-by-name', @type)"/>
</xsl:template>I hope this helps. This is pretty sketchy, since you didn't indicate what you want to do with your schema. But it gives you any easy way to do the traversal you need. (There is also a hard way using plain XPath, also less efficient.) XSLT works quite differently from what you appear to be expecting. It's a declarative, "functional" language -- for example, the order of the templates in the stylesheet doesn't actually matter (hence, as you discovered, you can't bind a value to a variable in one template and have it available in a "later" template). In order to get it to work for you, you have to think not in terms of designing a process to get from here to there, but of declaring what output you want for a given input. You might find a bit of reading on the XSLT processing model to be very helpful. Cheers, Wendell At 02:59 PM 6/19/2003, you wrote: Hi, ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== 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
|

Cart








