XSLT & HTML

J

JustinCarmony

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"
xmlns:xsl="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.
 
?

=?ISO-8859-1?Q?Une_B=E9vue?=

JustinCarmony said:
<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>
 
P

Peter Flynn

JustinCarmony said:
<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top