tags:

views:

40

answers:

1

this is the excerpt of the XML file.

<rdf:RDF>
        <rdf:Description rdf:about="http://abc.org/JohnD"&gt;
            <video:Movie xml:lang="en" xmlns:video="http://example.org/movie"&gt;Avatar&lt;/video:Movie&gt;
          </rdf:Description>

      <rdf:Description rdf:about="http://abc.org/JohnD"&gt;
        <foaf:interest xml:lang="en" xmlns:foaf="http://xmlns.com/foaf/0.1/"&gt;games&lt;/foaf:interest&gt;
      </rdf:Description>

</rdf:RDF>

the XSL excerpt

<xsl:template match="rdf:RDF/rdf:Description">
   <xsl:value-of select="video:Movie"/>
</xsl:template>

I want to select the literal "Avatar" from the node with the name <video:Movie> only

I ve tried using <xsl:value-of select="video:Movie"/> and various other combination, but it just won't display. I have declared the namespace accordingly in the XSL header.

+1  A: 

The following code selects the element irrespective of the namespace url:

<xsl:template match="rdf:RDF/rdf:Description">
   <xsl:value-of select="*[name() = 'video:Movie']"/>
</xsl:template>

But if all the namespaces are correct the code you provided should work, I just tested it with the following XSLT (note the video namespace on top of the XSLT).

<xsl:stylesheet 
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:video="http://example.org/movie" 
>
    <xsl:output method="html"/>

        <xsl:template match="rdf:RDF/rdf:Description">
            <xsl:apply-templates select="video:Movie"/>
        </xsl:template>
</xsl:stylesheet>
Obalix