Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Newbie (Parse and substring). >Thread Next - Re: Newbie (Parse and substring). Re: Newbie (Parse and substring).To: NULL Date: 3/6/2007 3:23:00 PM
Martin,
I thank you very very very much..
However may I ask a question still about the substring.
How can I make the sort if instead I have
<category>book/computer/asp</category>
I use another node like this one
<lnk>http://mywebsite/uk/book/computer/asp</lnk>
<lnk>http://mywebsite/sp/cd/world/xxx</lnk>
I would like to perform the sort on "book" and "cd".
I read the code and test it. It works well but I tried to udpate it to
handle my new needs and I failed.
I suppose that I have to play with this statement
substring-before(substring-after(U, '/'), '/'))[1])]
and maybe this one <xsl:sort
select="substring-before(substring-after(U,'/'), '/')" data-type="text"
order="ascending"/>
But.. but.. :(
Once again, I thank you in advance.
Stan
----- Original Message -----
From: "Martin Honnen" <mahotrash@y...>
Newsgroups: microsoft.public.xsl
Sent: Tuesday, March 06, 2007 1:52 PM
Subject: Re: Newbie (Parse and substring).
> Stan wrote:
>
>> I have to transform a XML file formated like that :
>>
>> <main>
>> <smain>
>> <code>Book 0</code>
>> <category>book/thriller/conelly</category>
>> </smain>
>> <smain>
>> <code>Book 1</code>
>> <category>book/computer/asp</category>
>> <smain>
>> <smain>
>> <code>Book 2</code>
>> <category>book/thriller/coben</category>
>> </smain>
>> </main>
>>
>>
>>
>> I have to group the node by category.
>
> Here is an example XSLT 1.0 stylesheet that use a key for grouping and
> also sorts the result:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:output method="html" indent="yes"/>
>
> <xsl:key name="smain-by-category" match="smain"
> use="substring-before(substring-after(category, '/'), '/')"/>
>
> <xsl:template match="/">
> <html>
> <head>
> <title>grouping example</title>
> </head>
> <body>
> <xsl:apply-templates select="main/smain[generate-id() =
> generate-id(key('smain-by-category',
> substring-before(substring-after(category, '/'), '/'))[1])]" mode="group">
> <xsl:sort select="substring-before(substring-after(category, '/'),
> '/')" data-type="text" order="ascending"/>
> </xsl:apply-templates>
> </body>
> </html>
> </xsl:template>
>
> <xsl:template match="smain" mode="group">
> <div class="csscategory">
> <h1><xsl:value-of select="substring-before(substring-after(category,
> '/'), '/')"/></h1>
> <ul>
> <xsl:apply-templates select="key('smain-by-category',
> substring-before(substring-after(category, '/'), '/'))"/>
> </ul>
> </div>
> </xsl:template>
>
> <xsl:template match="smain">
> <li><xsl:value-of select="code"/></li>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
