<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
	<!ENTITY e    "http://www.xs4all.nl/~pboot/p01/emblem.xml#" >
	<!ENTITY p01s "http://www.xs4all.nl/~pboot/p01/p01rdfs.rdf#" >
	<!ENTITY rdf  "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
	<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
	<!ENTITY % charrefs SYSTEM "entities.dtd">
	%charrefs;
]>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0"
  xmlns:saxon="http://icl.com/saxon"
  xmlns:p01s="http://www.xs4all.nl/~pboot/p01/p01rdfs.rdf#"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
  xmlns:pb="http://www.xs4all.nl/~pboot/"
  xmlns:func="http://exslt.org/functions"
  exclude-result-prefixes="saxon pb func rdf rdfs p01s"
  extension-element-prefixes="saxon pb func">

<xsl:variable name="datafile" select="'http://www.xs4all.nl/~pboot/p01/emblem.xml'"/>
<xsl:variable name="rdffile" select="'http://www.xs4all.nl/~pboot/p01/rdftriple.xml'"/>
<xsl:variable name="rdfsfile" select="'http://www.xs4all.nl/~pboot/p01/rdfstriple.xml'"/>
<xsl:variable name="rdfpref" select="'http://www.xs4all.nl/~pboot/p01/p01rdf.rdf'"/>
<xsl:variable name="rdfspref" select="'http://www.xs4all.nl/~pboot/p01/p01rdfs.rdf'"/>

<xsl:template match="*" mode="plain">
	<xsl:apply-templates mode="plain"/>
</xsl:template>

<xsl:template match="ptr" mode="plain">
	<xsl:apply-templates select="id(@target)" mode="plain"/>
</xsl:template>

<func:function name="pb:fullname">
	<xsl:param name="id"/>
	<xsl:param name="type"/>
	<func:result>
		<xsl:choose>
			<xsl:when test="$type='data'">
				<xsl:value-of select="concat($datafile,concat('#',$id))"/>
			</xsl:when>
			<xsl:when test="$type='rdf'">
				<xsl:value-of select="concat($rdfpref,concat('#',$id))"/>
			</xsl:when>
			<xsl:when test="$type='rdfs'">
				<xsl:value-of select="concat($rdfspref,concat('#',$id))"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:message>pb:fullname unknown type <xsl:value-of select="$type"/> with id <xsl:value-of select="$id"/></xsl:message>
			</xsl:otherwise>
		</xsl:choose>
	</func:result>
</func:function>

<func:function name="pb:global-part">
	<xsl:param name="uri"/>
	<func:result>
		<xsl:value-of select="substring-before($uri,'#')"/>
	</func:result>
</func:function>

<func:function name="pb:local-part">
	<xsl:param name="uri"/>
	<func:result>
		<xsl:value-of select="substring-after($uri,'#')"/>
	</func:result>
</func:function>

</xsl:stylesheet>

