[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl]
RE: [xsl]
Subject: RE: [xsl] <a class="..." href="..." problem
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 30 Jan 2006 00:31:33 -0000
It's a common question: people seem to miss this one in the specs. You need
an attribute value template
<a class="navigation" href="{url}"/>
The reason you can't use xsl:value-of here is that a stylesheet has to be a
well-formed XML document, and XML doesn't allow elements within attributes.
You could also use xsl:attribute to create the attribute, but that's always
struck me as unnecessarily verbose.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Vincent Blondel [mailto:vincent@xxxxxxxxxxxx]
> Sent: 29 January 2006 11:00
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] <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-strict.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>
Current Thread
- RE: [xsl] <a class="..." href="..." problem, (continued)
- Dave Johnson - Sun, 29 Jan 2006 13:10:49 -0000
- Vincent Blondel - Sun, 29 Jan 2006 15:10:39 +0100
- Jay Bryant - Sun, 29 Jan 2006 13:04:33 -0600
- Michael Kay - Mon, 30 Jan 2006 00:36:04 -0000
- Michael Kay - Mon, 30 Jan 2006 00:31:33 -0000 <=
<- Previous Index Next ->
RE: [xsl] <a class="..." href="...", Michael Kay
Thread
[xsl] attribute-match, Alexander Stippler
RE: [xsl] Shallow copy and base URI, Michael Kay
Date
RE: [xsl] <a class="..." href="...", Michael Kay
Month
Subject: RE: [xsl] <a class="..." href="..." problem From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 30 Jan 2006 00:31:33 -0000 |
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] <a class="..." href="...", Michael Kay | Thread | [xsl] attribute-match, Alexander Stippler |
RE: [xsl] Shallow copy and base URI, Michael Kay | Date | RE: [xsl] <a class="..." href="...", Michael Kay |
Month |