Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Newbie (Parse and substring).

From: "Stan" <netsunset@-----------.--->
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/ 



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent