example that shows prov-xml may need <prov:prefix>
authorTim L <lebot@rpi.edu>
Fri, 14 Dec 2012 10:12:44 -0500
changeset 5351 d487d44e6ae6
parent 5350 4bbf3c66312e
child 5352 36f87c764618
example that shows prov-xml may need <prov:prefix>
examples/eg-43-xmlns-not-accessible/xml/eg-43-xmlns-not-accessible-with-prefixes.xml
examples/eg-43-xmlns-not-accessible/xml/eg-43-xmlns-not-accessible.xml
examples/eg-43-xmlns-not-accessible/xml/get-prefix.xsl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/eg-43-xmlns-not-accessible/xml/eg-43-xmlns-not-accessible-with-prefixes.xml	Fri Dec 14 10:12:44 2012 -0500
@@ -0,0 +1,14 @@
+<prov:document
+    xmlns:prov="http://www.w3.org/ns/prov#"
+    xmlns:ex="http://example.com/ns/ex#">
+
+  <prov:prefix prov:id="ex">http://example.com/ns/ex#</prov:prefix>
+
+  <prov:wasInvalidatedBy>
+    <prov:entity prov:ref="ex:The-Painter"/>
+    <prov:activity prov:ref="ex:crash"/>
+    <prov:time>1998-09-03T01:31:00</prov:time>
+    <ex:circumstances>plane accident</ex:circumstances>
+  </prov:wasInvalidatedBy>
+
+</prov:document>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/eg-43-xmlns-not-accessible/xml/eg-43-xmlns-not-accessible.xml	Fri Dec 14 10:12:44 2012 -0500
@@ -0,0 +1,12 @@
+<prov:document
+    xmlns:prov="http://www.w3.org/ns/prov#"
+    xmlns:ex="http://example.com/ns/ex#">
+
+  <prov:wasInvalidatedBy>
+    <prov:entity prov:ref="ex:The-Painter"/>
+    <prov:activity prov:ref="ex:crash"/>
+    <prov:time>1998-09-03T01:31:00</prov:time>
+    <ex:circumstances>plane accident</ex:circumstances>
+  </prov:wasInvalidatedBy>
+
+</prov:document>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/eg-43-xmlns-not-accessible/xml/get-prefix.xsl	Fri Dec 14 10:12:44 2012 -0500
@@ -0,0 +1,28 @@
+<xsl:transform 
+   version="2.0" 
+   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+   xmlns:prov="http://www.w3.org/ns/prov#">
+<xsl:output method="text"/>
+
+<xsl:key name="prefix" match="//prov:prefix" use="@prov:id"/>
+
+<xsl:template match="/">
+
+   <xsl:variable name="prefix" select="substring-before(//prov:entity/@prov:ref,':')"/>
+
+   <xsl:variable name="magic" select="concat('magic(',$prefix,')=http://example.com/ns/ex#')"/>
+
+   <!-- Cannot access /prov:document/@xmlns:ex using a variable-constructed XPath.
+    xsl:variable name="magic1" select="concat(prov:document/xmlns:',$prefix,')"/
+   -->
+
+   <!-- These two work, but require an addition of a <prov:prefix> element -->
+   <xsl:variable name="magic2" select="//prov:prefix[@prov:id=$prefix]"/>
+   <xsl:variable name="magic3" select="key('prefix',$prefix)"/>
+
+   <xsl:value-of select="concat('The full URI of your painting is ',
+                                $magic3,
+                                substring-after(//prov:entity/@prov:ref,':'))"/>
+</xsl:template>
+
+</xsl:transform>