Subject: Re: document() question From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 15 Sep 1999 21:10:06 -0700 |
I have a string in a variable and I want to convert it to a document via the document() function.
Given the following example, it's obvious that I would get an error because document() is treating the variable's contents as a filename.
I presume that I am trying to do the impossible but I thought I would ask anyway.
T:\ftemp>type doc2.xml <BookList> <Book id="1"/> <Book id="2"/> </BookList>
T:\ftemp>type list3.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0" xmlns:data="any-uri">
<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:variable name="id" select="string(@id)"/> <!--note you cannot use document("")//Book[@id=$id]/*--> <xsl:for-each select='document("")'><!--the stylesheet--> <xsl:copy-of select="//data:BookSet[@set=$source] /Book[@id=$id] /*"/> </xsl:for-each> </Book> </xsl:for-each> </BookList> </xsl:template>
-- 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
document() question, Terris | Thread | Re: document() question, G. Ken Holman |
Re: expressing DTDs with UML, Dave Carlson | Date | Differences in specifying variable , Miloslav Nic |
Month |