Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xsl:variables.

From: "Guoqi Zheng" <no@-----.--->
To: NULL
Date: 3/28/2008 4:01:00 AM

Also the function works as case sensitive, how can I make it 
case-insensitive?

Regards,

Guoqi Zheng

"Guoqi Zheng" <no@s...> 写入消息 
news:8E37EA2D-6CB9-4B36-B423-7E2DC932D24D@m......
> Also in this template
> -----------------------------------------------------------
>   <xsl:template match="item">
>     <xsl:value-of select="concat(' ', ., '&#10;')"/>
>     <xsl:if test="position() = last()">
>       <xsl:text>&#10;</xsl:text>
>     </xsl:if>
>   </xsl:template>
> -----------------------------------------------------------
>
> I need to get the position of this item in the whole data, not just this 
> group only, How am I going to get the position()
>
> Thanks.
>
> Guoqi Zheng
>
>
> "Guoqi Zheng" <no@s...> 写入消息 
> news:E22A88F1-A666-4738-BC81-5D60F9F9CD42@m......
>> Martin,
>>
>> You are really great. Everything works. However do you mind explaining to 
>> me what does below code do?
>> generate-id() = generate-id(key('by-letter', substring(., 1, 1))[1])
>>
>> I do not understand what does the generate-id do here? do you mind 
>> explain?
>>
>> Regards,
>>
>> Guoqi Zheng
>>
>> "Martin Honnen" <mahotrash@y...> 写入消息 
>> news:erQ2sABkIHA.2304@T......
>>> Guoqi Zheng wrote:
>>>
>>>> I got a XML which I just need to display them based on Alphabet order, 
>>>> and at the beginning of every Alphabet, I write out the Alphabet 
>>>> letter.
>>>
>>> Assuming the input XML is
>>>
>>> <root>
>>>   <item>Canada</item>
>>>   <item>America</item>
>>>   <item>Belgium</item>
>>>   <item>Benelux</item>
>>>   <item>Australia</item>
>>>   <item>China</item>
>>> </root>
>>>
>>> then this stylesheet
>>>
>>> <xsl:stylesheet
>>>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>   version="1.0">
>>>
>>>   <xsl:output method="text"/>
>>>
>>>   <xsl:key name="by-letter" match="item" use="substring(., 1, 1)"/>
>>>
>>>   <xsl:template match="root">
>>>     <xsl:apply-templates select="item[generate-id() = 
>>> generate-id(key('by-letter', substring(., 1, 1))[1])]" mode="group">
>>>       <xsl:sort select="substring(., 1, 1)" data-type="text"/>
>>>     </xsl:apply-templates>
>>>   </xsl:template>
>>>
>>>   <xsl:template match="item" mode="group">
>>>     <xsl:value-of select="concat(substring(., 1, 1), '&#10;')"/>
>>>     <xsl:apply-templates select="key('by-letter', substring(., 1, 1))">
>>>       <xsl:sort select="." data-type="text"/>
>>>     </xsl:apply-templates>
>>>   </xsl:template>
>>>
>>>   <xsl:template match="item">
>>>     <xsl:value-of select="concat(' ', ., '&#10;')"/>
>>>     <xsl:if test="position() = last()">
>>>       <xsl:text>&#10;</xsl:text>
>>>     </xsl:if>
>>>   </xsl:template>
>>>
>>> </xsl:stylesheet>
>>>
>>> creates the following result:
>>>
>>>
>>> A
>>>  America
>>>  Australia
>>>
>>> B
>>>  Belgium
>>>  Benelux
>>>
>>> C
>>>  Canada
>>>  China
>>>
>>>
>>> With XSLT 2.0 you can achieve the same as follows:
>>>
>>> <xsl:stylesheet
>>>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>   version="2.0">
>>>
>>>   <xsl:output method="text"/>
>>>
>>>   <xsl:template match="root">
>>>     <xsl:for-each-group select="item" group-by="substring(., 1, 1)">
>>>       <xsl:sort select="substring(., 1, 1)"/>
>>>       <xsl:value-of select="concat(current-grouping-key(), '&#10;')"/>
>>>       <xsl:apply-templates select="current-group()">
>>>         <xsl:sort select="." data-type="text"/>
>>>       </xsl:apply-templates>
>>>     </xsl:for-each-group>
>>>   </xsl:template>
>>>
>>>   <xsl:template match="item">
>>>     <xsl:value-of select="concat(' ', ., '&#10;')"/>
>>>     <xsl:if test="position() = last()">
>>>       <xsl:text>&#10;</xsl:text>
>>>     </xsl:if>
>>>   </xsl:template>
>>>
>>> </xsl:stylesheet>
>>>
>>>
>>> -- 
>>>
>>> Martin Honnen --- MVP XML
>>> http://JavaScript.FAQTs.com/
>> 


transparent
Print
Mail
Digg
delicious
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