This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Multiple recursive transforms using document function?
- To: <XSL-List at lists dot mulberrytech dot com>
- Subject: Re: [xsl] Multiple recursive transforms using document function?
- From: "Thomas B. Passin" <tpassin at mitretek dot org>
- Date: Mon, 30 Apr 2001 17:37:36 -0400
- References: <20010430184440.37453.qmail@web14201.mail.yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
You are having a problem because you are asking the processor to find tags
in the dictionary document while it has loaded the template document. Of
course, it can't find them. I'm unclear what you are trying to accomplish
here. Do you want to get the second row from the dictionary where the
template says 'row 2'? If that's it, you could do it something like this
(not tested, but it should be close enough for you to work with). The idea
is to match against the position of the row, so that the 2nd row in the
template would give you the second child element in the dictionary ( you may
need to add one to the position).
<!-- new template file-->
<rows>
<row>1</row>
<row>2</row>
</rows>
<!-- Fragments of style sheet -->
<xsl:variable name='rows' select='document(template.xml)'/>
<xsl:variable name='dict' select='document(dictionary.xml)'/>
<xsl:template match='/'>
<xsl:for-each select='$rows/row'>
<xsl:value-of select='$dict/*[position()=.]'/>
</xsl:for-each>
</xsl:template>
Cheers,
Tom P
[Rowell Sotto]
> I'm having some semantic problems with how the
> document function works in conjunction with the
> xsl:apply-templates tag. I have two files:
> template.xml and dictionary.xml that I load using an
> xsl stylesheet(load.xsl) transformed against files.xml
> using the document function like so:
>
> <!-- command line -->
> java com.icl.saxon.StyleSheet files.xml load.xsl
>
> <!-- files.xml -->
> <files>
> <file>template.xml</file>
> <file>dictionary.xml</file>
> </files>
>
> <!-- load.xsl -->
> ...
> <xsl:template match="file">
> <xsl:apply-templates select="document(.)"/>
> </xsl:template>
>
> <xsl:template match="row1">
> <div><xsl:value-of select="row1"/></div>
> <span><xsl:value-of select="//name"/></span>
> </xsl:template>
>
> <xsl:template match="row2">
> <div><xsl:value-of select="row2"/></div>
> <span><xsl:value-of select="//vendor"/></span>
> </xsl:template>
> ...
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list