|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: document() question
Sorry folks, I got hot and heavy with my cutting and pasting and made an
assertion in the comment of one of my files that isn't true. I found this
while working on the revisions to my training material.
At 99/09/16 07:10 -0700, I wrote: <!--note you cannot use document("")//Book[@id=$id]/*--> Actually, you can use that, what you cannot use is: document("")/id($id)/* ... because the id() function can only be used alone or at the start of a location path, not *in* a location path. When I did the global cut and paste of id($id) to be /Book[@id=$id], I didn't notice the comment had also changed. I've attached an example below of what I said couldn't be done. The document() function can be at the start of any valid location path. Sorry if this was misleading earlier. ............ Ken
T:\ftemp>type test.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns:data="any-uri"><xsl:output method="xml" indent="yes"/> <data:BookSet set="first"> <Book id="1"><Name>The wizard of OZ</Name></Book> <Book id="2"><Name>Java Servlet Programming</Name></Book> <Book id="3"><Name>John Coltrane Rage</Name></Book> </data:BookSet> <data:BookSet set="second"> <Book id="1"><Name>An Uninteresting Book</Name></Book> <Book id="2"><Name>Another Uninteresting Book</Name></Book> <Book id="3"><Name>Yet Another Uninteresting Book</Name></Book> </data:BookSet> <!--source of data; default can be overridden on command line--> <xsl:param name="source" select="'first'"/> <xsl:template match="/BookList"> <!--document element-->
<BookList>
<xsl:for-each select="Book">
<Book id="{@id}">
<xsl:copy-of select='document("")
//data:BookSet[@set=$source]
/Book[@id=current()/@id]/*'/>
</Book>
</xsl:for-each>
</BookList>
</xsl:template></xsl:stylesheet> T:\ftemp>xt test.xml test.xsl test.out T:\ftemp>type test.out <BookList xmlns:data="any-uri"> <Book id="1"> <Name xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">The wizard of OZ</Name> </Book> <Book id="2"> <Name xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">Java Servlet Programming</Name> </Book> </BookList> T:\ftemp>xt test.xml test.xsl test.out source=second T:\ftemp>type test.out <BookList xmlns:data="any-uri"> <Book id="1"> <Name xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">An Uninteresting Book</Name> </Book> <Book id="2"> <Name xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">Another Uninteresting Book</Name> </Book> </BookList> T:\ftemp> -- 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 (Fax:-0995) Website: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2 Next instructor-led training: 1999-09-24, 1999-11-08, 1999-12-05/06, 1999-12-07, 2000-02-27/28, 2000-05-11/12 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








