ASP Error: 70
Description: Permission denied
Source: Microsoft VBScript runtime error

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

Re: rearranging and colouring a document

Subject: Re: rearranging and colouring a document
From: horst@xxxxxxxxxxx
Date: Thu, 8 Aug 2002 19:59:01 +0200 (CEST)
colouring
Hello,
thanks for your advice, I managed to get the sorting to work. It
took a while, as the fast sablotron seems to have problems with
the solution, but xalan works find for me.

However, I tried the proposed solution for colouring, but had
problems, as my description of the source was imprecise. Here a
more suitable example:

<text>
<sp><speaker>foo</speaker><p>text 1</p></sp>
<sp><speaker>bar</speaker><p>text 2</p></sp>
<sp><speaker>foo</speaker><p>text 3</p></sp>
<sp><speaker>xxxx</speaker><p>text 4</p></sp>
<sp><speaker>foo</speaker><p>text 5</p></sp>
<sp><speaker>xxxx</speaker><p>text 6</p></sp>
<sp><speaker>bar</speaker><p>text 7</p></sp>
</text>

how could I extract some kind of index from the speaker element?
- that is in this example:
foo: 1
bar: 2
xxxx: 3
(or any other unique number sequence suitable for indexing).

So it can be mapped to colours, which for example can be found in
an external xml document.

Thanks,

Horst



On 30 Jul, Jacoby, Peter R. wrote:
> Horst,
> 
> As you said there are two parts to your problem, sorting and adding a colour
> attribute.  The first is simpler, using the <xsl:sort> element:
> 
> <xsl:apply-templates select="sp">
> 	<xsl:sort select="speaker" data-type="text" order="ascending" />
> </xsl:apply-templates>
> 
> This will match on all <sp> elements and they will be sorted by the text in
> the <speaker> element.
> 
> For the second part, you were not exactly clear on the format for storing
> the possible colours to use so I took some liberty.  You can create a
> separate document to store all possible colours you will use.  In order for
> this method to work, you must have enough colours listed (equal to or more
> than the number of unique <person> elements).
> 
> The contents of possibleColours.xml:
> <?xml version="1.0" ?>
> <colours>
> 	<colour>red</colour>
> 	<colour>blue</colour>
> 	<colour>green</colour>
> </colours>
> 
> You can then use the document function to retrieve the contents of this
> file:
> <xsl:variable name="colours"
> select="document('possibleColours.xml')/colours"/>
> 
> The way you match a colour with a unique person is up to you, but one
> possibility is to use the position of the colour element and the text after
> "person" in the speaker element (i.e. "person2" would match on the colour in
> the second position).
> 
> The entire stylesheet is:
> 
> <?xml version="1.0" ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:variable name="colours"
> select="document('possibleColours.xml')/colours"/>
> 
> <xsl:template match="text">
> 	<text>
> 		<xsl:apply-templates select="sp">
> 			<xsl:sort select="speaker" data-type="text"
> order="ascending" />
> 		</xsl:apply-templates>
> 	</text>
> </xsl:template>
> 
> <xsl:template match="sp">
> 	<xsl:param name="current" select="substring-after(speaker,
> 'person')" />
> 	<sp colour="{$colours/colour[position() = $current]}">
> 		<xsl:copy-of select="*|text()" />
> 	</sp>
> </xsl:template>
> 
> <xsl:template match="text()"/>
> 	
> </xsl:stylesheet>
> 
> Hope this helps.
> 
> -Peter 
> 
> [I hadn't realized how hard it is for an American to write colour instead of
> color repeatedly.  And my spell checker complained too.]
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

-- 
Horst@xxxxxxxxxxx
Horst Eyermann 
Germany

You need a dictionary? - visit http://www.freedict.de
for free (GPL) dictionaries (unix; windows work in progress)
For windows, visit http://www.freedict.de/wbuch

A article (in German) about dictionary efforts on the net
http://www.heise.de/tp/deutsch/inhalt/on/5927/1.html 



 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.