1

this is the excerpt of the XML file.

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

      <rdf:Description rdf:about="http://abc.org/JohnD">
        <foaf:interest xml:lang="en" xmlns:foaf="http://xmlns.com/foaf/0.1/">games</foaf:interest>
      </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.

2
  • Is the rdf namespace declared in your Xml document and stylesheet? Everything you have here looks correct except for an xmlns:rdf="..." Commented Mar 7, 2010 at 15:05
  • I have declared every namespace needed. Because if not, the ASP.net application which the XSL is linked to will throw in an exception. Commented Mar 7, 2010 at 15:44

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.