xsl:sort - where am I going wrong??

I'm hoping someone can help me with what looks like a very simple problem. My 
output does not sort the languages alphabetically as I would expect. Can 
someone inspect my XSLT please? TIA!!


XML:
<?xml version="1.0" ?>
<Markets>
  <Market name="US">
    <Language name="English (US)" LCID="1033" LangCode="en-US" 
PSname="English" />
  </Market>
  <Market name="Australia">
    <Language name="English (Australia)" LCID="1033" LangCode="en-AU" 
PSname="English" />
  </Market>
  <Market name="Canada">
    <Language name="English (Canada)" LCID="1033" LangCode="en-CA" 
PSname="English" />
    <Language name="French (Canada)" LCID="1036" LangCode="fr-CA" 
PSname="French" />
  </Market>
  <Market name="UK">
    <Language name="English (UK)" LCID="1033" LangCode="en-GB" 
PSname="English" />
  </Market>
  <Market name="Hong-Kong">
    <Language name="English (Hong-Kong)" LCID="1033" LangCode="en-HK" 
PSname="English" />
    <Language name="Chinese/T (Hong-Kong)" LCID="1028" LangCode="zh-HK" 
PSname="Chinese (Hong Kong)" />
  </Market>
  <Market name="India">
    <Language name="English (India)" LCID="1033" LangCode="en-IN" 
PSname="English" />
  </Market>
  <Market name="Indonesia">
    <Language name="English (Indonesia)" LCID="1033" LangCode="en-ID" 
PSname="English" />
  </Market>
</Markets>

XSL:
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	 <xsl:template match="Markets">
		<Markets>
			<xsl:apply-templates select="Market"/>
		</Markets>
	</xsl:template>
	<xsl:template match="Market">
		<xsl:apply-templates select="Language">
			<xsl:sort select="@name"/>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="Language">
		<Language>
			<xsl:attribute name="name">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
		</Language>
	</xsl:template>
</xsl:stylesheet>

Output:
<?xml version="1.0" encoding="utf-8"?>
<Markets>
<Language name="English (US)" />
<Language name="English (Australia)" />
<Language name="English (Canada)" />
<Language name="French (Canada)" />
<Language name="English (UK)" />
<Language name="Chinese/T (Hong-Kong)" />
<Language name="English (Hong-Kong)" />
<Language name="English (India)" />
<Language name="English (Indonesia)" />
</Markets>
0
Illustris (1)
8/7/2007 9:54:02 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
658 Views

Similar Articles

[PageSpeed] 14

Hi,

You're sorting the languages within a market, which since there is only one 
per market, is not doing much.  Try moving the sort to within 
<xsl:apply-templates select="Market"/> earlier on.  Then sort on @name or 
Language/@name depending on which name you're trying to sort on.

Hope that helps!
Priscilla
-------------------------------------------------------------------------
Priscilla Walmsley http://www.datypic.com
Author, Definitive XML Schema / XML in Office 2003
Definitive XQuery (coming in 2006)
-------------------------------------------------------------------------

"Illustris" <Illustris@discussions.microsoft.com> wrote in message 
news:7C57C427-1A75-4DA2-B885-40F31A353F63@microsoft.com...
> I'm hoping someone can help me with what looks like a very simple problem. 
> My
> output does not sort the languages alphabetically as I would expect. Can
> someone inspect my XSLT please? TIA!!
>
>
> XML:
> <?xml version="1.0" ?>
> <Markets>
>  <Market name="US">
>    <Language name="English (US)" LCID="1033" LangCode="en-US"
> PSname="English" />
>  </Market>
>  <Market name="Australia">
>    <Language name="English (Australia)" LCID="1033" LangCode="en-AU"
> PSname="English" />
>  </Market>
>  <Market name="Canada">
>    <Language name="English (Canada)" LCID="1033" LangCode="en-CA"
> PSname="English" />
>    <Language name="French (Canada)" LCID="1036" LangCode="fr-CA"
> PSname="French" />
>  </Market>
>  <Market name="UK">
>    <Language name="English (UK)" LCID="1033" LangCode="en-GB"
> PSname="English" />
>  </Market>
>  <Market name="Hong-Kong">
>    <Language name="English (Hong-Kong)" LCID="1033" LangCode="en-HK"
> PSname="English" />
>    <Language name="Chinese/T (Hong-Kong)" LCID="1028" LangCode="zh-HK"
> PSname="Chinese (Hong Kong)" />
>  </Market>
>  <Market name="India">
>    <Language name="English (India)" LCID="1033" LangCode="en-IN"
> PSname="English" />
>  </Market>
>  <Market name="Indonesia">
>    <Language name="English (Indonesia)" LCID="1033" LangCode="en-ID"
> PSname="English" />
>  </Market>
> </Markets>
>
> XSL:
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="Markets">
> <Markets>
> <xsl:apply-templates select="Market"/>
> </Markets>
> </xsl:template>
> <xsl:template match="Market">
> <xsl:apply-templates select="Language">
> <xsl:sort select="@name"/>
> </xsl:apply-templates>
> </xsl:template>
>
> <xsl:template match="Language">
> <Language>
> <xsl:attribute name="name">
> <xsl:value-of select="@name"/>
> </xsl:attribute>
> </Language>
> </xsl:template>
> </xsl:stylesheet>
>
> Output:
> <?xml version="1.0" encoding="utf-8"?>
> <Markets>
> <Language name="English (US)" />
> <Language name="English (Australia)" />
> <Language name="English (Canada)" />
> <Language name="French (Canada)" />
> <Language name="English (UK)" />
> <Language name="Chinese/T (Hong-Kong)" />
> <Language name="English (Hong-Kong)" />
> <Language name="English (India)" />
> <Language name="English (Indonesia)" />
> </Markets> 


0
nospam4696 (28)
8/7/2007 10:19:18 PM
Reply:

Similar Artilces:

Sorting a List #2
Hi, In column A I have a list of dollar values. $40 $-30 $10 $0 $0 $120 What I would like to do is in column B put a ranking 1through whatever corresponding to their dollar value so it would look like this: $40 2 $-30 6 $10 3 $0 4 $0 4 $120 1 I hope I explained it well. In other words, in column B, they are sorted according to rank right where they stand. $120 is number 1. $-30 is number 6, etc. Thanks, Tom In B1: =rank(a1,$a$1:$a$6) and copy down to B6 Tom G wrote: > > Hi, > > In column A I have a list of dollar values. > > $40 > $-30 &...

XSL feed-- Metadata -Deployement Mgr
hi when we publish from deployement manager the xsl files are getting changed!!! my question is from which table(or tables) of the MSCRM, the metadata for the XSL is feeded??? Thanks in advance OrganizationUIBase Mike greaterthantwo media Printable Quotes, Orders and Invoices, with line-item details, now available for MSCRM. http://www.greaterthantwo.com "Apple" <none@nospam.com> wrote in message news:ueXyX%233%23DHA.3536@TK2MSFTNGP10.phx.gbl... > hi > when we publish from deployement manager the xsl files are getting > changed!!! > > my question is fro...

Top 10 data sort in Pivot Tables
I have looked on Help to see how to sort the data in a pivot table, to give the Top 10 in the right order, but when I try to follow these instructions I do not see the options. I can see the Pivot Tool Bar and click PivotTable but then it does not give me the option Sort and Top 10. I am new to Pivot Tables, can anyone help me please? Hi Gill Double click on a Field name>Advanced>click radio button for Show Top 10. Regards Roger Govier Gill wrote: > I have looked on Help to see how to sort the data in a pivot table, to give > the Top 10 in the right order, but when I tr...

How save SORT?
An using MS Office 2002 Excel. Have various worksheets that I always sort a certain way... let's say address list is sorted Column B, then Column A, then Column C. Problem is... everytime I go to sort, I have to re-enter this. Is there a way to save it for a specific worksheet file? Not sure, but it seems like some worksheets save it (it pops up with this sort criteria), others don't. Thanks Have you tried to record the steps as a macro (Tools|Macro|Record) Then assign the macro to a button; View|Toolbars|Forms - drag the small rectangle icon onto the sheet and assign your macr...

sorting/ordering a column by day of the week
i am making a spreadsheet of a weekly schedule, so i need to be able to sort and order a column not by day AND date (wednesday, January 8, 2010), but simply by day of the week. in 'format cells,' there is no such capacity, and when i sort ascending, it gives me the days in alphabetical order and not in day of the week order. does anyone know how to get excel to order a column from monday to friday (or sunday to saturday)? thanks so much, -- Laura Use a helper column. If dates are in col. A, use: =WEEKDAY(A2,3) and fill down. Then sort ascending based on this new column. HTH ...

Income Subtotal Showing Wrong Subtotal
When I set up my budget in Microsoft Money 2003 deluxe & Business, it shows the subtoal for my income as more than twice the amount of the bi-monthly income amount. Why is this wrong? When I go to Bills & Deposits, i have my paycheck deposited every 2 weeks. This amount shows up correctly but for some reason the Subtotal in the budget for Income , shows more than twice this amount. ?? ...

Sort Order incorrect
Sorting seems to have stopped working. It is grouping like items together but whether ascending or descending it jumps from A..B...F....M....D....C....E... etc. Has anyone experienced this problem or knows a resolution. I have to export everything to excel to print to get the correct sorting. William ...

Auto Sort #3
I have a chart that the range is A9:AR25 with the headings being in ro 8(A8:AR8). I am trying to find out how I can have this char automatically sort the data when a new value is entered, sort first b column AR, if tied then by column AI and finally if still tied b column AO -- Message posted from http://www.ExcelForum.com record a macro of your sort and then place within a worksheet change event in the sheet module -- Don Guillett SalesAid Software donaldb@281.com "Rob04 >" <<Rob04.163lpk@excelforum-nospam.com> wrote in message news:Rob04.163lpk@excelforum-nospam.co...

Sorting hidden columns
PP 2007 Why doesn't a Sort sort what is also included in Hidden Columns? Provide more details about what you have in what columns, what columns are hidden, what your sort parameters are, what you do when you sort, what happens when you sort, and what you want to happen when you sort. I tried sorting a number of columns, with some columns hidden, and all sorted correctly. HTH Otto "zyzzyva" <zyzzyva@discussions.microsoft.com> wrote in message news:6D77EA68-BF4C-4728-B908-4F784190340D@microsoft.com... > PP 2007 > > Why doesn't a Sort sort ...

Sort data witth blank line between entries
Hi I have a worksheet with data entries These consist of 1,2,3,4 or more consecutive/grouped entries with the same name in column b for each entry, then a blank line between the next consecutive/grouped entries and so on .... Each group of entries has a box border, which i would like to keep if possible. How do i sort column b alphabetically? The only way i can get *sort* to work is to remove the space between my grouped entries Martin ���� Hi just for sorting you may use a helper column. Lets say you use column D for this and row 1 is a header row. Enter the following in D2: =IF(B2=&quo...

If WB not there; give message: What am I doing wrong?
Sub DEC_NY_AutoShape22_Click() ' ' AutoShape21_Click Macro ' Macro recorded 8/31/2009 by Rick Green ' Application.ScreenUpdating = False ' 'Dim wb As Workbook 'On Error Resume Next 'Set wb = ActiveWorkbook.Worksheets("DEC") 'On Error GoTo 0 'If wb Is Nothing Then ' MsgBox "Year not active for this month." 'Else ChDir _ "C:\Documents and Settings\RICK\My Documents\Calendar\Y2010" Workbooks.Open Filename:= _ "C:\Documents and Settings\RICK\My Documents\Calenda...

Stop chart lines going to zero
Chart lines drop to zero on last point unless cell is highlighted and delete key pressed, which is no good if there is a formulae in the cell. Anybody know how to cure this ?? In article <68F329DB-DF81-4F7C-89BC-108D1DAB559C@microsoft.com>, =?Utf-8?B? VG9tIEg=?= <Tom H@discussions.microsoft.com> says... > Chart lines drop to zero on last point unless cell is highlighted and delete > key pressed, which is no good if there is a formulae in the cell. Anybody > know how to cure this ?? > > Replace the "" in the formula with NA() -- Regards, Tushar ...

xsl:with-param fails in XSL that accepts arguments from XML control
Hi, why does with-param fail to send parameters to any templates in a stylesheet that also accepts arguments from the ASP.NET XML control? The argument from the XML control seems to be available to any template in the stylesheet, even if a parameter for the argument is NOT coded for a template call. On the other hand, any parameters coded for a template call don't seem to pass their values (the stylesheet doesn't crash - everything is still rendered). ASP.NET C# code that loads the xml control xmlCtrl.TransformSource="template.xsl"; XsltArgumentList args1 = new XsltArgum...

sorting numbers #4
i have a simple sheet that basically consists of name, ip address, and then other columns obviously when i sort by ip address the .1,.2,.3,.4,.5, etc get sorted in between the higher numbers ie: 99 100 1 101 102 and i have to manually move them i cant seem to see how you can sort within a column if the above makes sense :) -- adetorry ------------------------------------------------------------------------ adetorry's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29151 View this thread: http://www.excelforum.com/showthread.php?threadid=488723 See: http...

Problem when Loading XSL file using XslCompiledTransform
Hi, I am testing the scenario to migrate from MSMXL4 to .NET2.0 system.xml. I experienced xsl file loading problem whenever the xsl file have a user defined script in it. The error message is as follow: "Objects of type 'Script2' do not have such a member" The above error only happens when I set the XsltSettings.TrustedXslt ans use the following statement to load xsl file: objxslcompiledtransform.Load(input, XsltSettings.TrustedXslt , new XmlUrlResolver()); Can anyone tell me what is happening here? Sample Xsl script: <msxsl:script language="javascript" ...

Sorting Worksheets in a workbook
Hi all, I am trying to use Cpearson's VBA procedure 'Sorting by Name' but I am not sure -- do I have to copy and save it into every worksheet? My workbook has 43 tabs so far. Thanks See http://www.ozgrid.com/VBA/sort-sheets.htm -- Regards Dave Hawley www.ozgrid.com "Doehead" <Doehead@discussions.microsoft.com> wrote in message news:56CAD6E6-CC28-4C7C-A6AC-EE5E2AA53665@microsoft.com... > Hi all, I am trying to use Cpearson's VBA procedure 'Sorting by Name' but > I > am not sure -- do I have to copy and save it into every w...

lock rows on sort
I'm working on a large table (about 2000 rows, 50 columns). I frequently have to sort the entire table based on one column, and I keep forgetting and sort just the column, disassociating the rest of the data from that column. Is there a way to lock rows so that I can't make this mistake, so that whenever I sort a column it sorts the whole table based on that column? Ken Benson Use Access instead? Kenneth C. Benson wrote: > I'm working on a large table (about 2000 rows, 50 columns). I frequently > have to sort the entire table based on one column, and I keep forgettin...

No out going e-mails
Its a strange problem. We can recieve incoming e-mails but cannot send e-mails outside the company. We don't even get any NDR. Our DNS is hosted by ISP. So something is wrong. We haven't changed anything on the server. Its just too strange. We can recieve e-mails but no e-mails are being recieved by people outside the company. Please advice. Exchange 5.5 sp4. Thanks, JS Is your ISP XO Communications? If so, they recently under went DNS changes. "JS" <anonymous@discussions.microsoft.com> wrote in message news:01d001c3bb57$9bf2df00$a101280a@phx.gbl... > Its...

Sorting and displaying different results
I have a spreadsheet made up of 2 columns - Drawing Number and Drawing Name. I would like to have 2 different sorted results show up on one page without actually typing the info twice (one list sorted by drawing number and the other sorted by name). In other words, I want the base data to be referenced somewhere else sorted differently and will reflect any future changes to the base data. Am I making sense here? Thanks in advance for any help Mac Maybe something along these lines .. Assuming the sample source data below is in Sheet1, cols A and B, data from row2 down (sample data ...

sort cells with hyphen #####-###-#### #2
How do you sort a column of numbers with hyphens? Example #####-###-####. I want to sort by the 3 middle numbers Thanks You can extract the 3 middle characters to a new column and then sort on that new column. =MID(A1,7,3) HTH Jason Atlanta, GA "bagman" wrote: > How do you sort a column of numbers with hyphens? > Example #####-###-####. > I want to sort by the 3 middle numbers > Thanks Put the middle numbers into a separate column and sort by that. This formula will get you those values =LEFT(MID(A1,FIND("-",A1)+1,99),FIND("-",MID(A1,FIND(&q...

Wrong Values
Hi, Cell G23 in sheet "Cert_End" has the formula: =IF(VLOOKUP($A$3,Table!$B$14:$BD$93,ROW(A4)*3+3,FALSE)<>"",(VLOOKUP($A$3,Table!$B$14:$BD$93,ROW(A4)*3+3,FALSE)),"") It will look up the number from sheet "table" that corresponds with the value in cell A3 in sheet . At the cell H23, I have the formula: =GetTen(G23) where GetTen is a function that converts number into words: (98 in cell G23 will have Ninety Eight in cell H23). My problem is that I see the value "Ninty five" instead of "ninty eight". For some cells it works f...

automatic sorting in excel
I would like to be able to have a column sorted alphabetically contiuously. In other words, whenever data is entered, the whole column gets arranged alphabetically without having to "click' on the sort function. I am not a power user of excel, but I now understand the basics of running a macro. I have been guided to use the following macro example and adapt it to my worksheet. I have tried a few changes, but I cannot get it to work. Lets say the filename is "mybook" and the worksheet name is "sheet1" and the range I want to sort automatically is B1:B20 ...

xsl:if and string function
I'm at my wit's end with this one. Within an xsl:if test, I'm not able to get 2 variables to properly evaluate if one of them is wrapped within a string function. <!-- This works --> <xsl:if test="$var:v141=&quot;true&quot;"> <!-- This doesn't work --> <xsl:if test="string($var:v141)=&quot;true&quot;"> I can't figure out why. The transformation is taking place within dotnet and the var:v141 is assigned through a function call and it doesn't matter if I return a boolean value or a string value ("true&quo...

Spreadsheet Protection & Sort
Is there a way to protect a spreadsheet (just one column of cells) yet allow for the spreadsheet to be sorted? Thanks for your help in advance. John John, If you want to sort only the unlocked cells of a protected sheet, you can do so with XL2002. In Tools - Protection, you have to option of allowing sort. Not available in XL97, don't know about 2000. In 97, it's generally done with a macro that unprotects the sheet, does the sort, then protects the sheet. -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "John"...

How to delete most of the "custom sort list"
I didnt like what Excel imported now I have a lot of junk that will take a very very long time to remove from the custom list. Is there a way to delet them? I tried shift control and selecting the ones but that didnt work. Thanks Do you want to delete all of them? If yes, you could run a macro: Option Explicit Sub testme() Dim iCtr As Long For iCtr = Application.CustomListCount To 5 Step -1 Application.DeleteCustomList iCtr Next iCtr End Sub If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/...