Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

XSL(T) problem

  • 08-04-2008 5:39pm
    #1
    Registered Users, Registered Users 2 Posts: 1,821 ✭✭✭


    Hey I got a problem with XSL... Move this if it belongs in web forum.

    I believe the problem is with the element scope...

    Basically I have this dtd file:
    <!ELEMENT catalogue (recordings, singers, composers, songs)>
    
    <!ELEMENT recordings (recording+)>
    <!ELEMENT recording (recID, singer, song, recordingDate, format, lengthInMinutes)>
    <!ATTLIST recording recID CDATA #REQUIRED>
    <!ELEMENT singer (#PCDATA)>	
    <!ELEMENT song (#PCDATA)>	
    <!ELEMENT recordingDate (day, month, year)>
    <!ELEMENT day (#PCDATA)>
    <!ELEMENT month (#PCDATA)>
    <!ELEMENT year (#PCDATA)>
    <!ELEMENT format (#PCDATA)>
    <!ELEMENT lengthInMinutes (#PCDATA)>
    
    <!ELEMENT singers (singer+)>
    <!ELEMENT singer (singerID, name, age)>
    <!ATTLIST singer singerID CDATA #REQUIRED>
    <!ELEMENT name (firstname, surname)>
    <!ELEMENT firstname (#PCDATA)>
    <!ELEMENT surname (#PCDATA)>
    <!ELEMENT age (#PCDATA)>
    
    <!ELEMENT composers (composer+)>
    <!ELEMENT composer (composerID, name, age)>
    <!ATTLIST composer composerID CDATA #REQUIRED>
    <!ELEMENT name (firstname, surname)>
    <!ELEMENT firstname (#PCDATA)>
    <!ELEMENT surname (#PCDATA)>
    <!ELEMENT age (#PCDATA)>
    
    <!ELEMENT songs (song+)>
    <!ELEMENT song (sonID, title, composer)>
    <!ATTLIST song songID CDATA #REQUIRED>
    <!ELEMENT title (#PCDATA)>
    <!ELEMENT composer (#PCDATA)>
    

    So what I need to do is match the recordings in a html table using cross referencing. I can do this. Heres the output:

    RecID | Singer | Song | RecordingDate | Format | LengthInMinutes | Composer
    2 | Driscoll, Aidan | La la la | 17January2006 | MP3 | 4.5 | AidanMcCarthy
    1 | Driscoll, Aidan | Fra la la | 17January2006 | MP3 | 3.5 | AidanDonovan
    3 | Sullivan, Aidan | Fra la la | 18January2006 | MP3 | 3.7 | AidanDonovan
    4 | Sullivan, Martin | Fra la la | 19January2006 | MP3 | 3.6 | AidanDonovan

    The problem I'm having is sorting the data by elements which arent being selected. So if I want to sort the data by song title I have the following xsl doc to do so (and the output is above, so its not sorting properly):
    <xsl:for-each select="/catalogue/recordings/recording">
    <xsl:sort select="/catalogue/songs/song/title" />
          <tr>
            <td><xsl:value-of select="@recID" /></td>
            <td><xsl:value-of select="/catalogue/singers/singer[@singerID=current()/singer]/name/surname" />, 
            <xsl:value-of select="/catalogue/singers/singer[@singerID=current()/singer]/name/firstname" /></td>
            <td><xsl:value-of select="/catalogue/songs/song[@songID=current()/song]/title" /></td>
            <td><xsl:value-of select="recordingDate" /></td>
            <td><xsl:value-of select="format" /></td>
            <td><xsl:value-of select="lengthInMinutes" /></td>
            <td>
            <xsl:value-of select="/catalogue/composers/composer[@composerID=/catalogue/songs/song[@songID=current()/song]/composer]/name" /></td>
          </tr>
    </xsl:for-each>
    

    So as you can see the problem is with : <xsl:sort select="/catalogue/songs/song/title" />. Since this is outside the foreach scope its not sorting it by this. Anybody know how I could sort it by an element outside recordings?

    Thanks,


Advertisement