RE: [xsl] Transforming cascading included schemas

Subject: RE: [xsl] Transforming cascading included schemas
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx
Date: Tue, 1 Oct 2002 12:16:31 +0100
Hello Jean

> -----Original Message-----
> From: Jean Lemons [mailto:jkslagle@xxxxxxxxxxxxx]
> Sent: 01 October 2002 05:03
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Transforming cascading included schemas
> 
> 
>   I need to produce documentation in HTML for web services defined in 
> WSDL. The schema for these are in separate XSD files 
> associated with the 
> WSDL file using xsd:include or xsd import. I need to access the 
> information in the schema to document the format information 
> for the web 
> service messages.
> 
> My problem is that the includes/imports for the needed schema are not 
> all in the primary source document. There are includes/imports in the 
> schema documents as well. Example:

[...]

> <!-- Key: types -->
> <xsl:key name="msgType" match="//xsd:schema//*" use="@name"/>
> ...
> <!-- Handle Include -->
> <xsl:template match="//xsd:include">
> <xsl:apply-templates select="document(@schemaLocation)"/>
> <xsl:apply-templates/>
> </xsl:template>
> ...
> 
> My confusion is in how to grab the document names so I can access the 
> key information. (I'm also not 100% sure I am getting the 
> keys). 

[...]

	Is it completely necessary for you to know the document names to use
the key? As things stand the nested schemas will all be transformed as if
they had been flattened out into one continuous document, except as regards
the key, which will only work within the scope of the context document. It
depends what you're using the key for.

	You can get all the names of the includes, though:

 <!-- top-level variable -->
 <xsl:variable name="includes">
    <xsl:apply-templates mode="getNames"/>
  </xsl:variable>

  <xsl:template match="/">
    <xsl:value-of select="$includes"/>
  </xsl:template>

  <xsl:template match="xsd:include" mode="getNames">
    <xsl:value-of select="@s"/><xsl:text>||</xsl:text>
    <xsl:apply-templates select="document(@s)//xsd:include"
mode="getNames"/>
 </xsl:template>


Effectively you're doing a preliminary pass over the whole lot, which could
be inefficient.

hth,
Tom


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread