Question

Good folks at stackoverflow... I am trying to create a XSLT transformation that will generate a Turtle file (RDF related). Part of that involves output of prefixed namespaces, something like this:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sap="http://www.sap.com/sapxsl"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:sap_coda="http://www.sapmantics.com/sap_coda#"
    version="1.0">

  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>' .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
...

When I try to apply the transformation, I get:

$ xsltproc zcoda_ttl_v02x.xslt zcoda_data_v02.xml > zcoda_data_v02x.ttl | x.txt
zcoda_ttl_v02x.xslt:10: namespace error : Failed to parse QName 'http:'
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>' .
                    ^
zcoda_ttl_v02x.xslt:10: parser error : error parsing attribute name
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>' .
                    ^
zcoda_ttl_v02x.xslt:10: parser error : attributes construct error
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>' .
                    ^
zcoda_ttl_v02x.xslt:10: parser error : Couldn't find end of Start Tag http: line 10
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>' .

So, I am at a loss here. The Turtle output that I seek contains many of these cases. Is there some way to stop the processor and just consider the http... as plain data (like the CDATA option in xml) ? Thanks, John

Was it helpful?

Solution

Use entities:

@prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;' .
@prefix owl: &lt;http://www.w3.org/2002/07/owl#&gt; .
@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt; .

OTHER TIPS

You can enclose the http stuff in an xsl:text i guess:

 <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:sap="http://www.sap.com/sapxsl" 
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
                xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
                xmlns:sap_coda="http://www.sapmantics.com/sap_coda#" 
                version="1.0">

  <xsl:strip-space elements="*"/>

  <xsl:template match="/">
@prefix rdfs: <xsl:text><![CDATA[<http://www.w3.org/2000/01/rdf-schema#>]]></xsl:text>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top