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

RE: multiple source files map to multiple target files

Subject: RE: multiple source files map to multiple target files
From: "Gosselin, Michael" <Michael.Gosselin@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 6 Apr 2006 13:19:38 -0400
files.map
Hi Evan et al,

I am having a problem with document() as well.

Assume I have a file "file.xml", which I will generate occasionally and want
to merge into my document.  The current XSLT (call it "current.xsl") doesn't
call this file right now; the main file is named, oh, "main.xml".

The file "file.xml" looks like this:

<file>
   <first>the first element</first>
   <second>the second element</second>
   <third>the third element</third>
</file>

How do I call the document() function to get the individual nodes out of the
file "file.xml" to be used by FOP in "current.xsl"?

I tried a merge, but it basically gave me all of both files, then formatted
according to the "current.xsl".  Do I need to create a second style sheet to
use with xsl:apply-templates?  The information I found on the document()
function wasn't extensive.

Thanks,

Michael Gosselin
Athena Diagnostics, Inc.
Worcester, MA  01605



> -----Original Message-----
> From: Evan Lenz [mailto:evan@xxxxxxxxxxxx] 
> Sent: Thursday, April 06, 2006 12:04 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  multiple source files map to multiple target files
>    
> However, assuming you have the XML source file that contains 
> the list of file names (URLs) that Michael mentioned, then a 
> single invocation of
> document() can return all the root nodes from your XML files. 
> (You don't have to do it individually for each one, e.g., 
> inside <xsl:for-each>.) And you don't need any extension 
> functions to do this.
> 
> Let's say you have a file named files.xml in the "config" 
> directory that contains this:
> 
> <files>
>     <file>input/foo.xml</file>
>     <file>input/bar.xml</file>
>     <file>input/bat.xml</file>
> </files>
> 
> Given the above document, the following expression will 
> return a node-set containing three root nodes, corresponding 
> to the three files listed.
> 
> document(document('config/files.xml')/files/file)
> 
> The file names are resolved relative to the location of 
> files.xml by default, i.e. from the "config" directory in 
> this case. The XSLT processor will look for an "input" 
> directory inside the "config" 
> directory. If you want to resolve them relative to your main 
> source document (rather than from the "config" directory), 
> then you could use the second (optional) argument to the 
> document() function, like so:
> 
> document(document('config/files.xml')/files/file, /)
> 
> The / in the second argument tells the function to resolve 
> the URLs relative to the base URI of the source document 
> instead of from the config directory (where files.xml lives). 
> The XSLT processor will look for an "input" directory inside 
> whatever directory your source document came from.
> 
> Finally, if you want to resolve them relative to the 
> stylesheet's base URI, you would use this:
> 
> document(document('config/files.xml')/files/file, document(''))
> 
> The document('') in the second argument returns the root node 
> of the stylesheet itself, so the relative URLs in files.xml 
> are resolved relative to the base URI of the stylesheet. The 
> XSLT processor will look for an "input" directory insider 
> whatever directory your stylesheet came from.
> 
> One more note: all the above examples assume that the 
> "config" directory is in the same directory as the 
> stylesheet. When you pass document() a string as the first 
> argument it assumes the base URI of the stylesheet. 
> When you pass it a node-set as the first argument (as we did 
> with the <file> elements), then the function uses the base 
> URI of each node in the node-set. In either case, you can 
> override the base URI behavior by using the second optional 
> argument (which must be a node-set). So, for example, if the 
> "config" directory is in the same location as your source 
> document, then you'd want to substitute this to grab the root 
> node of files.xml in each of the above examples:
> 
> document('config/files.xml', /)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.