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

Re: combining 2 different XML files within the same XS

Subject: Re: combining 2 different XML files within the same XSLT
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 29 Aug 2002 12:04:09 +0100
2 xsl files
Hi Todd,

> when using the document(//file) to fill the $mergedset variable, I
> am not allowed to have file paths in front of the files
>
> <files>
>  <file>games.xml</file>
>  <file>events.xml</file>
> </files>
>
> so the XML files have to be in the same directory as the XSL file,
> not a huge deal, but I usually keep all the XML files in a separate
> directory (cgi-bin/xml) from the XSL files..
>
> so what I would like is
> <files>
>  <file>cgi-bin/xml/ncaa_games.xml</file>
>  <file>cgi-bin/xml/holidays.xml</file>
> </files>
>
> but IF I do that, this doesn't work
> <xsl:variable name="mergedset" select="document(//file)"/>

The secret is the second argument of document(). When you use the
document() function with a single argument, then it takes the URIs you
specify and resolves them (as you've found) relative to the
*stylesheet*.

If you specify a node as the second argument, then it finds the base
URI of the node (which is the URI of the file in which the node lives,
usually), and uses that as the base URI for resolving the relative
filenames.

So, move your files.xml into the XML directory along with the other
XML files, and use relative paths from the files.xml file to these
other files:

<files>
 <file>games.xml</file>
 <file>events.xml</file>
</files>

Then use the second argument in the document() function so that the
filenames are resolved relative to the location of files.xml rather
than to the stylesheet:

<xsl:variable name="mergedset" select="document(//file, /)"/>

and all should be well (I think!).

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.