|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] document() question
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.
Thanks in Advance, Terris
G:\xsl>xt doc2.xml doc2.xsl
java.io.FileNotFoundException: \G:\xsl\askldf
The wizard of OZJava Servlet ProgrammingJohn Coltrane Rage
G:\xsl>type doc2.xml
<BookList>
<Book id="1"/>
<Book id="2"/>
</BookList>
G:\xsl>type doc2.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="source">askldf
<BookSet>
<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>
</BookSet>
</xsl:variable>
<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($source)/id($id)-->
<xsl:for-each select="document($source)">
<xsl:copy-of select="id($id)/*"/>
</xsl:for-each>
</Book>
</xsl:for-each>
</BookList>
</xsl:template>
</xsl:stylesheet>
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








