Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Thu, 19 Jun 2008 04:05:49 -0700 (PDT),    group: microsoft.public.xsl        back       


XSL Sort   
How to sort some data with either/or condition
date: Thu, 19 Jun 2008 04:05:49 -0700 (PDT)   author:   tamilselvi

Re: XSL Sort   
tamilselvi wrote:
> How to sort some data with either/or condition

Can you be more specific? How does your data look? What kind of sorting 
criteria do you want to use exactly?
Sorting in XSLT 1.0 is done with the xsl:sort element as a child element 
of xsl:for-each or xsl:apply-templates, see 
http://www.w3.org/TR/xslt#sorting
With XSLT 2.0 you have xsl:sort and additionally xsl:perform-sort, see 
http://www.w3.org/TR/xslt20/#creating-sorted-sequence.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Thu, 19 Jun 2008 13:20:49 +0200   author:   Martin Honnen

Re: XSL Sort   
On Jun 19, 4:20 pm, Martin Honnen  wrote:
> tamilselvi wrote:
> > How to sort some data with either/or condition
>
> Can you be more specific? How does your data look? What kind of sorting
> criteria do you want to use exactly?
> Sorting in XSLT 1.0 is done with the xsl:sort element as a child element
> of xsl:for-each or xsl:apply-templates, seehttp://www.w3.org/TR/xslt#sorting
> With XSLT 2.0 you have xsl:sort and additionally xsl:perform-sort, seehttp://www.w3.org/TR/xslt20/#creating-sorted-sequence.
>
> --
>
>         Martin Honnen --- MVP XML
>        http://JavaScript.FAQTs.com/

I have two fields Name & Sortname , here i have to sort by "Name" if
Name is null in that record i have to sort by Sortname...

1. How to find the field "Name " is null in sort?
2. If "Name" is null how to sort by "Sortname" ?
date: Thu, 19 Jun 2008 04:32:43 -0700 (PDT)   author:   tamilselvi

Re: XSL Sort   
tamilselvi wrote:

> I have two fields Name & Sortname , here i have to sort by "Name" if
> Name is null in that record i have to sort by Sortname...
> 
> 1. How to find the field "Name " is null in sort?
> 2. If "Name" is null how to sort by "Sortname" ?

We are talking about XML and sorting, right?
What do you have, elements named 'Name' and 'Sortname', or attributes 
named 'Name' and 'Sortname'?
And how exactly does a "null" value look in your XML? Does that mean the 
element or attribute is not present at all or does it have a special 
value indicating null?


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Thu, 19 Jun 2008 14:04:21 +0200   author:   Martin Honnen

Re: XSL Sort   
The XML format is

<Company Name="Tamil" Sortname="abc"/>
<Company Name="Tamils" Sortname="xyz"/>
<Company Name="ABCs" Sortname="Www"/>
date: Thu, 19 Jun 2008 05:28:07 -0700 (PDT)   author:   tamilselvi

Re: XSL Sort   
tamilselvi wrote:
> The XML format is
> 
> <Company Name="Tamil" Sortname="abc"/>
> <Company Name="Tamils" Sortname="xyz"/>
> <Company Name="ABCs" Sortname="Www"/>

So you have attributes named 'Name' and 'Sortname'. Try whether
   <xsl:apply-templates select="Company">
     <xsl:sort select="@Name" data-type="text"/>
     <xsl:sort select="@Sortname" data-type="text"/>
   </xsl:apply-templates>
does what you are looking for. That sorts on @Name first, then on @Sortname.

If the above is not what you are looking for then you need to tell us 
exactly what kind of "null" values you have i.e. whether the attribute 
is not present or whether it has a special value indicating null.



-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Thu, 19 Jun 2008 14:37:52 +0200   author:   Martin Honnen

Re: XSL Sort   
Martin Honnen wrote:
> tamilselvi wrote:
>> The XML format is
>>
>> <Company Name="Tamil" Sortname="abc"/>
>> <Company Name="Tamils" Sortname="xyz"/>
>> <Company Name="ABCs" Sortname="Www"/>
> 
> So you have attributes named 'Name' and 'Sortname'. Try whether
>   <xsl:apply-templates select="Company">
>     <xsl:sort select="@Name" data-type="text"/>
>     <xsl:sort select="@Sortname" data-type="text"/>
>   </xsl:apply-templates>
> does what you are looking for. That sorts on @Name first, then on 
> @Sortname.
> 
> If the above is not what you are looking for then you need to tell us 
> exactly what kind of "null" values you have i.e. whether the attribute 
> is not present or whether it has a special value indicating null.

Assuming "null" value means that the Name attribute is not present you 
can use
   <xsl:apply-templates select="Company">
     <xsl:sort select="(@Name | @Sortname)[1]"/>
   </xsl:apply-templates>



-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Thu, 19 Jun 2008 15:37:57 +0200   author:   Martin Honnen

Re: XSL Sort   
Martin Honnen wrote:

> Assuming "null" value means that the Name attribute is not present you 
> can use
>   <xsl:apply-templates select="Company">
>     <xsl:sort select="(@Name | @Sortname)[1]"/>
>   </xsl:apply-templates>

Slight correction:

   <xsl:apply-templates select="Company">
     <xsl:sort select="(@Name | @Sortname[not(../@Name)])[1]"/>
   </xsl:apply-templates>

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Thu, 19 Jun 2008 15:56:20 +0200   author:   Martin Honnen

Re: XSL Sort   
On Jun 19, 6:56 pm, Martin Honnen  wrote:
> Martin Honnen wrote:
> > Assuming "null" value means that the Name attribute is not present you
> > can use
> >   <xsl:apply-templates select="Company">
> >     <xsl:sort select="(@Name | @Sortname)[1]"/>
> >   </xsl:apply-templates>
>
> Slight correction:
>
>    <xsl:apply-templates select="Company">
>      <xsl:sort select="(@Name | @Sortname[not(../@Name)])[1]"/>
>    </xsl:apply-templates>
>
> --
>
>         Martin Honnen --- MVP XML
>        http://JavaScript.FAQTs.com/


Thanks

 <xsl:apply-templates select="Company">
      <xsl:sort select="(@Name | @Sortname[not(../@Name)])[1]"/>
 </xsl:apply-templates>

Its working fine.
Can u explain this concept <xsl:sort select="(@SortName | @Name[not(../
@SortName)])[1]"/>
date: Thu, 19 Jun 2008 21:02:22 -0700 (PDT)   author:   tamilselvi

Re: XSL Sort   
tamilselvi wrote:

>  <xsl:apply-templates select="Company">
>       <xsl:sort select="(@Name | @Sortname[not(../@Name)])[1]"/>
>  </xsl:apply-templates>
> 
> Its working fine.
> Can u explain this concept 

<xsl:sort select="(@Name | @Sortname[not(../@Name)])[1]"/> can be 
further simplified to
   <xsl:sort select="(@Name | @Sortname[not(../@Name)])"/>
The '|' is the union operator so what you do is taking the union of the 
'Name' attribute and the 'Sortname' attribute not having a parent with a 
'Name' attribute.
That way you ensure that, if the 'Name' attribute is present, you sort 
on the 'Name' attribute, and if 'Name' is not present, then you sort on 
the 'Sortname' attribute.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Fri, 20 Jun 2008 13:30:14 +0200   author:   Martin Honnen

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us