This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Multiple recursive transforms using document function?
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] Multiple recursive transforms using document function?
- From: Rowell Sotto <rowell_sotto at yahoo dot com>
- Date: Mon, 30 Apr 2001 11:44:40 -0700 (PDT)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi all,
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>
...
<!-- template.xml -->
<rows>
<row1>This is row 1.</row1>
<row2>This is row 2.</row2>
</rows>
<!-- dictionary.xml -->
<dictionary>
<name>Joe Vendor</name>
<vendor>Vendor Inc.</vendor>
<address>1234 Anywhere Lane</address>
</dictionary>
Normally what occurs when I apply the transform is the
following:
<!-- output -->
<div>This is row 1.</div>
<span/>
<div>This is row 2.</div>
<span/>
The transform against template.xml is successful, but
the transform to grab the values out of the
dictionary.xml file never applies. I assume this is
because when the document function gets called in the
xsl:apply-templates element, it only applies the
templates as individual node-sets and not as a union
of the two(template.xml and dictionary.xml), which is
what I want to occur.
Ideally the transform against the template.xml file
would occur first, with the result of that transform
saved as a node-set which is then transformed against
the dictionary.xml file. I've done the above transform
a number of different ways (using xsl:variables,
xsl:call-templates with passed params, etc.), but I
still end up with the same result.
If I use a stepped approach by creating temporary XSL
files and chaining them as input to another transform,
then this solution isn't a problem. I'm trying to see
if I can perform a single transform and use XSL to do
all the work recursively instead of creating a
muti-stepped approach.
Is this even possible using standard XSLT? I'm trying
to do this without resorting to extension functions,
which I think can be done using the nodeset
function(?). Thanks for any input you may have.
BTW. The data in the examples I used are simplified to
illustrate the problem. The real files are a bit more
involved, but they use essentially the same idea.
Thanks again.
Rowell Sotto
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list