Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Parsing RDF (Rss 1.0) with XSLT to get channel/title

Posted on 2005-05-04
1
Medium Priority
?
443 Views
Last Modified: 2013-11-18
Everything works great in my XSLT to parse through the RDF document except for getting the channel/title.

The xpath I've used is "//channel/title", "//channel/title/text()", "rdf:RDF/channel/title",
"rdf:RDF/channel/title/text()", "rss:channel/rss:title" etc...

I cant seem to get the document title to display.  When I test my xpath in xmlspy they test correct.

Can someone please help.


RDF Document: Snip
************************************
<?xml version="1.0" encoding="iso-8859-1" ?>
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
 <channel rdf:about="http://www.coattails.net/wow/wow_alerts.php">
  <title>World of Warcraft Community Alerts</title>
  <link>http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status</link>
  <description>World of Warcraft Alerts newsfeed by Belatucadros for Coattails.net - Original alerts (c) Blizzard.com.</description>
  <dc:language>en</dc:language>
  <dc:publisher>Feed (c) Coattails (www.coattails.net)</dc:publisher>
  <dc:creator>Feed created and maintained by Belatucadros (did all the work)(belatucadros@coattails.net) and Taggart (not so much)(omg@wtfpwn.net).</dc:creator>
 <items>
 <rdf:Seq>
  <rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#1" />
  <rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#2" />
  <rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#3" />
  <rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#4" />
  <rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#5" />
  </rdf:Seq>
  </items>
  </channel>


XSLT
******************************
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="rdf rss l dc admin content xsl"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                xmlns:rss="http://purl.org/rss/1.0/"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:admin="http://webns.net/mvcb/"
                xmlns:l="http://purl.org/rss/1.0/modules/link/"
                xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <xsl:output omit-xml-declaration="yes"/>
    <xsl:template match="/rdf:RDF">
            <br/>
            <div style="width:50%;">
                  <xsl:attribute name="style">font-size: 10pt;</xsl:attribute>
                  <xsl:attribute name="id">title</xsl:attribute>
                  <a>
                        <xsl:attribute name="href">#</xsl:attribute>
                        <xsl:attribute name="style">underline: none;font-weight: bold;</xsl:attribute>
                        <xsl:attribute name="onClick">display('content:<xsl:value-of select="rdf:RDF/channel/title" />');</xsl:attribute>
                        <xsl:value-of select="rdf:RDF/channel/title" />
                  </a>
            </div>
        <div style="width:50%;">
        <xsl:attribute name="id">content:<xsl:value-of select="rdf:RDF/channel/title" /></xsl:attribute>
        <xsl:for-each select="rss:item">    
            <div style="clear:left;">        
                <a class="headlines">        
                    <xsl:attribute name="href">            
                        <xsl:value-of select="@rdf:about"/>        
                    </xsl:attribute>        
                    <xsl:value-of select="rss:title"/>        
                </a>
                <br/>  
                <xsl:value-of disable-output-escaping="yes" select="rss:description"/>
                <br/>
                <span class="date">
                    <xsl:value-of select="dc:creator"/>
                </span>
            </div>  
            <hr/>
        </xsl:for-each>
        </div>
    </xsl:template>
</xsl:stylesheet>
0
Comment
Question by:raizon
1 Comment
 
LVL 23

Accepted Solution

by:
b1xml2 earned 2000 total points
ID: 13932322
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">


</rdf:RDF>

please note. on one hand, you are using the rdf (rdf:RDF) namespace, but you are also saying that the default namespace is xmlns="http://purl.org/rss/1.0/"

Xml
==
<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel rdf:about="http://www.coattails.net/wow/wow_alerts.php">
<title>World of Warcraft Community Alerts</title>
<link>http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status</link>
<description>World of Warcraft Alerts newsfeed by Belatucadros for Coattails.net - Original alerts (c) Blizzard.com.</description>
<dc:language>en</dc:language>
<dc:publisher>Feed (c) Coattails (www.coattails.net)</dc:publisher>
<dc:creator>Feed created and maintained by Belatucadros (did all the work)(belatucadros@coattails.net) and Taggart (not so much)(omg@wtfpwn.net).</dc:creator>
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#1" />
<rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#2" />
<rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#3" />
<rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#4" />
<rdf:li rdf:resource="http://forums.worldofwarcraft.com/board.aspx?fn=wow-realm-status#5" />
</rdf:Seq>
</items>
</channel>
</rdf:RDF>

Xslt
===
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="rdf rss l dc admin content xsl"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                xmlns:rss="http://purl.org/rss/1.0/"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:admin="http://webns.net/mvcb/"
                xmlns:l="http://purl.org/rss/1.0/modules/link/"
                xmlns:content="http://purl.org/rss/1.0/modules/content/">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/rdf:RDF">
            <br/>
        <div style="width:50%;">
            <xsl:attribute name="style">font-size: 10pt;</xsl:attribute>
            <xsl:attribute name="id">title</xsl:attribute>
            <a>
                <xsl:attribute name="href">#</xsl:attribute>
                <xsl:attribute name="style">underline: none;font-weight: bold;</xsl:attribute>
                <xsl:attribute name="onClick">display('content:<xsl:value-of select="channel/title" />');</xsl:attribute>
                <xsl:value-of select="channel/title" />
            </a>
        </div>
</xsl:template>
</xsl:stylesheet>

Html Output
========
<br />
<div style="font-size: 10pt;" id="title">
<a href="#" style="underline: none;font-weight: bold;" onClick="display('content:World of Warcraft Community Alerts');">World of Warcraft Community Alerts</a>
</div>



0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question