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

Re: Output a link in a transformation to html

Subject: Re: Output a link in a transformation to html
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 31 May 2001 14:49:08 -0600 (MDT)
xsl element link
Luare wrote:
> I am doing a transformation from xml to html.
> This example is not well-formed, why?

Because XSL is XML.
XML has a concept of well-formedness.

>     <H3>Web: <A HREF= <xsl:value-of select="."/>> <xsl:value-of select="."/>
> </A></H3>
> 
> The expresion <xsl:value-of select="."/> return a string, doesn't it?

XSL is not a scripting language where the source code is interpreted as raw 
instructions, and xsl:value-of is not a macro or function that returns 
anything.

A stylesheet represents a tree of nodes that follow the XPath/XSLT data 
model. It is this tree (the stylesheet tree) that is interpreted by an XSL 
processor, along with another tree derived from an XML document (the source 
tree). Elements in the stylesheet tree that are in the recognized XSLT 
namespace are interpreted as instructions to the processor that tell it how 
to go about constructing a third tree, the result tree. After this tree is 
constructed, a linear representation of that tree may (and usually is) 
output, following the syntax rules of XML or HTML or whatever was requested 
and supported.

xsl:value-of is an instruction that tells that XSL processor to put a text 
node in the result tree.

<H3>...</H3> and <A>...</A> are literal result elements that are treated as 
shorthand for these instructions to add elements to the result tree:

<xsl:element name="H3">...</xsl:element>
<xsl:element name="A">...</xsl:element>

This is what you want:

  <H3>Web: <A HREF="{.}"><xsl:value-of select="."/></A></H3>

You can also do something like this, which is useful if you need to do
something more complex than a single value-of in order to calculate the
attribute values:

<H3>
  <xsl:text>Web: </xsl:text>
  <A>
    <xsl:attribute name="HREF">
      <xsl:value-of select="."/>
    </xsl:attribute>
    <xsl:value-of select="."/>
  </A>
</H3>

> It seem a tipical error, but I am a beginner.

It's a FAQ, yes. You just need to get a better sense of XSL's processing 
model. See the FAQ at http://www.dpawson.co.uk/ and also get Michael Kay's
XSLT book.

   - Mike
_____________________________________________________________________________
mike j. brown, software engineer at  |  xml/xslt: http://skew.org/xml/
webb.net in denver, colorado, USA    |  personal: http://hyperreal.org/~mike/

 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.