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

Multiple recursive transforms using document function?

Subject: Multiple recursive transforms using document function?
From: Rowell Sotto <rowell_sotto@xxxxxxxxx>
Date: Mon, 30 Apr 2001 11:44:40 -0700 (PDT)
xml row1
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


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.