Jump to content

xander85

Members
  • Content Count

    52
  • Joined

  • Last visited

Community Reputation

0 Neutral

About xander85

  • Rank
    Newbie
  1. xander85

    XInclude

    yeah tried that, it sorted ascending for artist, then when i clicked it again it changed back to its default....but mate... i think you have done more than enough!! i have achieved what i wanted, having one xml doc load dynamically into several different style sheets using php!and using dreamweaver if i need to replace anything in the xslt files i just use find replace in current local folder works an absolute treat! hehethanks again mate!leave a comment on my blog page if u wish
  2. xander85

    XInclude

    ok i would like to thank you soo much for your help...i have taken a different approach, wich works fine for me reallythen main thing i wanted was to have one xml file, and i dojust have different php's and xsl's coz that content doesnt change, its just the xml...if you want to get the way you made up working please feel free, and let me know when you do..here is a little shout out to yourself on my site http://www.acousticmushroom.com/blog/if you ever do get the other way working in firefox, please let me know!!! you can post a comment on my site if u wish!cheers mate, have a good one!
  3. xander85

    XInclude

    sorts in ie but not in firefox.... i hate cross platform web design, its a biatch!!!so maybe i wasnt so drunk afterall, and that was after i was sleeping, haha i woke up at 8am still drunk! lol
  4. xander85

    XInclude

    OMG that worked a treat!!!!!!!!!!! haha sorry i think im still drunk, my footy team won last nite and were in the finals, the match b4 the grand final!!!haha i dunno why i told you that but anyways! ?(like i said im still drunk)ok, the only thing now is its only sorting descending. when i click the link it doesnt switch, even tho the url says ascending its sorting descendinghmmm....im guessing its this? <xsl:attribute name="href">?sortBy=<xsl:value-of select="$header"/>&sortOrder=<xsl:choose> <xsl:when test="$sortOrder = 'descending'">ascending</xsl:when> <xsl:when test="$sortOrder = 'ascending'">descending</xsl:when> </xsl:choose> </xsl:attribute>
  5. xander85

    XInclude

    tried the edit you gave, still not sorting, i might use a different approach, the links in the headers.... if i was to say link it to another page (source.php) what would i use?? im guessing it would go here? <tr> <xsl:call-template name="th"> <xsl:with-param name="header">artist</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">album</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">source</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">kind</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">added</xsl:with-param> </xsl:call-template> </tr>
  6. xander85

    XInclude

    hahah yeah i see what IVE done :)i got the code you gave me, but for some reason i was playin wid it, editing it to see if i could get it working, this was before the last few edits you gave me.... i guess i just forgot to change it back :)ill try that out later at work now hehe
  7. xander85

    XInclude

    ok the break; thing added the suffix backstill not sorting grrr....look if we cant get it working or rather you cant get it working i could just use what you have given me to take a different approach
  8. xander85

    XInclude

    changing <xsl:param name="sortBy" select="'added'"/><xsl:param name="sortOrder" select="'descending'"/> to <xsl:param name="sortBy"/><xsl:param name="sortOrder"/> removed the suffix at the end of the url fromlibrary.php?sortBy=added&sortOrder=descendingtolibrary.php?sortBy=added&sortOrder=and changing the stylesheet.php also did nothing....
  9. xander85

    XInclude

    yeah as far as i can see its all correct spelling &amp and case wise.here are the 3files anywaysstylesheet.php <?php//This file will always return an XSLT stylesheet, so we specify that with this MIME typeheader('Content-type: application/xslt+xml');/*If any of the two parameters gets a value that is not whitelisted (in the first argument of the ereg()), the default value will be used */$sortBy = (!ereg('added',$_GET['sortBy']) ? 'added' : $_GET['sortBy']);$sortOrder = (!ereg('descending|ascending',$_GET['sortOrder']) ? 'descending' : $_GET['sortOrder']);//Load the XSLT stylesheet$dom = new DOMDocument;$dom->load('library.xsl');//Get all parameters$params = $dom->documentElement->getElementsByTagNameNS('http://www.w3.org/1999/XSL/Transform','param');//Loop thru all parametersfor ($i = 0; $i < $params->length; $i++) { $param = $params->item($i); /* Treat specially the ones we know and adjust their value to the filtered variant above */ switch($param->getAttribute('name')) { case 'sortBy': $param->nodeValue = $sortBy; break 2; case 'sortOrder': $param->nodeValue = $sortOrder; break 2; default: break 2; }}//Return the stylesheet to the browserecho $dom->saveXML();?> library.php <?php//This file will always return an XSLT stylesheet, so we specify that with this MIME typeheader('Content-type: application/xslt+xml');/*If any of the two parameters gets a value that is not whitelisted (in the first argument of the ereg()), the default value will be used */$sortBy = (!ereg('added',$_GET['sortBy']) ? 'added' : $_GET['sortBy']);$sortOrder = (!ereg('descending|ascending',$_GET['sortOrder']) ? 'descending' : $_GET['sortOrder']);//Load the XSLT stylesheet$dom = new DOMDocument;$dom->load('library.xsl');//Get all parameters$params = $dom->documentElement->getElementsByTagNameNS('http://www.w3.org/1999/XSL/Transform','param');//Loop thru all parametersfor ($i = 0; $i < $params->length; $i++) { $param = $params->item($i); /* Treat specially the ones we know and adjust their value to the filtered variant above */ switch($param->getAttribute('name')) { case 'sortBy': $param->nodeValue = $sortBy; break 2; case 'sortOrder': $param->nodeValue = $sortOrder; break 2; default: break 2; }}//Return the stylesheet to the browserecho $dom->saveXML();?> library.xsl <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:param name="sortBy">added</xsl:param><xsl:param name="sortOrder">descending</xsl:param><xsl:template match="/library"> <html> <link href="library.css" rel="stylesheet" type="text/css" /> <title>acousticmushroom.com .::. music . . .</title><body> <div id="page"> <div id="header" onclick="location.href='http://www.acousticmushroom.com/blog/';" style="cursor: pointer;"/> <div id="content"> <h5> <xsl:for-each select="/library/stats"> Xander's Music Collection<br/><xsl:value-of select="updated"/> </xsl:for-each> </h5> <h6> <xsl:for-each select="/library/stats"> <p> artists - <xsl:value-of select="artists"/> . . . albums - <xsl:value-of select="albums"/> . . . songs - <xsl:value-of select="songs"/></p> <p><xsl:value-of select="playback"/></p> <p><xsl:value-of select="size"/></p> <p>mp3 albums - <xsl:value-of select="mp3"/> . . . aac albums - <xsl:value-of select="aac"/> . . . lossless albums - <xsl:value-of select="lossless"/></p> </xsl:for-each> <p>please note all dates showing 2007-08-01 are albums added to the library prior to the website, ie. i do not have a date for them... yet</p> <p>to search the library use your browsers find function (CTRL+F)</p> <p> click <a href="http://www.acousticmushroom.com/blog">here</a> to return home</p> <p> <a href="http://www.acousticmushroom.com/assets/files/library.pdf">pdf version</a> </p> </h6> <table> <tr> <xsl:call-template name="th"> <xsl:with-param name="header">artist</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">album</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">source</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">kind</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">added</xsl:with-param> </xsl:call-template> </tr> <xsl:choose><!--artist--> <xsl:when test="$sortBy = 'artist'"> <xsl:apply-templates select="music"> <xsl:sort select="artist" order="ascending" /> </xsl:apply-templates> </xsl:when><!--album--> <xsl:when test="$sortBy = 'album'"> <xsl:apply-templates select="music"> <xsl:sort select="album" order="ascending" /> </xsl:apply-templates> </xsl:when><!--source--> <xsl:when test="$sortBy = 'source'"> <xsl:apply-templates select="music"> <xsl:sort select="source" order="ascending" /> </xsl:apply-templates> </xsl:when><!--kind--> <xsl:when test="$sortBy = 'kind'"> <xsl:apply-templates select="music"> <xsl:sort select="kind" order="ascending" /> </xsl:apply-templates> </xsl:when><!--added--> <xsl:when test="$sortBy = 'added'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="descending" /> </xsl:apply-templates> </xsl:when> </xsl:choose> </table> </div> </div> </body> </html></xsl:template><xsl:template match="music"> <tr> <td><xsl:value-of select="artist"/></td> <td><xsl:value-of select="album"/></td> <td><xsl:value-of select="source"/></td> <td><xsl:value-of select="kind"/></td> <td><xsl:value-of select="added"/></td> </tr></xsl:template><xsl:template name="th"> <xsl:param name="header"/> <th> <a> <xsl:attribute name="href">?sortBy=<xsl:value-of select="$header"/>&sortOrder=<xsl:choose> <xsl:when test="$sortOrder = 'descending'">ascending</xsl:when> <xsl:when test="$sortOrder = 'ascending'">descending</xsl:when> </xsl:choose> </xsl:attribute> <xsl:value-of select="$header"/> </a> </th></xsl:template></xsl:stylesheet> cheers
  10. xander85

    XInclude

    ok its working in IE nowwhat you gave me was good, however it refused to load the data table, checked ALL files for spelling etc and now it works.but with this it still refuses to sort <tr> <xsl:call-template name="th"> <xsl:with-param name="header">artist</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">album</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">source</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">kind</xsl:with-param> </xsl:call-template> <xsl:call-template name="th"> <xsl:with-param name="header">added</xsl:with-param> </xsl:call-template> </tr> <xsl:choose><!--artist--> <xsl:when test="$sortBy = 'artist' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="artist" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'artist' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="artist" order="ascending" /> </xsl:apply-templates> </xsl:when><!--album--> <xsl:when test="$sortBy = 'album' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="album" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'album' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="album" order="ascending" /> </xsl:apply-templates> </xsl:when><!--source--> <xsl:when test="$sortBy = 'source' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="source" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'source' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="source" order="ascending" /> </xsl:apply-templates> </xsl:when><!--kind--> <xsl:when test="$sortBy = 'kind' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="kind" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'kind' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="kind" order="ascending" /> </xsl:apply-templates> </xsl:when><!--added--> <xsl:when test="$sortBy = 'added' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'added' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="ascending" /> </xsl:apply-templates> </xsl:when> </xsl:choose> </table> </div> </div> </body> </html></xsl:template><xsl:template match="music"> <tr> <td><xsl:value-of select="artist"/></td> <td><xsl:value-of select="album"/></td> <td><xsl:value-of select="source"/></td> <td><xsl:value-of select="kind"/></td> <td><xsl:value-of select="added"/></td> </tr></xsl:template><xsl:template name="th"> <xsl:param name="header"/> <th> <a> <xsl:attribute name="href">?sortBy=<xsl:value-of select="$header"/>&sortOrder=<xsl:choose> <xsl:when test="$sortOrder = 'descending'">ascending</xsl:when> <xsl:when test="$sortOrder = 'ascending'">descending</xsl:when> </xsl:choose> </xsl:attribute> <xsl:value-of select="$header"/> </a> </th></xsl:template> i cant really see anything thats wrong in that, then again i am only an xslt uber junior hehe
  11. xander85

    XInclude

    added this <xsl:choose><!--artist--> <xsl:when test="$sortBy = 'artist' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="artist" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'artist' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="artist" order="ascending" /> </xsl:apply-templates> </xsl:when><!--album--> <xsl:when test="$sortBy = 'album' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="album" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'album' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="album" order="ascending" /> </xsl:apply-templates> </xsl:when><!--source--> <xsl:when test="$sortBy = 'source' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="source" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'source' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="source" order="ascending" /> </xsl:apply-templates> </xsl:when><!--kind--> <xsl:when test="$sortBy = 'kind' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="kind" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'kind' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="kind" order="ascending" /> </xsl:apply-templates> </xsl:when><!--added--> <xsl:when test="$sortBy = 'added' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'added' and $sortOrder = 'ascending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="ascending" /> </xsl:apply-templates> </xsl:when> </xsl:choose> changed accending, to ascending. chose lower case, as its the same as the xml file, and it looks better hehe.however still not sorting, the URL in the address bar of FF changes from the default oflibrary.php?sortBy=added&sortOrder=ascendingto say when the header is clickedlibrary.php?sortBy=artist&sortOrder=ascendingbut the sorting still remains.also its not switching from ascending to descending and vise versaive checked all the files for spelling and case and & but it still refuses to load in IE
  12. xander85

    XInclude

    headers are now showing, but it still only sorts by 'added' there must me somtin thats overwriting the "onclick" sorting
  13. xander85

    XInclude

    almost there, almost......i added in the code as u mentioned, but its not displaying the table headers? i noticed a typo?? maybe im wrong im not surethe sort...... didnt have a $ as a prefix, it wouldnt load, had a xsl transorm error in firefox, i changed it to $sortOrder and $sortByand it loaded in firefox just fine, but missing the table headers <xsl:template name="th"> <xsl:param name="header"/> <th> <a> <xsl:attribute name="href">?sortBy=<xsl:value-of select="$header"/>&sortOrder=<xsl:choose> <xsl:when test="$sortOrder = 'descending'">accending</xsl:when> <xsl:when test="$sortOrder = 'accending'">descending</xsl:when> </xsl:choose> </xsl:attribute> <xsl:value-of select="header"/> </a> </th></xsl:template> unfortunatly it still refuses to load in iexplore... haha, kinda sux when you make somthing that works in one browser but not the other, im guessing older versions of iexplore dont have the correct xsl processors installed like ff and safari dooo? thats just a HUGE guess haha.....so yeah here is the source folder again incase you cbf scrolling the page to find it again hehe.http://www.acousticmushroom.com/test/
  14. xander85

    XInclude

    im not exaclty sure where this template goes in the document?? <xsl:template name="th"> does it replace this sorting sting? <xsl:choose> <xsl:when test="$sortBy = 'added' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'added' and $sortOrder = 'accending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="accending" /> </xsl:apply-templates> </xsl:when> </xsl:choose> ive tried different parts of the file but cannot get it to work... also it still will not load in ie... even after i changed this &sortOrder here is the current version of the xslt file <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:param name="sortBy" select="'added'"/><xsl:param name="sortOrder" select="'descending'"/><xsl:template match="/library"> <html> <link href="library.css" rel="stylesheet" type="text/css" /> <title>acousticmushroom.com .::. music . . .</title><body> <div id="page"> <div id="header" onclick="location.href='http://www.acousticmushroom.com/blog/';" style="cursor: pointer;"/> <div id="content"> <h5> <xsl:for-each select="/library/stats"> Xander's Music Collection<br/><xsl:value-of select="updated"/> </xsl:for-each> </h5> <h6> <xsl:for-each select="/library/stats"> <p> artists - <xsl:value-of select="artists"/> . . . albums - <xsl:value-of select="albums"/> . . . songs - <xsl:value-of select="songs"/></p> <p><xsl:value-of select="playback"/></p> <p><xsl:value-of select="size"/></p> <p>mp3 albums - <xsl:value-of select="mp3"/> . . . aac albums - <xsl:value-of select="aac"/> . . . lossless albums - <xsl:value-of select="lossless"/></p> </xsl:for-each> <p>please note all dates showing 2007-08-01 are albums added to the library prior to the website, ie. i do not have a date for them... yet</p> <p>to search the library use your browsers find function (CTRL+F)</p> <p> click <a href="http://www.acousticmushroom.com/blog">here</a> to return home</p> <p> <a href="http://www.acousticmushroom.com/assets/files/library.pdf">pdf version</a> </p> </h6> <table> <tr> <th>Artist</th> <th>Album</th> <th>Source</th> <th>Kind</th> <th>Added</th> </tr> <xsl:choose> <xsl:when test="$sortBy = 'added' and $sortOrder = 'descending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="descending" /> </xsl:apply-templates> </xsl:when> <xsl:when test="$sortBy = 'added' and $sortOrder = 'accending'"> <xsl:apply-templates select="music"> <xsl:sort select="added" order="accending" /> </xsl:apply-templates> </xsl:when> </xsl:choose> </table> </div> </div> </body> </html></xsl:template><xsl:template match="music"> <tr> <td><xsl:value-of select="artist"/></td> <td><xsl:value-of select="album"/></td> <td><xsl:value-of select="source"/></td> <td><xsl:value-of select="kind"/></td> <td><xsl:value-of select="added"/></td> </tr></xsl:template></xsl:stylesheet> do you need to merge<tr><th>Artist....... blah blah etc</th></tr> and<xsl:template blah blah etc />together so it loads the links and adds the sort string?
  15. xander85

    XInclude

    SCRAP THAT haha!fixed it, i should look harder at the code before i make a post haha, sorry bout thatthe<xsl:for-each select="library/stats"> was missing the / before library, replaced with <xsl:for-each select="/library/stats">
×
×
  • Create New...