[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|