473,378 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

XSLT & HTML

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 <liand <atags 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.

Jan 22 '07 #1
4 1721
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/
Jan 22 '07 #2
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/
Jan 22 '07 #3
JustinCarmony <ca*****@gmail.comwrote:
<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
Jan 22 '07 #4
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/
Jan 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SDM | last post by:
I need to create a stylesheet to allow the querystring in my attribute links to format as: <TD<A href='IQNet.asp?f=2&t=3'>Choice 1</A></TD> not <TD<A href='IQNet.asp?f=2&amp;t=3'>Choice...
3
by: J Trost | last post by:
I was wondering if anyone knows if it is possible to do basic string replacement using XSLT even though the strings being replaced may contain "<" and ">". Here is my problem: I need to be able...
3
by: Jack Fox | last post by:
I've never had the need to work with XML, but I believe I now have an appropriate application. I have time-series data in objects organized as a tree that I want an ASP.NET program to write out to...
2
by: chris | last post by:
Hi there, I create an XML file from a dataset like this: System.IO.StreamWriter xmlSW = new System.IO.StreamWriter(FILENAME); dsUserData1.WriteXml(xmlSW, XmlWriteMode.WriteSchema);...
3
by: Fredy Muñoz [MCP] | last post by:
Hello there! I have a couple of questions about generating HTML using an XSLT Stylesheet. I use the System.Xml and System.Xml.Xsl namespaces and a XslTransform object to make the...
1
by: tconti | last post by:
Howdy: I have 2 general questions regarding the use of XSLT to generate emails. We have several procecesses that use XSLT to generate emails. We frequently run into issues where a client...
3
by: crc128 | last post by:
Hi, I'm looking at using XML and XSLT with apache cocoon to automatically generate html files for a site. the problem I'm having is that I want one of the pages to display a google map, but the...
4
by: gouranga | last post by:
Sablotron keeps giving an error (non-XSL instruction) on the line with this code: <xsl:result-document href="slideshow/index.html" format="html"> Is this implemented in Sablotron? It's quite...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.