andreathedove Posted August 2, 2006 Share Posted August 2, 2006 Hello,I open a new topic.The difference to transform and reading between rss and xml with xsl? Thanks,Andrea Link to comment Share on other sites More sharing options...
boen_robot Posted August 2, 2006 Share Posted August 2, 2006 None. RSS is XML based format. XSLT reads all XML based languages. Link to comment Share on other sites More sharing options...
andreathedove Posted August 2, 2006 Author Share Posted August 2, 2006 None. RSS is XML based format. XSLT reads all XML based languages. ehmif I have- <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">- <channel> <title>iWEBTOOL.com</title> <description>iWEBTOOL's aim is to bring the net's best web tools straight to your fingertips!</description> <link>http://www.iwebtool.com</link> - <image> <url>http://www.iwebtool.com/images/logo.gif</url> <title>iWEBTOOL.com</title> <link>http://www.iwebtool.com</link> </image> <dc:language>en-us</dc:language> - <item> <title>Alexa Traffic Rank</title> <description><img src="http://www.iwebtool.com/tool/tools/alexa_traffic_rank/alexa_traffic_rank.gif" alt="Alexa Traffic Rank" />View and compare Alexa Traffic charts. You can select a data type from Reach, Rank and Page Views.</description> <icon>http://www.iwebtool.com/tool/tools/alexa_traffic_rank/alexa_traffic_rank.gif</icon> <category>Domain Checkups</category> <link>http://www.iwebtool.com/alexa_traffic_rank</link> </item>- <item>etc ...</channel></rss>and I write<xsl:for-each select="/rss/channel/item[not(category = preceding-sibling::item/category)]"> <xsl:sort select="category" data-type="text" order="ascending"/> <a class="testo" href="shopping_cat.asp?Cat={category}"><b><xsl:value-of select="category"/></b></a> <br/> </xsl:for-each>why it read the CHANNEL ?Andrea Link to comment Share on other sites More sharing options...
andreathedove Posted August 3, 2006 Author Share Posted August 3, 2006 ehmif I have- <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">- <channel> <title>iWEBTOOL.com</title> <description>iWEBTOOL's aim is to bring the net's best web tools straight to your fingertips!</description> <link>http://www.iwebtool.com</link> - <image> <url>http://www.iwebtool.com/images/logo.gif</url> <title>iWEBTOOL.com</title> <link>http://www.iwebtool.com</link> </image> <dc:language>en-us</dc:language> - <item> <title>Alexa Traffic Rank</title> <description><img src="http://www.iwebtool.com/tool/tools/alexa_traffic_rank/alexa_traffic_rank.gif" alt="Alexa Traffic Rank" />View and compare Alexa Traffic charts. You can select a data type from Reach, Rank and Page Views.</description> <icon>http://www.iwebtool.com/tool/tools/alexa_traffic_rank/alexa_traffic_rank.gif</icon> <category>Domain Checkups</category> <link>http://www.iwebtool.com/alexa_traffic_rank</link> </item>- <item>etc ...</channel></rss>and I write<xsl:for-each select="/rss/channel/item[not(category = preceding-sibling::item/category)]"> <xsl:sort select="category" data-type="text" order="ascending"/> <a class="testo" href="shopping_cat.asp?Cat={category}"><b><xsl:value-of select="category"/></b></a> <br/> </xsl:for-each>why it read the CHANNEL ?Andreain other words... can I jump the channel content ? Link to comment Share on other sites More sharing options...
boen_robot Posted August 3, 2006 Share Posted August 3, 2006 Sure... why not? Link to comment Share on other sites More sharing options...
andreathedove Posted August 3, 2006 Author Share Posted August 3, 2006 Sure... why not?what? Link to comment Share on other sites More sharing options...
boen_robot Posted August 3, 2006 Share Posted August 3, 2006 You're asking if you can jump the channel content. I'm saying you can, and I'm asking (rithorically) why wouldn't you be able to. Link to comment Share on other sites More sharing options...
andreathedove Posted August 3, 2006 Author Share Posted August 3, 2006 You're asking if you can jump the channel content. I'm saying you can, and I'm asking (rithorically) why wouldn't you be able to.How Link to comment Share on other sites More sharing options...
boen_robot Posted August 3, 2006 Share Posted August 3, 2006 Look, in the paging XML script, just change the path /*/*[name()=$pagedElement] and the such, to /*/*/*[name()=$pagedElement] or simply //*[name()=$pagedElement] And you'll have the RSS fead read.In other words, instead of reading the root element(/rss), you must read the one below it (/rss/channel) and that's it. Nothing more special.One more very frequent use case of that creature. Link to comment Share on other sites More sharing options...
andreathedove Posted August 3, 2006 Author Share Posted August 3, 2006 Look, in the paging XML script, just change the path /*/*[name()=$pagedElement] and the such, to /*/*/*[name()=$pagedElement] or simply //*[name()=$pagedElement] And you'll have the RSS fead read.In other words, instead of reading the root element(/rss), you must read the one below it (/rss/channel) and that's it. Nothing more special.One more very frequent use case of that creature. my example:http://www.bluside.it/tool/the rss file ishttp://www.bluside.it/tool/rss.xmland the xslhttp://www.bluside.it/tool/categorie.xslThe resul are[ ] Domain Checkups [ ] HTML [ ] Miscellaneous [ ] Search Engine Optimization [ ] why this ?[ ] Link to comment Share on other sites More sharing options...
boen_robot Posted August 3, 2006 Share Posted August 3, 2006 It's this portion: <xsl:for-each select="/rss/channel/item[not(category = preceding-sibling::item/category)]"> <xsl:sort select="category" data-type="text" order="ascending"/> <td bordercolor="#FFFFFF" width="200" valign="top" align="left"> <a class="testo" href="shopping_cat.asp?Cat={category}"><b><xsl:value-of select="category"/></b></a> [ ] <br/> </td> <xsl:if test="position() mod 1 = 0"> <!-- Blocco CDATA assieme a codice Javascript --> <script> <![CDATA[document.write("</tr><tr>");]]> </script> <!-- FINE Blocco CDATA assieme a codice Javascript --> </xsl:if> </xsl:for-each> You can clearly see the "[ ]" for yourself there. Simply remove them and you won't see them. But really, why do you bother with this XSLT? The paging one is so much fun. Link to comment Share on other sites More sharing options...
andreathedove Posted August 3, 2006 Author Share Posted August 3, 2006 my example:http://www.bluside.it/tool/the rss file ishttp://www.bluside.it/tool/rss.xmland the xslhttp://www.bluside.it/tool/categorie.xslThe resul are[ ] Domain Checkups [ ] HTML [ ] Miscellaneous [ ] Search Engine Optimization [ ] why this ?[ ] ehm I want thisDomain Checkups [ ] HTML [ ] Miscellaneous [ ] Search Engine Optimization [ ] but not[]Domain Checkups [ ] HTML [ ] Miscellaneous [ ] Search Engine Optimization [ ] Link to comment Share on other sites More sharing options...
boen_robot Posted August 4, 2006 Share Posted August 4, 2006 Oh, I see. Sorry. Well, it seems this is generated for the cases where the <category> element is not present.If you want to have something like "Unknown category" identfier, you should use something like: <xsl:for-each select="/rss/channel/item[not(category = preceding-sibling::item/category)]"> <xsl:sort select="category" data-type="text" order="ascending"/> <td bordercolor="#FFFFFF" width="200" valign="top" align="left"> <xsl:choose><xsl:when test="category"><a class="testo" href="shopping_cat.asp?Cat={category}"><b><xsl:value-of select="category"/></b></a></xsl:when><xsl:otherwise><a class="testo" href="shopping_cat.asp?Cat=~Unknown"><b>~Uknown~</b></a></xsl:otherwise></xsl:choose>[ ] <br/> </td> <xsl:if test="position() mod 1 = 0"> <!-- Blocco CDATA assieme a codice Javascript --> <script> <![CDATA[document.write("</tr><tr>");]]> </script> <!-- FINE Blocco CDATA assieme a codice Javascript --> </xsl:if> </xsl:for-each> And to eliminate the articles with unknown category, just use <xsl:if> instead.I can already think of a lot more elegant solution then this one, but considering the bad state of this code (tables, weird scripts, etc.) I would prefer to keep it in my own bag'o'tricks. Link to comment Share on other sites More sharing options...
andreathedove Posted August 11, 2006 Author Share Posted August 11, 2006 Oh, I see. Sorry. Well, it seems this is generated for the cases where the <category> element is not present.If you want to have something like "Unknown category" identfier, you should use something like:<xsl:for-each select="/rss/channel/item[not(category = preceding-sibling::item/category)]"> <xsl:sort select="category" data-type="text" order="ascending"/> <td bordercolor="#FFFFFF" width="200" valign="top" align="left"> <xsl:choose><xsl:when test="category"><a class="testo" href="shopping_cat.asp?Cat={category}"><b><xsl:value-of select="category"/></b></a></xsl:when><xsl:otherwise><a class="testo" href="shopping_cat.asp?Cat=~Unknown"><b>~Uknown~</b></a></xsl:otherwise></xsl:choose>[ ] <br/> </td> <xsl:if test="position() mod 1 = 0"> <!-- Blocco CDATA assieme a codice Javascript --> <script> <![CDATA[document.write("</tr><tr>");]]> </script> <!-- FINE Blocco CDATA assieme a codice Javascript --> </xsl:if> </xsl:for-each> And to eliminate the articles with unknown category, just use <xsl:if> instead.I can already think of a lot more elegant solution then this one, but considering the bad state of this code (tables, weird scripts, etc.) I would prefer to keep it in my own bag'o'tricks. how to eliminate ? how to eliminate ? with your code the result in html are<td bordercolor="#FFFFFF" width="*" valign="top" align="left"><a class="testo" href="shopping_cat.asp?Cat="><b></b></a><br></td> ...etc ...Andrea Link to comment Share on other sites More sharing options...
andreathedove Posted August 11, 2006 Author Share Posted August 11, 2006 how to eliminate ? :)with your code the result in html are<td bordercolor="#FFFFFF" width="*" valign="top" align="left"><a class="testo" href="shopping_cat.asp?Cat="><b></b></a><br></td> ...etc ...AndreaI have resolved the problem Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now