| | |
1 |
PropAttr-1 |
Match non-rdf attribute, and convert into propertyElt production. |
<$tag $prop=$val $attrs…>
$body…
</$tag>
|
<$tag $attrs…>
<$prop
>$val</$prop>
$body…
</$tag>
|
When: |
$prop!~"rdfx:*"; $prop!~"rdf:*"; $prop!~"xml:*"; |
<xsl:template match=
"*[@*[not(namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
or namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
or namespace-uri()=
'http://www.w3.org/XML/1998/namespace')]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="prop" select=
"./@*[not(namespace-uri()=$z-rdfx
or namespace-uri()=$z-rdf
or namespace-uri()=$z-xml)]
[1]"/>
<xsl:variable name="val" select="$prop"/>
<xsl:variable name="attrs" select=
"./@*[generate-id()!=generate-id($prop)]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:element name="{name($prop)}"
namespace="{namespace-uri($prop)}">
<xsl:value-of select="$val"/>
</xsl:element>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
2 |
PropAttr-2 |
|
<$tag rdf:type=$val $attrs…>
$body…
</$tag>
|
<$tag $attrs…>
<rdf:type rdf:resource=$val/>
$body…
</$tag>
|
Implicitly |
each $attrs≠"rdf:type"; |
<xsl:template match="*[@rdf:type]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="val" select="./@rdf:type"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='type'))]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<rdf:type rdf:resource="{$val}"/>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
3 |
PropAttr-3 |
Match rdf attribute for which PropAttr-1 rule applies. |
<$tag $prop=$val $attrs…>
$body…
</$tag>
|
<$tag $attrs…>
<$prop
>$val</$prop>
$body…
</$tag>
|
When: |
$prop~"rdf:*"; $prop≠"rdf:bagID"; $prop≠"rdf:ID"; $prop≠"rdf:about"; $prop≠"rdf:aboutEach"; $prop≠"rdf:type"; |
<xsl:template match=
"*[@rdf:*[not(local-name()='bagID'
or local-name()='ID'
or local-name()='about'
or local-name()='aboutEach'
or local-name()='type')]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="prop" select=
"./@rdf:*[not(local-name()='bagID'
or local-name()='ID'
or local-name()='about'
or local-name()='aboutEach'
or local-name()='type')]
[1]"/>
<xsl:variable name="val" select="$prop"/>
<xsl:variable name="attrs" select=
"./@*[generate-id()!=generate-id($prop)]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:element name="{name($prop)}"
namespace="{namespace-uri($prop)}">
<xsl:value-of select="$val"/>
</xsl:element>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
4 |
TypedNode |
Match typedNode rule and convert into description with rdf:type propertyElt. |
<$tag $attrs…>
$body…
</$tag>
|
<rdf:Description $attrs…>
<rdf:type rdf:resource=$tag/>
$body…
</rdf:Description>
|
When: |
$tag≠"rdf:Description"; |
<xsl:template match=
"*[not(self::rdf:Description)]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select="./node()"/>
<rdf:Description>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<rdf:type
rdf:resource="{concat(namespace-uri($tag),local-name($tag))}"/>
<xsl:copy-of select="$body"/>
</rdf:Description>
</xsl:template> |
5 |
about |
Map an rdf:about into rdfx:subject. |
<$tag rdf:about=$about $attrs…>
$body…
</$tag>
|
<$tag rdfx:subject=$about
rdfx:scope='URI' $attrs…>
$body…
</$tag>
|
Implicitly |
each $attrs≠"rdfx:subject"; each $attrs≠"rdf:about"; each $attrs≠"rdfx:scope"; |
<xsl:template match=
"*[@rdf:about]
[not(@rdfx:subject)]
[not(@rdfx:scope)]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="about" select="./@rdf:about"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$about"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>URI</xsl:text>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
6 |
aboutEach |
Map an rdf:aboutEach into rdfx:subject. |
<$tag rdf:aboutEach=$about
$attrs…>
$body…
</$tag>
|
<$tag rdfx:scope='Collection'
rdfx:subject=$about
$attrs…>
$body…
</$tag>
|
Implicitly |
each $attrs≠"rdfx:subject"; each $attrs≠"rdfx:scope"; each $attrs≠"rdf:aboutEach"; |
<xsl:template match=
"*[@rdf:aboutEach]
[not(@rdfx:subject)]
[not(@rdfx:scope)]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="about" select="./@rdf:aboutEach"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope')
or (namespace-uri()=$z-rdf
and local-name()='aboutEach'))]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>Collection</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$about"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
7 |
bNode |
On a description with no identifier, add an rdfx:subject |
<$tag $attrs…>
$body…
</$tag>
|
<$tag rdfx:subject='_:{generate-id()}'
rdfx:scope='bNode'
$attrs…>
$body…
</$tag>
|
When: |
each $attrs≠"rdf:ID"; each $attrs≠"rdf:about"; each $attrs≠"rdfx:subject"; each $attrs≠"rdf:aboutEach"; |
Implicitly |
each $attrs≠"rdfx:scope"; |
<xsl:template match=
"*[not(@rdf:ID)]
[not(@rdfx:subject)]
[not(@rdf:about)]
[not(@rdf:aboutEach)]
[not(@rdfx:scope)]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope')
or (namespace-uri()=$z-rdf
and local-name()='aboutEach'))]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:text>_:</xsl:text>
<xsl:value-of select=
"concat('n',$iteration)"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>bNode</xsl:text>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
8 |
ID |
Map an rdf:ID into rdfx:subject. |
<$tag rdf:ID=$id $attrs…>
$body…
</$tag>
|
<$tag rdfx:scope='URI'
rdfx:subject='#{$id}'
$attrs…>
$body…
</$tag>
|
Implicitly |
each $attrs≠"rdf:ID"; each $attrs≠"rdfx:subject"; each $attrs≠"rdfx:scope"; |
<xsl:template match=
"*[@rdf:ID]
[not(@rdfx:subject)]
[not(@rdfx:scope)]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="id" select="./@rdf:ID"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="body" select="./node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>URI</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:text>#</xsl:text>
<xsl:value-of select="$id"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
9 |
parseTypeResource |
Match propertyElt with parseType=Resource and simplify. |
<$tag $attrs…>
<$propElt rdf:ID=?$ID
rdf:parseType='Resource'
rdfx:reify=?$reify
rdfx:reifyScope=?$reifyScope>
$propEltBody…
</$propElt>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdfx:reify=?$reify
rdf:ID=?$ID>
<rdf:Description>
$propEltBody…
</rdf:Description>
</$propElt>
$body…
</$tag>
|
<xsl:template match=
"*[*[1]
[@rdf:parseType='Resource']
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='parseType')
or (namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify'))])]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="propEltBody" select="./*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<rdf:Description>
<xsl:copy-of select="$propEltBody"/>
</rdf:Description>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
10 |
propertyEltWithPropAttrs |
Match propertyElt with propAttrs or bagID . |
<$tag $attrs…>
<$propElt rdf:ID=?$ID
rdfx:reify=?$reify
rdf:resource=?$about
rdfx:reifyScope=?$reifyScope
$attr=$value
$propEltAttrs…/>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdf:ID=?$ID
rdfx:reify=?$reify>
<rdf:Description
rdf:about=?$about
$attr=$value
$propEltAttrs…/>
</$propElt>
$body…
</$tag>
|
When: |
$attr!~"rdfx:*"; each $propEltAttrs!~"rdfx:*"; |
Implicitly |
$attr≠"rdf:ID"; $attr≠"rdf:about"; $attr≠"rdfx:reifyScope"; $attr≠"rdf:resource"; $attr≠"rdfx:reify"; each $propEltAttrs≠"rdf:ID"; each $propEltAttrs≠"rdf:about"; each $propEltAttrs≠"rdfx:reifyScope"; each $propEltAttrs≠"rdf:resource"; each $propEltAttrs≠"rdfx:reify"; |
<xsl:template match=
"*[*[1]
[@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
or (namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='about')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='resource')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify'))]]
[not(@rdfx:*[not(rdfx:reify)]
[not(rdfx:reifyScope)])]
[not(@rdf:about)]
[not(*)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="about" select=
"./*[1]/@rdf:resource"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="attr" select=
"./*[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or namespace-uri()=$z-rdfx
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='reifyScope')
or (namespace-uri()=$z-rdf
and local-name()='resource')
or (namespace-uri()=$z-rdfx
and local-name()='reify'))]
[1]"/>
<xsl:variable name="value" select="$attr"/>
<xsl:variable name="propEltAttrs" select=
"./*[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or namespace-uri()=$z-rdfx
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='reifyScope')
or (namespace-uri()=$z-rdf
and local-name()='resource')
or (namespace-uri()=$z-rdfx
and local-name()='reify'))]
[generate-id()!=generate-id($attr)]"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<rdf:Description>
<xsl:if test="$about">
<xsl:attribute name="rdf:about" namespace="{$z-rdf}">
<xsl:value-of select="$about"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="{name($attr)}"
namespace="{namespace-uri($attr)}">
<xsl:value-of select="$value"/>
</xsl:attribute>
<xsl:for-each select="$propEltAttrs">
<xsl:copy/>
</xsl:for-each>
</rdf:Description>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
11 |
propertyEltWithResource |
Match propertyElt with rdf:resource . |
<$tag $attrs…>
<$propElt
rdf:resource=$about
rdf:ID=?$ID
rdfx:reifyScope=?$reifyScope
rdfx:reify=?$reify
$propEltAttrs…/>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdfx:reify=?$reify
rdf:ID=?$ID>
<rdf:Description
rdf:about=$about
$propEltAttrs…/>
</$propElt>
$body…
</$tag>
|
Implicitly |
each $propEltAttrs≠"rdf:ID"; each $propEltAttrs≠"rdf:about"; each $propEltAttrs≠"rdfx:reifyScope"; each $propEltAttrs≠"rdf:resource"; each $propEltAttrs≠"rdfx:reify"; |
<xsl:template match=
"*[*[1]
[@rdf:resource]
[not(@rdf:about)]
[not(*)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="about" select=
"./*[1]/@rdf:resource"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="propEltAttrs" select=
"./*[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='reifyScope')
or (namespace-uri()=$z-rdf
and local-name()='resource')
or (namespace-uri()=$z-rdfx
and local-name()='reify'))]"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<rdf:Description rdf:about="{$about}">
<xsl:for-each select="$propEltAttrs">
<xsl:copy/>
</xsl:for-each>
</rdf:Description>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
12 |
Flattening |
Remove nested description or typedNode from first propertyElt. |
<$tag $attrs…>
<$propElt rdfx:reify=?$reify
rdfx:reifyScope=?$reifyScope
rdf:ID=?$ID>
<$object rdfx:subject=$about
rdfx:scope=$scope
$objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
<$object rdfx:subject=$about
rdfx:scope=$scope
$objAttrs…>
$objBody…
</$object>
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdfx:reify=?$reify
rdf:ID=?$ID
rdfx:object=$about
rdfx:scope=$scope/>
$body…
</$tag>
|
Implicitly |
each $objAttrs≠"rdfx:subject"; each $objAttrs≠"rdfx:scope"; |
<xsl:template match=
"*[*[1]
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify'))])]
[*[last()=1]]
[*[1]
[@rdfx:subject]
[@rdfx:scope]]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="object" select="./*[1]/*[1]"/>
<xsl:variable name="about" select=
"./*[1]/*
[1]/@rdfx:subject"/>
<xsl:variable name="scope" select=
"./*[1]/*
[1]/@rdfx:scope"/>
<xsl:variable name="objAttrs" select=
"./*[1]/*
[1]/@*
[not((namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="objBody" select="./*[1]/*[1]/node()"/>
<xsl:for-each select="$object">
<xsl:copy>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$about"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$scope"/>
</xsl:attribute>
<xsl:for-each select="$objAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$objBody"/>
</xsl:copy>
</xsl:for-each>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="rdfx:object" namespace="{$z-rdfx}">
<xsl:value-of select="$about"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$scope"/>
</xsl:attribute>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
13 |
PreFlatteningBNode |
Add a bNode name to nested description or typedNode of first propertyElt. |
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdf:ID=?$ID
rdfx:reify=?$reify>
<$object $objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdfx:reify=?$reify
rdf:ID=?$ID>
<$object rdfx:scope='bNode'
rdfx:subject='_:{generate-id()}'
$objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
When: |
each $objAttrs≠"rdf:ID"; each $objAttrs≠"rdf:about"; each $objAttrs≠"rdfx:subject"; each $objAttrs≠"rdf:aboutEach"; |
Implicitly |
each $objAttrs≠"rdfx:scope"; |
<xsl:template match=
"*[*[1]
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify'))])]
[*[last()=1]]
[*[1]
[not(@rdf:ID)]
[not(@rdfx:subject)]
[not(@rdf:about)]
[not(@rdf:aboutEach)]
[not(@rdfx:scope)]]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="object" select="./*[1]/*[1]"/>
<xsl:variable name="objAttrs" select=
"./*[1]/*
[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope')
or (namespace-uri()=$z-rdf
and local-name()='aboutEach'))]"/>
<xsl:variable name="objBody" select="./*[1]/*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="$object">
<xsl:copy>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>bNode</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:text>_:</xsl:text>
<xsl:value-of select=
"concat('n',$iteration)"/>
</xsl:attribute>
<xsl:for-each select="$objAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$objBody"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
14 |
PreFlatteningID |
Change an rdf:ID to an rdfx:subject in a nested description or typedNode of first propertyElt. |
<$tag $attrs…>
<$propElt rdfx:reify=?$reify
rdf:ID=?$ID
rdfx:reifyScope=?$reifyScope>
<$object rdf:ID=$nestedID
$objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdf:ID=?$ID
rdfx:reify=?$reify>
<$object rdfx:scope='URI'
rdfx:subject='#{$nestedID}'
$objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
Implicitly |
each $objAttrs≠"rdf:ID"; each $objAttrs≠"rdfx:subject"; each $objAttrs≠"rdfx:scope"; |
<xsl:template match=
"*[*[1]
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify'))])]
[*[last()=1]]
[*[1]
[@rdf:ID]
[not(@rdfx:subject)]
[not(@rdfx:scope)]]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="object" select="./*[1]/*[1]"/>
<xsl:variable name="nestedID" select="./*[1]/*[1]/@rdf:ID"/>
<xsl:variable name="objAttrs" select=
"./*[1]/*
[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="objBody" select="./*[1]/*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="$object">
<xsl:copy>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>URI</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:text>#</xsl:text>
<xsl:value-of select="$nestedID"/>
</xsl:attribute>
<xsl:for-each select="$objAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$objBody"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
15 |
PreFlatteningAbout |
Change an rdf:about to an rdfx:subject in a nested description or typedNode of first propertyElt. |
<$tag $attrs…>
<$propElt rdf:ID=?$ID
rdfx:reify=?$reify
rdfx:reifyScope=?$reifyScope>
<$object rdf:about=$about
$objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope=?$reifyScope
rdf:ID=?$ID
rdfx:reify=?$reify>
<$object rdfx:scope='URI'
rdfx:subject=$about
$objAttrs…>
$objBody…
</$object>
</$propElt>
$body…
</$tag>
|
Implicitly |
each $objAttrs≠"rdfx:subject"; each $objAttrs≠"rdf:about"; each $objAttrs≠"rdfx:scope"; |
<xsl:template match=
"*[*[1]
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify'))])]
[*[last()=1]]
[*[1]
[@rdf:about]
[not(@rdfx:subject)]
[not(@rdfx:scope)]]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select="./@*"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="object" select="./*[1]/*[1]"/>
<xsl:variable name="about" select=
"./*[1]/*
[1]/@rdf:about"/>
<xsl:variable name="objAttrs" select=
"./*[1]/*
[1]/@*
[not((namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdf
and local-name()='about')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="objBody" select="./*[1]/*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope"
namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="$object">
<xsl:copy>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:text>URI</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$about"/>
</xsl:attribute>
<xsl:for-each select="$objAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$objBody"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
16 |
BasicSeparation |
Extract first propertyElt from a description, no bagID, not parseType='Literal'. |
<$tag rdfx:subject=$subject
rdfx:scope=$subjScope
$attrs…>
<$propElt
rdfx:object=?$object
rdf:ID=?$ID
rdfx:reify=?$reify
rdfx:scope=?$objScope
rdfx:reifyScope=?$reifyScope
>$objectString</$propElt>
<$more $moreAttrs…>
$moreBody…
</$more>
$body…
</$tag>
|
<rdf:Description
rdfx:scope=$subjScope
rdfx:subject=$subject>
<$propElt
rdfx:reifyScope=?$reifyScope
rdfx:object=?$object
rdfx:scope=?$objScope
rdf:ID=?$ID
rdfx:reify=?$reify
>$objectString</$propElt>
</rdf:Description>
<$tag rdfx:subject=$subject
rdfx:scope=$subjScope
$attrs…>
<$more $moreAttrs…>
$moreBody…
</$more>
$body…
</$tag>
|
When: |
$propElt≠"rdf:li"; each $attrs≠"rdf:bagID"; |
Implicitly |
each $attrs≠"rdfx:subject"; each $attrs≠"rdfx:scope"; |
<xsl:template match=
"*[@rdfx:subject]
[@rdfx:scope]
[not(@rdf:bagID)]
[*[1]
[not(self::rdf:li)]
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='ID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='scope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reifyScope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='reify')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='object'))])]
[not(*)]]
[*[2]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="subject" select="./@rdfx:subject"/>
<xsl:variable name="subjScope" select="./@rdfx:scope"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="body" select=
"./*[2]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="object" select="./*[1]/@rdfx:object"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="objScope" select="./*[1]/@rdfx:scope"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="objectString" select="string(./*[1])"/>
<xsl:variable name="more" select="./*[2]"/>
<xsl:variable name="moreAttrs" select="./*[2]/@*"/>
<xsl:variable name="moreBody" select="./*[2]/node()"/>
<rdf:Description rdfx:scope="{$subjScope}" rdfx:subject="{$subject}">
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:if test="$reifyScope">
<xsl:attribute name="rdfx:reifyScope" namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$object">
<xsl:attribute name="rdfx:object" namespace="{$z-rdfx}">
<xsl:value-of select="$object"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$objScope">
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$objScope"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ID">
<xsl:attribute name="rdf:ID" namespace="{$z-rdf}">
<xsl:value-of select="$ID"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$reify">
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$objectString"/>
</xsl:copy>
</xsl:for-each>
</rdf:Description>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$subject"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$subjScope"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$more">
<xsl:copy>
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
17 |
ReificationID2rdfxReify |
Convert an rdf:ID to rdfx:reify. |
<$tag $attrs…>
<$propElt rdf:ID=$ID
$moreAttrs…>
$moreBody…
</$propElt>
$body…
</$tag>
|
<$tag $attrs…>
<$propElt
rdfx:reifyScope='URI'
rdfx:reify='#{$ID}'
$moreAttrs…>
$moreBody…
</$propElt>
$body…
</$tag>
|
When: |
each $attrs≠"rdf:bagID"; $propElt≠"rdf:li"; |
Implicitly |
each $moreAttrs≠"rdf:ID"; each $moreAttrs≠"rdfx:reifyScope"; each $moreAttrs≠"rdfx:reify"; |
<xsl:template match=
"*[not(@rdf:bagID)]
[*[1]
[not(self::rdf:li)]
[@rdf:ID]
[not(@rdfx:reifyScope)]
[not(@rdfx:reify)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="ID" select="./*[1]/@rdf:ID"/>
<xsl:variable name="moreAttrs" select=
"./*[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdfx
and local-name()='reifyScope')
or (namespace-uri()=$z-rdfx
and local-name()='reify'))]"/>
<xsl:variable name="moreBody" select="./*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:attribute name="rdfx:reifyScope" namespace="{$z-rdfx}">
<xsl:text>URI</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:text>#</xsl:text>
<xsl:value-of select="$ID"/>
</xsl:attribute>
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
18 |
ReificationResource |
Construct quad when reifying with resource object. |
<$tag rdfx:scope=$subjScope
rdfx:subject=$subject
$attrs…>
<$propElt
rdfx:scope=$objScope
rdfx:reifyScope=$reifyScope
rdfx:object=$object
rdfx:reify=$reify/>
$body…
</$tag>
|
<rdf:Statement
rdfx:subject=$reify
rdfx:scope=$reifyScope>
<rdf:subject
rdfx:object=$subject
rdfx:scope=$subjScope/>
<rdf:predicate
rdf:resource=$propElt/>
<rdf:object
rdfx:object=$object
rdfx:scope=$objScope/>
</rdf:Statement>
<$tag rdfx:subject=$subject
rdfx:scope=$subjScope
$attrs…>
<$propElt
rdfx:object=$object
rdfx:scope=$objScope/>
$body…
</$tag>
|
When: |
$propElt≠"rdf:li"; each $attrs≠"rdf:bagID"; |
Implicitly |
each $attrs≠"rdfx:subject"; each $attrs≠"rdfx:scope"; |
<xsl:template match=
"*[@rdfx:scope]
[@rdfx:subject]
[not(@rdf:bagID)]
[*[1]
[not(self::rdf:li)]
[@rdfx:scope]
[@rdfx:reifyScope]
[@rdfx:object]
[@rdfx:reify]
[@*[last()=4]]
[not(*)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="subjScope" select="./@rdfx:scope"/>
<xsl:variable name="subject" select="./@rdfx:subject"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="objScope" select="./*[1]/@rdfx:scope"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="object" select="./*[1]/@rdfx:object"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<rdf:Statement rdfx:scope="{$reifyScope}" rdfx:subject="{$reify}">
<rdf:subject rdfx:object="{$subject}" rdfx:scope="{$subjScope}"/>
<rdf:predicate
rdf:resource="{concat(namespace-uri($propElt),local-name($propElt))}"/>
<rdf:object rdfx:object="{$object}" rdfx:scope="{$objScope}"/>
</rdf:Statement>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$subject"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$subjScope"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:attribute name="rdfx:object" namespace="{$z-rdfx}">
<xsl:value-of select="$object"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$objScope"/>
</xsl:attribute>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
19 |
ReificationString |
Construct quad when reifying with string object. |
<$tag rdfx:subject=$subject
rdfx:scope=$subjScope
$attrs…>
<$propElt rdfx:reify=$reify
rdfx:reifyScope=$reifyScope
>$object</$propElt>
$body…
</$tag>
|
<rdf:Statement
rdfx:subject=$reify
rdfx:scope=$reifyScope>
<rdf:subject
rdfx:object=$subject
rdfx:scope=$subjScope/>
<rdf:predicate
rdf:resource=$propElt/>
<rdf:object
>$object</rdf:object>
</rdf:Statement>
<$tag rdfx:scope=$subjScope
rdfx:subject=$subject
$attrs…>
<$propElt
>$object</$propElt>
$body…
</$tag>
|
When: |
$propElt≠"rdf:li"; each $attrs≠"rdf:bagID"; |
Implicitly |
each $attrs≠"rdfx:subject"; each $attrs≠"rdfx:scope"; |
<xsl:template match=
"*[@rdfx:subject]
[@rdfx:scope]
[not(@rdf:bagID)]
[*[1]
[not(self::rdf:li)]
[@rdfx:reify]
[@rdfx:reifyScope]
[@*[last()=2]]
[not(*)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="subject" select="./@rdfx:subject"/>
<xsl:variable name="subjScope" select="./@rdfx:scope"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="object" select="string(./*[1])"/>
<rdf:Statement rdfx:scope="{$reifyScope}" rdfx:subject="{$reify}">
<rdf:subject rdfx:object="{$subject}" rdfx:scope="{$subjScope}"/>
<rdf:predicate
rdf:resource="{concat(namespace-uri($propElt),local-name($propElt))}"/>
<rdf:object>
<xsl:value-of select="$object"/>
</rdf:object>
</rdf:Statement>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$subjScope"/>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$subject"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:value-of select="$object"/>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
20 |
liStart |
Initialize liCounter |
<$tag $attrs…>
<rdf:li $moreAttrs…>
$moreBody…
</rdf:li>
$body…
</$tag>
|
<$tag rdfx:liCounter='1'
$attrs…>
<rdf:li $moreAttrs…>
$moreBody…
</rdf:li>
$body…
</$tag>
|
Implicitly |
each $attrs≠"rdfx:liCounter"; |
<xsl:template match=
"*[not(@rdfx:liCounter)]
[*[1]
[self::rdf:li]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdfx
and local-name()='liCounter'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="moreAttrs" select="./*[1]/@*"/>
<xsl:variable name="moreBody" select="./*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:liCounter" namespace="{$z-rdfx}">
<xsl:text>1</xsl:text>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<rdf:li>
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</rdf:li>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
21 |
liCount |
Use liCounter |
<$tag rdfx:liCounter=$N
$attrs…>
<rdf:li $moreAttrs…>
$moreBody…
</rdf:li>
$body…
</$tag>
|
<$tag rdfx:liCounter='{$N+1}'
$attrs…>
<$N $moreAttrs…>
$moreBody…
</$N>
$body…
</$tag>
|
Implicitly |
each $attrs≠"rdfx:liCounter"; |
<xsl:template match=
"*[@rdfx:liCounter]
[*[1]
[self::rdf:li]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="N" select="./@rdfx:liCounter"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdfx
and local-name()='liCounter'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="moreAttrs" select="./*[1]/@*"/>
<xsl:variable name="moreBody" select="./*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:liCounter" namespace="{$z-rdfx}">
<xsl:value-of select="$N+1"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:element name="{concat('_',$N)}" namespace="{$z-rdf}">
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</xsl:element>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
22 |
liEnd |
Remove liCounter |
<$tag rdfx:liCounter=$N
$attrs…>
<$prop $moreAttrs…>
$moreBody…
</$prop>
</$tag>
|
<$tag $attrs…>
<$prop $moreAttrs…>
$moreBody…
</$prop>
</$tag>
|
When: |
$prop≠"rdf:li"; |
Implicitly |
each $attrs≠"rdfx:liCounter"; |
<xsl:template match=
"*[@rdfx:liCounter]
[*[last()=1]]
[*[1]
[not(self::rdf:li)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="N" select="./@rdfx:liCounter"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdfx
and local-name()='liCounter'))]"/>
<xsl:variable name="prop" select="./*[1]"/>
<xsl:variable name="moreAttrs" select="./*[1]/@*"/>
<xsl:variable name="moreBody" select="./*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$prop">
<xsl:copy>
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
23 |
bagLiStart |
Initialize counter for bagId, declare bag. |
<$tag rdf:bagID=$bagID $attrs…>
$body…
</$tag>
|
<rdf:Bag rdf:ID=$bagID/>
<$tag rdf:bagID=$bagID
rdfx:bagLiCounter='1'
$attrs…>
$body…
</$tag>
|
When: |
each $attrs≠"rdfx:bagLiCounter"; |
Implicitly |
each $attrs≠"rdf:bagID"; |
<xsl:template match=
"*[@rdf:bagID]
[not(@rdfx:bagLiCounter)]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="bagID" select="./@rdf:bagID"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID')
or (namespace-uri()=$z-rdfx
and local-name()='bagLiCounter'))]"/>
<xsl:variable name="body" select="./node()"/>
<rdf:Bag rdf:ID="{$bagID}"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdf:bagID" namespace="{$z-rdf}">
<xsl:value-of select="$bagID"/>
</xsl:attribute>
<xsl:attribute name="rdfx:bagLiCounter" namespace="{$z-rdfx}">
<xsl:text>1</xsl:text>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
24 |
bagLiEnd |
Drop completed bagId. |
<rdf:Description
rdfx:scope=$subjScope
rdfx:subject=$subject
rdf:bagID=$bagID
rdfx:liCounter=?$M
rdfx:bagLiCounter=$N/>
|
|
<xsl:template match=
"rdf:Description[@rdfx:scope]
[@rdfx:subject]
[@rdf:bagID]
[@rdfx:bagLiCounter]
[not(@*[not((namespace-uri()=
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
and local-name()='bagID')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='subject')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='scope')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='bagLiCounter')
or (namespace-uri()=
'http://jcarroll.hpl.hp.com/rdf/rdfx/'
and local-name()='liCounter'))])]
[not(*)]">
<xsl:variable name="subjScope" select="./@rdfx:scope"/>
<xsl:variable name="subject" select="./@rdfx:subject"/>
<xsl:variable name="bagID" select="./@rdf:bagID"/>
<xsl:variable name="M" select="./@rdfx:liCounter"/>
<xsl:variable name="N" select=
"./@rdfx:bagLiCounter"/>
</xsl:template> |
25 |
bagIDwithoutReification |
In a description with bagID, the first propElt is implicitly reified, if necessary. |
<$tag rdf:bagID=$bagID $attrs…>
<$more $moreAttrs…>
$moreBody…
</$more>
$body…
</$tag>
|
<$tag rdf:bagID=$bagID $attrs…>
<$more rdfx:reifyScope='bNode'
rdfx:reify='_:{generate-id()}'
$moreAttrs…>
$moreBody…
</$more>
$body…
</$tag>
|
When: |
each $moreAttrs≠"rdf:ID"; each $moreAttrs≠"rdfx:reify"; |
Implicitly |
each $attrs≠"rdf:bagID"; each $moreAttrs≠"rdfx:reifyScope"; |
<xsl:template match=
"*[@rdf:bagID]
[*[1]
[not(@rdf:ID)]
[not(@rdfx:reifyScope)]
[not(@rdfx:reify)]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="bagID" select="./@rdf:bagID"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="more" select="./*[1]"/>
<xsl:variable name="moreAttrs" select=
"./*[1]/@*
[not((namespace-uri()=$z-rdf
and local-name()='ID')
or (namespace-uri()=$z-rdfx
and local-name()='reifyScope')
or (namespace-uri()=$z-rdfx
and local-name()='reify'))]"/>
<xsl:variable name="moreBody" select="./*[1]/node()"/>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdf:bagID" namespace="{$z-rdf}">
<xsl:value-of select="$bagID"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:for-each select="$more">
<xsl:copy>
<xsl:attribute name="rdfx:reifyScope" namespace="{$z-rdfx}">
<xsl:text>bNode</xsl:text>
</xsl:attribute>
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:text>_:</xsl:text>
<xsl:value-of select=
"concat('n',$iteration)"/>
</xsl:attribute>
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</xsl:copy>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
26 |
bagIDSeparation |
Separate out the first element of a description node with bagID. |
<$tag rdfx:scope=$subjScope
rdfx:bagLiCounter=$N
rdf:bagID=$bagID
rdfx:subject=$subject
$attrs…>
<$propElt rdfx:reify=$reify
rdfx:reifyScope=$reifyScope
$moreAttrs…>
$moreBody…
</$propElt>
$body…
</$tag>
|
<rdf:Description
rdfx:scope=$subjScope
rdfx:subject=$subject>
<$propElt rdfx:reify=$reify
rdfx:reifyScope=$reifyScope
$moreAttrs…>
$moreBody…
</$propElt>
</rdf:Description>
<rdf:Description
rdfx:scope='URI'
rdfx:subject='#{$bagID}'>
<$N rdfx:object=$reify
rdfx:scope=$reifyScope/>
</rdf:Description>
<$tag rdfx:bagLiCounter='{$N+1}'
rdfx:scope=$subjScope
rdf:bagID=$bagID
rdfx:subject=$subject
$attrs…>
$body…
</$tag>
|
When: |
$propElt≠"rdf:li"; |
Implicitly |
each $moreAttrs≠"rdfx:reifyScope"; each $moreAttrs≠"rdfx:reify"; each $attrs≠"rdf:bagID"; each $attrs≠"rdfx:subject"; each $attrs≠"rdfx:scope"; each $attrs≠"rdfx:bagLiCounter"; |
<xsl:template match=
"*[@rdfx:scope]
[@rdfx:bagLiCounter]
[@rdf:bagID]
[@rdfx:subject]
[*[1]
[not(self::rdf:li)]
[@rdfx:reify]
[@rdfx:reifyScope]]">
<xsl:variable name="tag" select="."/>
<xsl:variable name="subjScope" select="./@rdfx:scope"/>
<xsl:variable name="N" select=
"./@rdfx:bagLiCounter"/>
<xsl:variable name="bagID" select="./@rdf:bagID"/>
<xsl:variable name="subject" select="./@rdfx:subject"/>
<xsl:variable name="attrs" select=
"./@*[not((namespace-uri()=$z-rdf
and local-name()='bagID')
or (namespace-uri()=$z-rdfx
and local-name()='subject')
or (namespace-uri()=$z-rdfx
and local-name()='scope')
or (namespace-uri()=$z-rdfx
and local-name()='bagLiCounter'))]"/>
<xsl:variable name="body" select=
"./*[1]/following-sibling::node()"/>
<xsl:variable name="propElt" select="./*[1]"/>
<xsl:variable name="reify" select="./*[1]/@rdfx:reify"/>
<xsl:variable name="reifyScope" select=
"./*[1]/@rdfx:reifyScope"/>
<xsl:variable name="moreAttrs" select=
"./*[1]/@*
[not((namespace-uri()=$z-rdfx
and local-name()='reifyScope')
or (namespace-uri()=$z-rdfx
and local-name()='reify'))]"/>
<xsl:variable name="moreBody" select="./*[1]/node()"/>
<rdf:Description rdfx:scope="{$subjScope}" rdfx:subject="{$subject}">
<xsl:for-each select="$propElt">
<xsl:copy>
<xsl:attribute name="rdfx:reify" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
<xsl:attribute name="rdfx:reifyScope" namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
<xsl:for-each select="$moreAttrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$moreBody"/>
</xsl:copy>
</xsl:for-each>
</rdf:Description>
<rdf:Description rdfx:scope="URI" rdfx:subject="#{$bagID}">
<xsl:element name="{concat('_',$N)}" namespace="{$z-rdf}">
<xsl:attribute name="rdfx:object" namespace="{$z-rdfx}">
<xsl:value-of select="$reify"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$reifyScope"/>
</xsl:attribute>
</xsl:element>
</rdf:Description>
<xsl:for-each select="$tag">
<xsl:copy>
<xsl:attribute name="rdfx:bagLiCounter" namespace="{$z-rdfx}">
<xsl:value-of select="$N+1"/>
</xsl:attribute>
<xsl:attribute name="rdfx:scope" namespace="{$z-rdfx}">
<xsl:value-of select="$subjScope"/>
</xsl:attribute>
<xsl:attribute name="rdf:bagID" namespace="{$z-rdf}">
<xsl:value-of select="$bagID"/>
</xsl:attribute>
<xsl:attribute name="rdfx:subject" namespace="{$z-rdfx}">
<xsl:value-of select="$subject"/>
</xsl:attribute>
<xsl:for-each select="$attrs">
<xsl:copy/>
</xsl:for-each>
<xsl:copy-of select="$body"/>
</xsl:copy>
</xsl:for-each>
</xsl:template> |
27 |
tidyingUp |
Remove superfluous rdf:Description's. |
<rdf:Description
rdfx:scope=$subjScope
rdfx:subject=$subj/>
|
|
<xsl:template match=
"rdf:Description[@rdfx:scope]
[@rdfx:subject]
[@*[last()=2]]
[not(*)]">
<xsl:variable name="subjScope" select="./@rdfx:scope"/>
<xsl:variable name="subj" select="./@rdfx:subject"/>
</xsl:template> |