Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT & HTML

Reply
Thread Tools

XSLT & HTML

 
 
JustinCarmony
Guest
Posts: n/a
 
      01-22-2007
My employer wants me to explore the possibilities of XSLT for a new
project I am working on. It seems to work great for some things, but
here is an issue:

My boss wants to make a XML based web service, and a XSLT template to
parse that XML into a fully functioning webpage. There is the issue, I
can modify content between HTML tags and such, but lets say the
following example:

-----------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div id="mainNav">
<ul>
<xsl:for-each select="/linkLists/linkList/link">
<li class="home"><a href="#"><span></span><xsl:value-of
select="defaultText" /></a></li>
</xsl:for-each>
</ul>
</div>
</xsl:template>
</xsl:stylesheet>
-----------------------------------------------------------------------------------------------------------------------

I can change the default Text. However, I cannot change values within
the <li> and <a> tags without getting an error. The following does not
work:

<li class="<xsl:value-of select="className" />"><a href="<xsl:value-of
select="linkURL />"><span></span><xsl:value-of select="defaultText"
/></a></li>

Is there a way to accomplish this and parse correctly? Thank you.

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-22-2007
JustinCarmony wrote:

> <li class="<xsl:value-of select="className" />"><a href="<xsl:value-of
> select="linkURL />"><span></span><xsl:value-of select="defaultText"
> /></a></li>


Use attribute value templates e.g.
<li class="{className}"><a href="{linkURL}">
see
<http://www.w3.org/TR/xslt#attribute-value-templates>


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
JustinCarmony
Guest
Posts: n/a
 
      01-22-2007
Thanks!

Martin Honnen wrote:
> JustinCarmony wrote:
>
> > <li class="<xsl:value-of select="className" />"><a href="<xsl:value-of
> > select="linkURL />"><span></span><xsl:value-of select="defaultText"
> > /></a></li>

>
> Use attribute value templates e.g.
> <li class="{className}"><a href="{linkURL}">
> see
> <http://www.w3.org/TR/xslt#attribute-value-templates>
>
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


 
Reply With Quote
 
=?ISO-8859-1?Q?Une_B=E9vue?=
Guest
Posts: n/a
 
      01-22-2007
JustinCarmony <(E-Mail Removed)> wrote:

> <li class="<xsl:value-of select="className" />">


<li>
<xsl:attribute name"class">
<xsl:value-of select="defaulText"/>
<xsl:attribute>
[...]
</li>


or a shorter version :
<xsl:variable name="trick" select="defaultText"/>
<li class="{$trick}">
[...]
</li>

--
Artaban de Médée
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      01-22-2007
JustinCarmony wrote:
> <li class="<xsl:value-of select="className" />"><a href="<xsl:value-of
> select="linkURL />"><span></span><xsl:value-of select="defaultText"
> /></a></li>


Others have posted suggested solutions; here's the explanation:
XSLT is XML, so it has to follow the rules and be well-formed. You can't
put element markup in an attribute value, and you can't nest quotes, so
<li class="<xsl:value-of select="className" />">
is a non-concept.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments