essepuntato / LODE

Live OWL Documentation Environment, to convert OWL ontologies into HTML human-readable pages.
ISC License
104 stars 55 forks source link

f:string-last-index-of fails on relative uri with slash #14

Open VladimirAlexiev opened 6 years ago

VladimirAlexiev commented 6 years ago

Input:

@base                      <http://data.businessgraph.io/>.
<status/> a skos:ConceptScheme, owl:NamedIndividual;

Note the ConceptScheme URL ends in /: I think this is a legit and often used convention for concept schemes (so one could define a prefix for it eg status:, and use it in Concept qnames, eg status:active).

Causes this error:

Type error at char 146 in xsl:variable/@select on line 1799 column 236 of extraction.xsl:
  XPTY0004: An empty sequence is not allowed as the third argument of substring()
  at xsl:apply-templates (extraction.xsl#1116)
     processing /assertions/assertion[1]/@rdf:resource
  at xsl:call-template name="get.individual.assertions" (extraction.xsl#1015)
  at xsl:call-template name="get.individual.description" (extraction.xsl#454)
  at xsl:apply-templates (extraction.xsl#1605)
     processing /rdf:RDF/owl:NamedIndividual[3]
  at xsl:call-template name="get.namedindividuals" (extraction.xsl#182)
  at xsl:call-template name="structure" (extraction.xsl#193)
  at xsl:apply-templates (extraction.xsl#105)
     processing /rdf:RDF/owl:Ontology[1]
  in built-in template rule
An empty sequence is not allowed as the third argument of substring()

The reported line is last below:

    <xsl:function name="f:getPrefixFromIRI" as="xs:string?">
        <xsl:param name="iri" as="xs:string" />

        <xsl:if test="not(starts-with($iri,'_:'))">
            <xsl:variable name="iriNew" select="if (contains($iri,'#') or contains($iri,'/')) then $iri else concat(base-uri($root), $iri)" as="xs:string" />

            <xsl:variable name="ns" select="if (contains($iriNew,'#')) then substring($iriNew,1,f:string-first-index-of($iriNew,'#')) else substring($iriNew,1,f:string-last-index-of(replace($iriNew,'://','---'),'/'))" as="xs:string" />

Maybe iriNew is to blame? It assumes that an iri with #/ is absolute. My turtle example uses a relative IRI with / but when I examine the corresponding rdf, I don't see any relative IRIs...

My XSL debugging skills are non-existent.