SunQuest
           XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 13th, 2003, 10:22 PM
pramenjatchek pramenjatchek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 pramenjatchek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question xsl:sort not working



I've created a separate XML file containing a list of other XML files which contain glossary items.

I then have used a stylesheet to pull out the glossary items and display them in a html page. All this is working but when I add an xsl:sort statement to sort the items alphabetically, it doesn't sort, it just displays the items as they have appeared in each XML file. Is there any reason for this?

The XML combine file is:

<files>
<file name="mod01_01.xml"/>
<file name="mod01_02.xml"/>
<file name="mod01_03.xml"/>
<file name="mod01_04.xml"/>
<file name="mod01_05.xml"/>
<file name="mod02_01.xml"/>
<file name="mod03_01.xml"/>
<file name="mod03_02.xml"/>
<file name="mod05_01.xml"/>
<file name="mod07_01.xml"/>
<file name="mod10_01.xml"/>
<file name="mod10_02.xml"/>
<file name="mod10_03.xml"/>
</files>

The XSL file exerpt is:

<xsl:template match="files">
<xsl:for-each select="document(file/@name)">
<xsl:for-each select="/*/pageResources/hotWord">
<xsl:sort select="hotWordTitle"/>
<p><span class="b"><xsl:value-of select="hotWordTitle"/></span><br/><xsl:value-of select="hotWordTxt"/></p>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

Any help would be much appreciated.

Thank you

Reply With Quote
  #2  
Old August 14th, 2003, 04:13 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
have u tried order ...

just a thought....

<xsl:sort order="ascending" select="hotWordTitle"/>

thank u
regards
niha

Reply With Quote
  #3  
Old August 14th, 2003, 08:09 AM
s_c_gardner s_c_gardner is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: NYC
Posts: 8 s_c_gardner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
maybe data-type?

You could try defining the data type. . .

<xsl:sort select="HotWordTitle" data-type="text"/>

Of course, the default should be text anyway. . . so this shouldn't make a difference. It seems more likely that something is causing it to completely ignore the sort.

One thing that does seem likely about your file is that it even if it works, it will probably only sort within each file, not across all the files.

I don't know if this is what you want or not, or if you've clumped your terms sequentially (maybe file 1 is all "A's" or something, which would make sense).

Reply With Quote
  #4  
Old August 14th, 2003, 09:24 AM
opt-d5 opt-d5 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Helsinki, Finland
Posts: 5 opt-d5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This is simple: <xsl:sort select="hotWordTitle" />
won't get your files sorted. This works for me:
Code:
    
    <xsl:template match="files"> 
      <xsl:for-each select="file[@name]"> 
          <xsl:sort select="@name"/> 
          <p><xsl:value-of select="@name"/></p> 
      </xsl:for-each> 
    </xsl:template> 

I can't help more, since I haven't seen the XML file that has
hotWordTitle in it.

Have that a go and tell me if it sovled the problem

Reply With Quote
  #5  
Old August 14th, 2003, 07:11 PM
pramenjatchek pramenjatchek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 pramenjatchek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for all the suggestions

s_c_gardner was right, I got it to sort the items but only per file.

The last suggestion (opt-d5) also didn't work, as the files are actually full educational modules that contain random glossary items in the content, so they could start with any letter and I onlyl needed the hotwords and not the rest.

What I did in the end was to generate a new xml file with one xsl that contains only the hotword items from all the other module files, and then wrote a separate xsl dealing with this newly created file. So now it is sorting all the hotwords correctly.

Probably a big workaround but it seems to work ok.

thanks again!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > xsl:sort not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway