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

Re: Problem using document() to access another XML fil

Subject: Re: Problem using document() to access another XML file
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 20 Feb 2004 10:26:06 GMT
fil document
document('/formats.xml'

is the formats.xml really at the root of your filesystem (or http server)?
if the file is in the same directory as your main source file, you don't
want that / in front of formats.

',/*)

no need for the * there just the single / node would be enough, you just
need any node in the document, used to get the base uri for the relative
yur in the first argument.

Once you have the right file path to your document you just need to make
sure that you get the Xpaths in the dvariable definition to match up.

For example

 <xsl:variable name="format"
select="document('/formats.xml',/*)/node()/formats/format[@id=./file/@type]"
/>

if you changed that to

 <xsl:variable name="format"
select="document('formats.xml',/)/node()/formats/format[@id=./file/@type]"
/>

then it would be the empty set, as
document('formats.xml',/)
is the root node (/) of the document, so

document('formats.xml',/)/node()/

is all the child nodes of that, which is probably just the formats
element.

Then 

document('formats.xml',/)/node()/formats/

is the formats children of the formats element, and there is no such child
so this is the empty node set.

So, you could fix that to be


select="document('formats.xml',/)/formats/format[@id=./file/@type]

now

document('formats.xml',/)/formats/format

would select al the format elements so



 document('formats.xml',/)/formats/format[@id=./file/@type]

selects all the format elements whose id attribute is equal to the string
value of the type attribute of a child element called file. No format
element has a child element called file, so the right hand side of the =
acts as the empty string, and no format element has an id attribure with
value "" so no format elements are selected by this filter.

You don't want the file element child of the format element, you want
the file element child of the element that was current at the outer
expression, so that is


"document('formats.xml',/)/formats/format[@id=current()/file/@type]"


David


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.