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

document() question

Subject: document() question
From: "Terris" <terris@xxxxxxxxxx>
Date: Wed, 15 Sep 1999 20:11:34 -0700
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


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.