xsl-list
[Top] [All Lists]

tagging an xslt up for web pages

2003-11-17 02:52:38
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



<Prev in Thread] Current Thread [Next in Thread>