Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3356718
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:32:48+00:00 2026-05-18T02:32:48+00:00

I am trying to transform an RDF file to HTML using XSLT. I am

  • 0

I am trying to transform an RDF file to HTML using XSLT.

I am using the template that i’ve found on the web:
http://snippets.dzone.com/posts/show/1164

<?xml version="1.0" encoding="utf-8"?>
<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:dc="http://purl.org/dc/elements/1.1/"
  xmlns:foo="http://purl.org/rss/1.0/">
    <xsl:output method="html"/>
    <xsl:template match="/">
        <xsl:apply-templates select="/rdf:RDF/foo:channel"/>
    </xsl:template>
    <xsl:template match="/rdf:RDF/foo:channel">
        <h3><xsl:value-of select="foo:title"/></h3>
        <p><xsl:value-of select="foo:description"/></p>
        <ul>
            <xsl:apply-templates select="/rdf:RDF/foo:item"/>
        </ul>
    </xsl:template>
    <xsl:template match="/rdf:RDF/foo:item">
        <li>
            <a href="{foo:link}" title="{substring(dc:date, 0, 11)}"><xsl:value-of select="foo:title"/></a>
            <p><xsl:value-of select="foo:description" disable-output-escaping="yes" /></p>
        </li>
    </xsl:template>
</xsl:stylesheet>

It works perfectly with an RDF file like that:
(Here is the link to the complete file)
http://dl.dropbox.com/u/2232733/rdfexample.xml

<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/1.2" -->
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
>
<channel rdf:about="http://www.wasab.dk/morten/blog/rdf">
    <title>Binary Relations</title>
    <link>http://www.wasab.dk/morten/blog</link>
    <description>Reflections on the web</description>
    <dc:language>en</dc:language>
    <dc:date>2004-05-29T23:02:37Z</dc:date>
    <admin:generatorAgent rdf:resource="http://wordpress.org/?v=1.2"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <items>
<rdf:Seq>
<rdf:li rdf:resource="http://www.wasab.dk/morten/blog/archives/2004/05/30/wordpress-plugin-linkifier"/>
...
<rdf:li rdf:resource="http://www.wasab.dk/morten/blog/archives/2004/05/20/yet-another-semweb-blogger"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="http://www.wasab.dk/morten/blog/archives/2004/05/30/wordpress-plugin-linkifier">
    <title>WordPress Plugin: Linkifier</title>

However, I can’t make it work for an RDF\XML that i get from lastfm.rdfize.com/:
(here is the link for the file)
http://dl.dropbox.com/u/2232733/metallica_rdf_xml.xml

It has a different structure and I can’t figure out what tags in XSTL should i use to make an HTML from it:

rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:terms="http://purl.org/dc/terms/"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:owl="http://www.w3.org/2002/07/owl#"
  xmlns:mo="http://purl.org/ontology/mo/"
  xmlns:ov="http://open.vocab.org/terms/"
  xmlns:event="http://purl.org/NET/c4dm/event.owl#"
  xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
  xmlns:v="http://www.w3.org/2006/vcard/ns#">

  <rdf:Description rdf:about="http://lastfm.rdfize.com/artists/Metallica">
    <rdf:type rdf:resource="http://purl.org/ontology/mo/MusicArtist"/>
    <rdfs:label>Metallica</rdfs:label>
  ...

So my question is – how should I form an XSLT to process my RDF?
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:32:48+00:00Added an answer on May 18, 2026 at 2:32 am

    Your main problem is that your stylesheet is far too domain specific. RDF/XML is a very complex serialization that allows multiple ways of stating things. Your stylesheet is referring to very specific element names which are only valid in a very narrow range of RDF/XML documents e.g.

    <xsl:template match="/rdf:RDF/foo:item">
    

    The above attempts to match the root level <rdf:RDF> elements which is actually not mandatory – it’s acceptable for alternative root elements to be used or for <rdf:RDF> to be embedded inside other XML elements provided there is only one.

    Then it attempts to match the <foo:item> element which is a document specific ID, this element name could be absolutely anything from the general <rdf:Description> to the previous example.

    Solution

    Don’t attempt to transform RDF/XML with a stylesheet as invariably any stylesheet you write which can transform a full range of RDF/XML documents will be so ridicously complex as to make no sense whatsoever.

    Instead find yourself a good RDF library (there’s one/more out there for most major languages) which provides an RDF/XML parser and a HTML or HTML+RDFa writer and use those. If you want to control the HTML output as a base use the library’s HTML writer as a guide and adapt it or just apply a CSS stylesheet over its output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to query an xml file using the following xslt: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I have the following line of xml that I'm trying transform using XSLT but
I'm trying to transform some XML into HTML using XSLT . Problem: I can't
I am trying to transform a .html document using xslt. The generated html for
I'm trying to have a script automatically transform an xml file into several html
I'm trying to transform some XML-data to HTML with XSLT for my bachelor thesis.
I am using lxml 2.2.8 and trying to transform some existing html files into
I am trying to transform XML file twice with different XSLT files (Two step
I am trying to transform an xml file with xsl stylesheet into html. this
I’ve been trying to transform some simple XML into another simple XML using XSLT.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.