Hi,
A couple of weeks I sent an e-mail about a problem I encountered while
parsing XML Literals but didn't get a reply so let me try to explain the
problem in more detail. I have bunch of web service descriptions written
in OWL-S. Each OWL-S description has a grounding part where each service
parameter may have an XSLT transformation associated with it. These XSLT
descriptions are given as XML literals where the value of the literal is
a complete XSLT stylesheet. A simplified example looks like this:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:grounding="http://www.daml.org/services/owl-s/1.0/Grounding.owl#">
<grounding:Grounding>
<grounding:xsltTransformation rdf:parseType="Literal">
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://www.example.org/test#">
<xsl:template match="/">
<xsl:variable name="X1" select="//ns1:SomeThing"/>
<output>
<xsl:value-of select="$X1"/>
</output>
</xsl:template>
</xsl:stylesheet>
</grounding:xsltTransformation>
</grounding:Grounding>
</rdf:RDF>
The interesting thing here is the stylesheet defines a namespace with
prefix "ns1" but the usage of this namespace is not obvious because it
is somewhat hidden inside an attribute value. When I parse this file
with Jena, the literal value I get does not have the namespace
declaration for "ns1" and looks like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:variable name="X1" select="//ns1:SomeThing"></xsl:variable>
<output>
<xsl:value-of select="$X1"></xsl:value-of>
</output>
</xsl:template>
</xsl:stylesheet>
This is not a valid XSLT stylesheet anymore and cannot be used. The hack
I found to get around this is to add something to the XML literal that
uses the namespace ns1. An element <ns1:dummy/> or an attribute like
ns1:dummy="" brings back the namespace declaration like this:
<xsl:stylesheet xmlns:ns1="http://www.example.org/test#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ns1:dummy=""
version="1.0">
<xsl:template match="/">
<xsl:variable name="X1" select="//ns1:SomeThing"></xsl:variable>
<output>
<xsl:value-of select="$X1"></xsl:value-of>
</output>
</xsl:template>
</xsl:stylesheet>
What I'd like to learn is if it is possible to get the correct literal
value without adding dummy attributes. I thought this problem (dropping
unused namespaces) could be related to Xerces parsing but I couldn't
find anything relevant in the parser documentation. I'd appreciate if
you have any ideas or suggestions.
Thanks,
Evren
---
Evren Sirin evren@...
Graduate Research Assistant
Computer Science Department
Univ of Maryland, College Park, MD 20742
Phone: (301) 405-7027, Fax: (301) 405-6707