Subject: Re: [xsl] How to get a list of XPath out of XMl schema documents - clarification From: Robert Koberg <rob@xxxxxxxxxx> Date: Fri, 25 Feb 2005 04:52:52 -0800 |
First - thanks to everybody for the fast answers and for the hints so far (even that I didn't get Dimitres example to run - using Stylus Studio with MSXML/MSXML 4.0). This seems to me a great and helpful mailing list.
Second - The XPaths of the XML schema documents are used to create mappings between EDI field descriptions and the XML file in which they should be transferred. The XML schemas are the base for the mapping design. First intention is, to control if every given XPath in the mapping documents (usually Excel sheets) is correct written. Next intention is, to get an easy diff about the ongoing changes in the XML schema documents. So hierarchy doesn't matter. It's only important that the list contains every used unique XPath to an named element. Namespaces are not used. Indeed the XML schemata are very simple and don't use much of the possibilities that an XML schema offers. But at least they group elements to complex elements and use references. There is no elaborated software intended, which will use this information.
Below is a concrete example of such a schema
The desired XSLT would produce a list like
/OBBISOFT/MESSAGE/MESSAGE_NO /OBBISOFT/MESSAGE/MESSAGE_VERSION_NO /OBBISOFT/MESSAGE/MESSAGE_SENDER/MAIN /OBBISOFT/MESSAGE/MESSAGE_SENDER/CENTER /OBBISOFT/MESSAGE/MESSAGE_SENDER/TEAM ...
which lists only the elements.
A list like /OBBISOFT /OBBISOFT/MESSAGE /OBBISOFT/MESSAGE/MESSAGE_NO wouldn't be the desired output.
<xsl:key name="elems" match="xs:element" use="@name"/>
<xsl:template match="xs:element"> <xsl:choose> <xsl:when test="@ref"> <xsl:apply-templates select="key('elems', @ref)"/> </xsl:when> <xsl:when test="@name"> <xsl:text>/</xsl:text> <xsl:value-of select="@name"/> <xsl:apply-templates/> </xsl:when> </xsl:choose> </xsl:template>
best, -Rob
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to get a list of XPat, Michael Kay | Thread | [xsl] grouping nodes inside a new p, Andrew Male |
Re: [xsl] grouping nodes inside a n, David Carlisle | Date | [xsl] looping within a key's nodese, Heckel, Matt , Ctr, |
Month |