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

Re: How to get a list of XPath out of XMl schema docu

Subject: Re: 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
obbisoft
Michael Lindenau (geschdftlich) wrote:
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.


This isn't to difficult based on your given situation. You could use XSL like:

<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

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.