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

Re: Multi-source documents: difference between documen

Subject: Re: Multi-source documents: difference between document() and entities?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 14:46:01 -0500
difference between document and file
At 2004-01-27 11:50 -0700, Randolph Kahle wrote:
As I understand it, document() returns the root node of a tree and if I use the "/" path while processing a tree, I do *not* get the "root" above all document()-retrieved trees.

Correct ... there is no such "root above all retrieved trees" ... they are standalone (and relatively unordered).


What I get is the root of that specific XML file's tree.

Right.


My question is: How do I construct a path that will search all trees returned by the document() function?

document() returns the union of root nodes from all of the files opened by the string values of the *set* of nodes passed as an argument.


So, if I had:

  <files>
    <file url="a.xml"/>
    <file url="b.xml"/>
    <file url="c.xml"/>
  </files>

... and I did:

document( /files/file/@url )

... I would get the union set of three root nodes, so if I wanted to search all three XML documents for all <info> elements I would use:

document( /files/file/@url )//info

So, the trick is to put the "multiplicity" into the argument to the document function and deal with the multiplicity that is returned.

I hope this helps.

......................... Ken

p.s. don't worry about repeated calls to document() ... the processor typically caches the entire tree and just continues to return the already-retrieved root node. So, you could have:

  <xsl:variable name="allfiles" select="document( /files/file/@url )"/>
  ...
  <xsl:for-each select="$allfiles//info">
    ...


-- Public courses: sign up for one or both soon to reserve your seat! Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong, China: 2004-05-17 Bremen, Germany: 2004-05-24 World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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.