|
Subject: Re: [xsl] Writing a stylesheet to create a stylesheet, with XSLT in the XML From: Mike Brown <mike@xxxxxxxx> Date: Mon, 17 Jun 2002 15:58:29 -0600 (MDT) |
Scott Moore wrote:
> <Sections label="<xsl:value-of select="/Doc/FirstName"/>"/>
>
> 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:
>
> <xsl:value-of select="/Doc/FirstName"/>
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Writing a stylesheet to c, Scott Moore | Thread | RE: [xsl] Writing a stylesheet to c, G. Ken Holman |
| Re: [xsl] Writing a stylesheet to c, David Carlisle | Date | Re: [xsl] NameSpace question?, David Carlisle |
| Month |