|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
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 |
|
#2
|
|||
|
|||
|
have u tried order ...
just a thought....
<xsl:sort order="ascending" select="hotWordTitle"/> thank u regards niha |
|
#3
|
|||
|
|||
|
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). |
|
#4
|
|||
|
|||
|
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 ![]() |
|
#5
|
|||
|
|||
|
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! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl:sort not working |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|