SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: xsl sort ?????

Hybrid View

  1. #1
    SitePoint Member Mara's Avatar
    Join Date
    Mar 2001
    Location
    Seattle
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question xsl sort ?????

    Hello,
    I am desparately trying to find a way to sort an xml doc NOT ONLY by title but by somehow passing over the "The" in the title...
    I have been looking extensively on the web and can't seem to find anything...
    Is there a way to do this?

    Here is the xsl file:
    <books>
    <xsl:for-each order-by="+title" select="book" xmlnssl="http://www.w3.org/TR/WD-xsl">
    <book>
    <category>
    <xsl:value-of select="category" />
    </category>
    <title>
    <xsl:value-of select="title" />
    </title>
    <author>
    <xsl:value-of select="author" />
    </author>
    </book>
    </xsl:for-each>
    </books>

    ANY suggestions or comments are welcome!
    THANK YOU,
    Mara

  2. #2
    SitePoint Zealot JEmLAC's Avatar
    Join Date
    Apr 2002
    Location
    Kansas City
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mara,
    I don't have an answer for you, exactly. I'm still working through some novice/intermediate XSLT stuff, myself, but the resource I've been working through (Inside XSLT, Steve Holzner) is an excellent reference and has a section on string handling functions in XSL. I'll try to give an example of something he has in the book which may be applicable and maybe you can cross-reference it with an online resource like W3 or something.
    Code:
    <xsl:template match="text()[starts-with(., 'The ')]">
      <xsl:value-of select="text()[substring-after('wherever you can get the title', 'The ')]"/>
    </xsl:template>
    Note the above code will not work, specifically the contents of the value-of element and the syntax of the select attribute. I'm not sure text() is required. Mainly use it as a jumping off point. Sorry I don't have a more complete answer, but hopefully it will get you started.

    B
    Morning person by habit, not by nature.

  3. #3
    SitePoint Member Mara's Avatar
    Join Date
    Mar 2001
    Location
    Seattle
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help!,
    After looking into string manipulation...I have decided to go the simplistic route and simply add an "alphaIndex" element to the nodes (where the keyword is specified) then order-by the "alphaIndex".
    This works fine but feels a little clunky and not very elegant...
    This is the first time I have played around with xml...it sounded so INTIMIDATING but, there's really not much to the xml itself, huh?
    Thanks again,
    Mara


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •