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

Re: Writing a stylesheet to create a stylesheet, with

Subject: Re: Writing a stylesheet to create a stylesheet, with XSLT inthe XML
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 17 Jun 2002 15:58:29 -0600 (MDT)
scott moore boulder colorado
Scott Moore wrote:
> <Sections label="&lt;xsl:value-of select=&quot;/Doc/FirstName&quot;/&gt;"/>
> 
> Okay, let me try again.  The above snippet is in my XML file.

Why?

I'm asking rhetorically; it's generally a bad idea to try to embed
markup as character data, and then expect it to be markup upon output.

>  I want to
> process the <Sections> node and basically do this in my stylesheet:
> 
> <xsl:value-of select="@label"/>
> 
> Unfortunately, that produces the following in the result tree:
> 
> &lt;xsl:value-of select=&quot;/Doc/FirstName&quot;/&gt;

Ah, but it doesn't. It produces in the result *tree* a single text node
containing the pseudo-markup
    < x s l : v a l u e - o f
and so on, with spaces added to emphasize that it's character data.

If you intend to produce <xsl:value-of...> in the *serialization*
of the result tree, then you must have not a text node but an element node 
with this structure:

  element named 'value-of' in namespace 'http://www.w3.org/1999/XSL/Transform'
       \___attribute 'select' with value '/Doc/FirstName'

So, why not have

  <Sections>
    <label>
      <xsl:value-of select="/Doc/FirstName"/>
    </label>
  </Sections>

and then <xsl:copy-of select="label/*"/> ?
(Don't forget to declare the xsl prefix in the source as well)

> <xsl:text disable-output-escaping="yes"><xsl:value-of
> select="@label"/></xsl:text>
> 
> BUT, the above is an error.  You apparently cannot place an <xsl:value-of/>
> inside of a <xsl:text/> element. 

xsl:text and xsl:value-of do exactly the same thing. They create a text node
in the result tree. The character data encapsulated by the text node is going
to be the content of xsl:text element, or the result of evaluating the XPath 
expression given in the select attribute of the xsl:value-of.

On either element, you can use disable-output-escaping="yes", but of course
it's not portable and not recommended, blah blah etc.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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-2011 All Rights Reserved.