Hi,
I'm trying to run an xsl script from within Virtuoso that I've successfully
run externally within a php class.
When run within Virtuoso I get the following error.
SQLState: 22007
Message: XM003: XML parser detected an error:
ERROR : 37000 XM028: XPath interpreter, line 1: Namespace prefix has
been used already for other namespace URI
in the following expression:
/ in / in attribute match of tag
http://www.w3.org/1999/XSL/Transform:template in line 38 of file
virt://WS.WS.SYS_DAV_RES.RES_FULL_PATH.RES_CONTENT:/DAV/VAD/rdf_mappers/xslt/main/xml2rdf25.xsl
at line 38 column 33 of
'virt://WS.WS.SYS_DAV_RES.RES_FULL_PATH.RES_CONTENT:/DAV/VAD/rdf_mappers/xslt/main/xml2rdf25.xsl'
<xsl:template match="/">
-------------------------------^
The query I run to cause this error is -
select xslt (registry_get ('_rdf_mappers_path_') ||
'xslt/main/xml2rdf25.xsl', xtree_doc(file_to_string
('/usr/local/virtuoso-opensource/var/lib/virtuoso/db/dummy.xml')));
The xsl file and dummy xml file are attached. Would someone be able to
explain why Virtuoso doesn't like it?
Cheers
Mark
<output><person><personId xmlns:n2="http://jim.jis.sa.gov.au/xmlschema/partymodel/v3"><jisPin>21528</jisPin></personId></person></output>
<?xml version="1.0" encoding="UTF-8"?>
<!-- xml2rdf25.xsl XSLT stylesheet to transform XML into RDF/XML
Version 2.5 (2009-05-19)
Changes to V2.4 added BaseURI variable and comments template
Web page http://www.gac-grid.org/project-products/Software/XML2RDF.html
Usage xsltproc xml2rdf25.xsl file.xml
Author Frank Breitling (fbreitling at aip.de)
Copyright 2009 AstroGrid-D (http://www.gac-grid.org/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->
<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:xs="http://www.w3.org/2001/XMLSchema#">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="BaseURI">http://www.totalmetrics.com/ontology/benchmark</xsl:param>
<!-- Define if not completed by application-->
<!-- http://www.exampleURI.net/STELLA-I -->
<xsl:param name="SubjectURI">http://test_data.com/extract</xsl:param>
<!-- Define if not completed by application-->
<!-- http://www.exampleURI.net/STELLA-I -->
<!-- Begin RDF document -->
<xsl:template match="/">
<xsl:element name="rdf:RDF">
<rdf:Description>
<xsl:attribute name="rdf:about"/>
<xsl:apply-templates select="*/*|*/@*|comment()"/>
</rdf:Description>
</xsl:element>
</xsl:template>
<!-- Turn XML elements into RDF triples. -->
<xsl:template match="*">
<xsl:param name="subjectname"/>
<!-- Build unique subject name from acestors elements and
a number in case of sibling elements with same name. -->
<xsl:variable name="newsubjectname">
<xsl:if test="$subjectname=''">
<xsl:value-of select="$SubjectURI"/>
<xsl:text>/</xsl:text>
</xsl:if>
<xsl:value-of select="$subjectname"/>
<xsl:value-of select="name()"/>
<xsl:variable name="number">
<xsl:number/>
</xsl:variable>
<xsl:if test="$number > 1">
<xsl:number/>
</xsl:if>
</xsl:variable>
<!--Defining new variable 'Parentcurrent' to join current and parent node -->
<xsl:variable name='parentcurrent'>
<xsl:choose>
<!--<xsl:when test="name(..) = 'BenchmarkSubmissionPeriod'">-->
<xsl:when test="(count(ancestor::*) >= 2) and (count(descendant::*) >= 1)">
<xsl:value-of select="name(..)"/>
<xsl:text>Has</xsl:text>
<xsl:value-of select="name()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--xsl:element name="{name()}" namespace="{namespace-uri()}"-->
<!--<xsl:element name="{name()}" namespace="{concat($BaseURI,'/')}">-->
<xsl:element name="{$parentcurrent}" namespace="{concat($BaseURI,'/')}">
<xsl:choose>
<xsl:when test="count(./@*)+count(*) > 0">
<rdf:Description>
<xsl:attribute name="rdf:about">
<xsl:value-of select="$newsubjectname"/>
</xsl:attribute>
<rdf:type>
<xsl:attribute name="rdf:resource">
<xsl:value-of select="concat($BaseURI,'/',name())"/>
</xsl:attribute>
</rdf:type>
<!--Adding Child Of parent -->
<xsl:if test="(count(ancestor::*) >= 2) and (count(descendant::*) >= 1)">
<xsl:variable name='currentparent'>
<xsl:value-of select="name()"/>
<xsl:text>Of</xsl:text>
<xsl:value-of select="name(..)"/>
</xsl:variable>
<xsl:element name="{$currentparent}" namespace="{concat($BaseURI,'/')}">
<xsl:attribute name="rdf:resource">
<xsl:value-of select="substring($subjectname,1,string-length($subjectname)-1)"/>
</xsl:attribute>
</xsl:element>
</xsl:if>
<xsl:apply-templates select="@*|node()">
<xsl:with-param name="subjectname"
select="concat($newsubjectname,'/')"/>
</xsl:apply-templates>
</rdf:Description>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="@*|node()">
<xsl:with-param name="subjectname"
select="$newsubjectname"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- Create attribute triples. -->
<xsl:template match="@*" name="attributes">
<xsl:variable name="ns">
<!-- If attribute doesn't have a namespace use element namespace -->
<xsl:choose>
<xsl:when test="namespace-uri()=''">
<xsl:value-of select="concat($BaseURI,'/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($BaseURI,'/')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{name()}" namespace="{$ns}">
<xsl:choose>
<xsl:when test="name()='uref'">
<xsl:attribute name="rdf:resource">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- Preserve comments. -->
<xsl:template match="comment()">
<xsl:comment>
<xsl:value-of select="."/>
</xsl:comment>
</xsl:template>
</xsl:stylesheet>