[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

tagging an xslt up for web pages

Subject: tagging an xslt up for web pages
From: "james walker" <jameswalkerandy@xxxxxxxxxxx>
Date: Mon, 17 Nov 2003 09:52:38 +0000
xsl span
I am tyriong to design a piece of xslt which will enclose another xslt in <span> tags and <code> tags so i can present the code in different colours in a web page. Doind this by hand takes a long long time. I have an example xslt like this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:key name="items-by-category" match="item" use="category" />

<xsl:template match="rss/channel">
<xsl:for-each select="item[count(. | key('items-by-category', category)[1]) = 1]">
<h2 class="head-small-orangedark" style="margin-bottom:3px"><xsl:value-of select="category"/></h2>
<xsl:for-each select="key('items-by-category', category)">
<xsl:variable name ="url" select="link" />
<xsl:variable name ="length" select="string-length(description)" />
<h3 style="font-size:100%; margin-bottom:3px"><a href="{$url}"><xsl:value-of select="title" /></a></h3>
<xsl:choose>
<xsl:when test="$length > '512'">
<p style="font-size:85%; margin-left:1.5em"><xsl:value-of select="substring(description,1,512)"/>...</p>
</xsl:when>
<xsl:otherwise>
<p style="font-size:85%; margin-left:1.5em"><xsl:value-of select="description"/></p>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>

each line is enclosed with <code> tags, if there is a space the code tag before needs margin-bottom style=0.5 (in order to show that space on the web page). Things like xsl:when are enclsoed in <span> tags with a colour blue......


elkemant names = <span class="blue">xsl:when</span>
anything in double quotes = <span class="green">"substring(description,1,512)"</span>
parameters are red.
< and > signs would need to be changed to &lt; &gt; as well.


The ouput would look something like this:

<code class="sp" style="margin-bottom:0.5em">&lt;<span class="blue" >xsl:stylesheet</span> <span class="red">xmlns:xsl=</span><span class="green">"http://www.w3.org/1999/XSL/Transform"</span> <span class="red"> version=</span><span class="green">"1.0"</span>&gt;</code>
<code class="sp" style="margin-bottom:0.5em">&lt;<span class="blue" >xsl:key</span> <span class="red >name=</span><span class="green" >"items-by-category"</span> <span class="red" >match=</span><span class="green" >"item"</span> <span class="red" >use=</span><span class="green" >"category"</span> /&gt;</code>


as u can see this involves alot of work!!

I am having difficulty knowing where to start and if it can be done using an xslt? Template matches cant be done because it would be xslt elements that u are matching....

_________________________________________________________________
Hotmail messages direct to your mobile phone http://www.msn.co.uk/msnmobile


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.