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

Re: document() question

Subject: Re: document() question
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Sep 1999 07:24:17 -0700
Re: document() question
At 99/09/15 21:10 -0700, I wrote:
At 99/09/15 20:11 -0700, Terris wrote:
I have a string in a variable and I want to convert it
to a document via the document() function.
...
Trying to feed a variable of rich markup to the document() function is impossible.

Sleeping on this I realized that a change to my previous post *would* allow one to access a declared variable with a result-tree assignment. Rather than adding a new vocabulary, I am now passing the stylesheet to the document() function and just looking for the variable declared with the given name.


I hope this helps further.

.......... Ken

p.s. I'm still not exactly sure why namespace declarations are appearing for a namespace that doesn't appear to be being used ... but the parseable result doesn't change and an XSLT engine is allowed to write out namespace declarations it thinks it needs as long as the end result doesn't parse incorrectly ... so I don't think XT is "wrong".


T:\ftemp>type doc2.xml <BookList> <Book id="1"/> <Book id="2"/> </BookList>

T:\ftemp>type list4.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="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>
</xsl:variable>

<xsl:variable name="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>
</xsl:variable>

 <!--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)"/>
        <xsl:for-each select='document("")'><!--the stylesheet-->
          <xsl:copy-of select="//xsl:variable[@name=$source]
                                /Book[@id=$id]
                                /*"/>
        </xsl:for-each>
      </Book>
    </xsl:for-each>
  </BookList>
</xsl:template>

</xsl:stylesheet>

T:\ftemp>xt doc2.xml list4.xsl result1.xml

T:\ftemp>type result1.xml
<BookList>
<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 doc2.xml list4.xsl result2.xml source=second

T:\ftemp>type result2.xml
<BookList>
<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


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.