|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: <a class="..." href="..." problem
The XSLT community will tell you that this:
> Alternatively you can try encoding your output xml/xhtml tags.
> <a class="navigation" id="selected" href="<xsl:value-of select="url"
/>"
> >
> <xsl:value-of select="title" />
> </a>
is a bad idea. Heres' one of many explanations why:
http://www.dpawson.co.uk/xsl/sect2/N2215.html#d3401e172
You're not strictly using DOE, but the comment still applies.
I suggest using the attribute value template (AVT):
<a class="navigation" id="selected" href="{url}"><xsl:value-of
select="title" /></a>
It's the shortest, easiest-to-read solution, and it avoids the problem of
replacing markup with text (such as using < for <).
Jay Bryant
Bryant Communication Services
----- Original Message -----
From: "Dave Johnson" <djohnson@xxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Sunday, January 29, 2006 7:10 AM
Subject: RE: <a class="..." href="..." problem
> Hi Vincent,
>
> You can try one of two things.
>
> The traditional way of doing this is to use the <xsl:attribute/> element
> like this:
> <a class="navigation" id="selected">
> <xsl:attribute name="href"><xsl:value-of select="url"
> /></xsl:attribute>
> <xsl:value-of select="title" />
> </a>
>
> Alternatively you can try encoding your output xml/xhtml tags.
> <a class="navigation" id="selected" href="<xsl:value-of select="url"
/>"
> >
> <xsl:value-of select="title" />
> </a>
>
> The second method can is a good way to go if you are using the XSLT on the
> client in Mozilla based browsers as it tends to be much faster.
>
> MSDN has a very good XSLT 1.0 reference here:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html
> /a138c224-550c-458a-b510-4bd23ebe56c1.asp
>
> Cheers,
> Dave
>
> =====================================================================
> AJAX and XML/XSLT - http://blogs.ebusiness-apps.com/dave
> eBusiness Applications - http://www.ebusiness-apps.com
> =====================================================================
>
>
> -----Original Message-----
> From: Vincent Blondel [mailto:vincent@xxxxxxxxxxxx]
> Sent: January 29, 2006 11:00 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: <a class="..." href="..." problem
>
> Hi all,
>
> I just began with xsl two days ago, so sorry for this maybe stupid
> question.
>
> I am trying to write some xsl stylesheets but I encounter some problems
> with next xsl document.
>
> As you can see it in the "chapter" template section, I try to enumerate
> all menu entries through two XPath nodes. <title> corresponds to the
> label displayed on the web page and <url> corresponding to the link
> pointing to the web page.
>
> This is working fine except the href variable. It seems I cannot insert
> some <xsl:... /> tag into some double quotes being part of another tag.
>
> How can I solve this problem ?
>
> Regards
> Vincent
>
> --------------
> index.xsl
> --------------
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet
> version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="xml" encoding="iso-8859-1"
>
>
doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-str
> ict.dtd"
> doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN">
> </xsl:output>
>
> <xsl:template match="document">
> <html>
> <head>
> <title>
> <xsl:value-of select="title"/>
> </title>
> </head>
> <body>
> <div class="navigation">
> <xsl:apply-templates select="chapter"/>
> </div>
> </body>
> </html>
> </xsl:template>
>
> <xsl:template match="chapter">
> <a class="navigation" href="<xsl:value-of select="url"/>"
> id="selected">
> <xsl:value-of select="title"/>
> </a>
> </xsl:template>
>
> </xsl:stylesheet>
|
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
|

Cart








