incubator-triplesoup-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r528394 [27/35] - in /incubator/triplesoup/donations/TRIPLES-3-RDFStore: ./ dbms/ dbms/client/ dbms/client/t/ dbms/dbmsproxy/ dbms/deamon/ dbms/doc/ dbms/include/ dbms/libdbms/ dbms/utils/ doc/ include/ lib/ lib/DBD/ lib/RDFStore/ lib/RDFSt...
Date Fri, 13 Apr 2007 08:56:16 GMT
Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/link2rdf.xsl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/link2rdf.xsl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/link2rdf.xsl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/link2rdf.xsl Fri Apr 13 01:56:01 2007
@@ -0,0 +1,373 @@
+<?xml version='1.0'?>
+<!--
+	http://www.openhealth.org/RDF/extract/link2rdf.xsl
+	Copyright (c) 2000 Jonathan Borden, The Open Healthcare Group and GroveLogic, LLC. all rights reserved
+	licensed under the Open Health Community License http://www.openhealth.org/license
+	
+	Version 2000-09-20
+	
+	* Implements XLink2RDF conversion - this version includes extended links
+		
+-->
+<!-- jonathan@openhealth.org -->
+
+<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:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+	xmlns:xlink="http://www.w3.org/1999/xlink"
+	xmlns:saxon="http://icl.com/saxon"
+	exclude-result-prefixes='xsl rdf rdfs xlink saxon'
+	>
+
+
+<!--   XLink 2 RDF here                                                                      -->
+<!-- per http://www.w3.org/XML/2000/09/xlink2rdf.htm -->
+<!--  <xsl:param name="subject"/> -->
+
+
+<xsl:template name="xlink-simple">
+
+  	<xsl:param name="subject"><xsl:call-template name="nodeIdentifier"/></xsl:param>
+	<xsl:variable name="object" select="@xlink:href"/>
+
+	<xsl:call-template name="statement">
+		<xsl:with-param name="predicate">
+			<xsl:choose>
+				<xsl:when test="@xlink:arcrole"><xsl:value-of select="@xlink:arcrole" /></xsl:when>
+				<xsl:otherwise><xsl:call-template name="QNameToURI"/></xsl:otherwise>
+			</xsl:choose>
+		</xsl:with-param>
+		<xsl:with-param name="subject" select="$subject"/>
+		<xsl:with-param name="object" select="@xlink:href"/>
+		<xsl:with-param name="object-type" select="'resource'"/>
+	</xsl:call-template>
+	<xsl:if test="@xlink:role">
+ 		<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfType"/>
+		 <xsl:with-param name="subject" select="@xlink:href"/>
+		 <xsl:with-param name="object" select="@xlink:role"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+     	<!--<rdf:Statement>
+        		<rdf:predicate><xsl:value-of select="$rdfType" /></rdf:predicate>
+				<rdf:subject><xsl:value-of select="@xlink:href"/></rdf:subject>
+        		<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="@xlink:role" /></rdf:object>
+      	</rdf:Statement>-->
+		<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfType"/>
+		 <xsl:with-param name="subject" select="@xlink:role"/>
+		 <xsl:with-param name="object" select="$rdfsClass"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+      	<!--<rdf:Statement>
+        		<rdf:predicate><xsl:value-of select="$rdfType" /></rdf:predicate>
+        		<rdf:subject><xsl:value-of select="@xlink:role" /></rdf:subject>
+        		<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select='concat($rdfsNS,"Class")' /></rdf:object>
+      	</rdf:Statement>-->
+	</xsl:if>
+<!--
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="$object"/>
+</xsl:call-template>
+-->
+
+<xsl:call-template name="generate-statements">
+  <xsl:with-param name="node" select="."/>
+  <xsl:with-param name="subject" select="$object"/>
+</xsl:call-template>
+
+</xsl:template>
+<!-- this is special for linkbase processing -->
+<xsl:template match="*[(@xlink:type='simple') and not(../@xlink:type='extended')]" mode="xlink-extended">
+	<xsl:apply-templates select="." mode="property-elements"/>
+</xsl:template>
+<xsl:template match="*[@xlink:type='arc']" mode="xlink-extended">
+	<xsl:param name="predicate"><xsl:call-template name="get-predicate" /></xsl:param>
+	<xsl:variable name="base" select=".."/>
+	<xsl:variable name="from" select="@xlink:from"/>
+	<xsl:variable name="to" select="@xlink:to" />
+<xsl:if test="$trace">[TRACE xlink:type'arc' predicate=<xsl:value-of select="$predicate" />]</xsl:if>
+	<xsl:for-each select="$base/*[((@xlink:type='resource') or (@xlink:type='locator')) and (not($from) or (@xlink:label=$from))]">
+		<xsl:variable name="this-from" select="."/>
+		<xsl:variable name="subject"><xsl:call-template name="get-subject-object" /></xsl:variable>
+		<xsl:for-each select="$base/*[((@xlink:type='resource') or (@xlink:type='locator')) and (not($to) or (@xlink:label=$to))]">
+			<xsl:variable name="this-to" select="."/>
+			<xsl:variable name="object"><xsl:call-template name="get-subject-object"/></xsl:variable>
+			<xsl:call-template name="statement">
+		 		<xsl:with-param name="predicate" select="$predicate"/>
+		 		<xsl:with-param name="subject" select="$subject"/>
+		 		<xsl:with-param name="object" select="$object"/>
+		 		<xsl:with-param name="object-type" select="'resource'"/>
+			</xsl:call-template>
+
+			<!--<rdf:Statement>
+				<rdf:predicate><xsl:value-of select="$predicate" /></rdf:predicate>
+				<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+				<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="$object" /></rdf:object>
+			</rdf:Statement>-->
+		</xsl:for-each>
+	</xsl:for-each>
+</xsl:template>
+<xsl:template match="*[(@xlink:type='arc') and (@xlink:arcrole='http://www.w3.org/1999/xlink/properties/linkbase')]" mode="xlink-extended">
+<xsl:if test="$trace">[TRACE xlink arcrole=linkbase]</xsl:if>
+	<xsl:apply-templates select="document(@xlink:href)" mode="xlink-extended"/>
+</xsl:template>
+<xsl:template match="*[@xlink:type='locator']" mode="xlink-extended">
+	<xsl:variable name="subject" select="@xlink:href"/>
+	<xsl:variable name="object">
+		<xsl:choose>
+			<xsl:when test="@xlink:role"><xsl:value-of select="@xlink:role" /></xsl:when>
+			<xsl:otherwise><xsl:call-template name="QNameToURI" /></xsl:otherwise>
+		</xsl:choose>
+	</xsl:variable>
+	<xsl:if test="@xlink:role">
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfType"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="@xlink:role"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+		<!--<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="$rdfType" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="@xlink:role" /></rdf:object>
+		</rdf:Statement>-->
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfType"/>
+		 <xsl:with-param name="subject" select="@xlink:role"/>
+		 <xsl:with-param name="object" select="$rdfsClass"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+		<!--<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="$rdfType" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="@xlink:role" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="$rdfsClass" /></rdf:object>
+		</rdf:Statement>-->
+	</xsl:if>
+	<xsl:if test="@xlink:label">
+		<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="concat($xlinkNS,'#','label')"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="@xlink:label"/>
+		 <xsl:with-param name="object-type" select="'literal'"/>
+		</xsl:call-template>
+		<!--<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsLiteralType}"><xsl:value-of select="@xlink:label" /></rdf:object>
+		</rdf:Statement>-->
+	</xsl:if>
+	<xsl:if test="@xlink:title">
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="concat($xlinkNS,'#','title')"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="@xlink:title"/>
+		 <xsl:with-param name="object-type" select="'literal'"/>
+		</xsl:call-template>
+		<!--<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsLiteralType}"><xsl:value-of select="@xlink:title" /></rdf:object>
+		</rdf:Statement>-->
+	</xsl:if>
+	<xsl:apply-templates select="*[@xlink:type='title']" mode="xlink-extended"/>
+	<xsl:call-template name="generate-statements-noxlink">
+  		<xsl:with-param name="node" select="."/>
+  		<xsl:with-param name="subject" select="$object"/>
+	</xsl:call-template>
+
+</xsl:template>
+<xsl:template match="*[@xlink:type='resource']" mode="xlink-extended">
+	<xsl:variable name="subject"><xsl:call-template name="QNameToURI" /></xsl:variable>
+	<xsl:variable name="object">
+		<xsl:choose>
+			<xsl:when test="@xlink:role"><xsl:value-of select="@xlink:role" /></xsl:when>
+			<xsl:otherwise><xsl:call-template name="QNameToURI" /></xsl:otherwise>
+		</xsl:choose>
+	</xsl:variable>
+	<xsl:if test="@xlink:role">
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfType"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="@xlink:role"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfType"/>
+		 <xsl:with-param name="subject" select="@xlink:role"/>
+		 <xsl:with-param name="object" select="$rdfsClass"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+	</xsl:if>
+	<xsl:if test="@xlink:label">
+		<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="concat($xlinkNS,'#','label')"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="@xlink:label"/>
+		 <xsl:with-param name="object-type" select="'literal'"/>
+		</xsl:call-template>
+	</xsl:if>
+	<xsl:if test="@xlink:title">
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="concat($xlinkNS,'#','title')"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="@xlink:title"/>
+		 <xsl:with-param name="object-type" select="'literal'"/>
+		</xsl:call-template>
+	</xsl:if>
+
+	<!--<xsl:if test="@xlink:role">
+		<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="$rdfType" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="@xlink:role" /></rdf:object>
+		</rdf:Statement>
+		<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="$rdfType" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="@xlink:role" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="$rdfsClass" /></rdf:object>
+		</rdf:Statement>
+	</xsl:if>
+	<xsl:if test="@xlink:label">
+		<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="concat($xlinkNS,'#','label')" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsLiteralType}"><xsl:value-of select="@xlink:label" /></rdf:object>
+		</rdf:Statement>
+	</xsl:if>
+	<xsl:if test="@xlink:title">
+		<rdf:Statement>
+			<rdf:predicate><xsl:value-of select="concat($xlinkNS,'#','title')" /></rdf:predicate>
+			<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+			<rdf:object rdf:type="{$rdfsLiteralType}"><xsl:value-of select="@xlink:title" /></rdf:object>
+		</rdf:Statement>
+	</xsl:if>-->
+	<xsl:apply-templates select="*[@xlink:type='title']" mode="xlink-extended"/>
+
+	<xsl:call-template name="generate-statements-noxlink">
+  		<xsl:with-param name="node" select="."/>
+  		<xsl:with-param name="subject" select="$object"/>
+	</xsl:call-template>
+
+</xsl:template>
+<xsl:template match="*[@xlink:type='title']" mode="xlink-extended">
+	<xsl:variable name="subject"><xsl:call-template name="QNameToURI"><xsl:with-param name="node" select=".." /></xsl:call-template></xsl:variable>
+	<xsl:variable name="object"><xsl:call-template name="QNameToURI"/></xsl:variable>
+<xsl:if test="$trace">[TRACE *[xlink:type='title']
+	subject=<xsl:value-of select="$subject" />:<xsl:value-of select="name(..)" />
+	object=<xsl:value-of select="$object" />
+]</xsl:if>
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="concat($xlinkNS,'#','title')"/>
+		 <xsl:with-param name="subject" select="$subject"/>
+		 <xsl:with-param name="object" select="$object"/>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+
+	<!--<rdf:Statement>
+		<rdf:predicate><xsl:value-of select="" /></rdf:predicate>
+		<rdf:subject><xsl:value-of select="$subject" /></rdf:subject>
+		<rdf:object rdf:type="{$rdfsResourceType}"><xsl:value-of select="$object" /></rdf:object>
+	</rdf:Statement>-->
+	<xsl:choose>
+		<!-- if XML content then process -->
+		<xsl:when test="*">
+			<xsl:for-each select="*">
+	<xsl:if test="$trace">[TRACE "*" name=<xsl:value-of select="name()" />]</xsl:if>
+		<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfValue"/>
+		 <xsl:with-param name="subject" select="$object"/>
+		 <xsl:with-param name="object"><xsl:call-template name="nodeIdentifier" /></xsl:with-param>
+		 <xsl:with-param name="object-type" select="'resource'"/>
+		</xsl:call-template>
+
+	<!--<rdf:Statement>
+		<rdf:predicate><xsl:value-of select="$rdfValue" /></rdf:predicate>
+		<rdf:subject><xsl:value-of select="$object" /></rdf:subject>
+		<rdf:object rdf:type="{$rdfsResourceType}"></rdf:object>
+	</rdf:Statement>-->
+	<xsl:apply-templates select="." mode="objects"/>
+			</xsl:for-each>
+		</xsl:when>
+		<!-- otherwise literal content set to rdf:value -->
+		<xsl:when test="text()[string-length(normalize-space())&gt;0]">
+			<xsl:for-each select="text()[string-length(normalize-space())&gt;0]">
+	 	<xsl:call-template name="statement">
+		 <xsl:with-param name="predicate" select="$rdfValue"/>
+		 <xsl:with-param name="subject" select="$object"/>
+		 <xsl:with-param name="object" select="."/>
+		 <xsl:with-param name="object-type" select="'literal'"/>
+		</xsl:call-template>
+
+	<!--<rdf:Statement>
+		<rdf:predicate><xsl:value-of select="$rdfValue" /></rdf:predicate>
+		<rdf:subject><xsl:value-of select="$object" /></rdf:subject>
+		<rdf:object rdf:type="{$rdfsLiteralType}"><xsl:value-of select="." /></rdf:object>
+	</rdf:Statement>-->
+			</xsl:for-each>
+		</xsl:when>
+	</xsl:choose>
+</xsl:template>
+<xsl:template name="get-predicate">
+<xsl:if test="$trace">
+[TRACE get-predicate
+	node=<xsl:value-of select="name()" />
+	arcrole=<xsl:value-of select="@xlink:arcrole" />
+]
+</xsl:if>
+	<xsl:choose>
+		<xsl:when test="@xlink:arcrole"><xsl:value-of select="@xlink:arcrole" /></xsl:when>
+		<xsl:otherwise><xsl:call-template name="QNameToURI"/></xsl:otherwise>
+	</xsl:choose>
+</xsl:template>
+<xsl:template name="get-subject-object">
+	<xsl:choose>
+		<xsl:when test="@xlink:type='locator'"><xsl:value-of select="@xlink:href" /></xsl:when>
+		<xsl:when test="@xlink:type='resource'"><xsl:call-template name="QNameToURI"/></xsl:when>
+		<xsl:otherwise><error>Unknown xlink:type for subject or object</error></xsl:otherwise>
+	</xsl:choose>
+</xsl:template>
+<!--                                                                         -->
+
+<xsl:template name="generate-statements-noxlink">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="subject">
+    <xsl:call-template name="resource-uri">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+  </xsl:param>
+<xsl:if test="$trace">[TRACE gen-stat-noxlink
+	subject=<xsl:value-of select="$subject" />
+]</xsl:if>
+<xsl:variable name="reified-statement">
+  <xsl:value-of select="$node/@bagID"/>
+</xsl:variable>
+
+<xsl:apply-templates select="$node/@*" mode="property-attributes">
+  <xsl:with-param name="subject" select="$subject"/>
+</xsl:apply-templates>
+
+<xsl:apply-templates select="$node/*[not(@xlink:*)]" mode="property-elements">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="reified-statement" select="$reified-statement"/>
+</xsl:apply-templates>
+	<xsl:choose>
+		<xsl:when test="$defaultParseType='Resource'">
+			<xsl:for-each select='text()[string-length(normalize-space())&gt;0]'>
+        		<xsl:call-template name="generate-statement-string">
+  					<xsl:with-param name="subject" select="$subject"/>
+  					<xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+  					<xsl:with-param name="predicate-local-name" select="'value'"/>
+  					<xsl:with-param name="object-type" select="'literal'"/>
+  					<xsl:with-param name="object" select="."/>
+				</xsl:call-template>
+      		</xsl:for-each>
+		</xsl:when>
+	</xsl:choose>
+</xsl:template>
+</xsl:stylesheet>

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf.xsl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf.xsl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf.xsl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf.xsl Fri Apr 13 01:56:01 2007
@@ -0,0 +1,656 @@
+<?xml version="1.0" ?>
+
+<!-- rdf (syntax sucks) 1.0 "parser" -->
+<!-- revision: 2000-09-14 -->
+<!-- contact: jason@injektilo.org -->
+
+<!-- TODO: -->
+
+<!-- aboutEach=bagID -->
+<!-- reification -->
+<!-- aboutEachPrefix -->
+<!-- xml:lang -->
+
+<!-- error checking -->
+<!-- property-elements with resource attributes can't have children? -->
+
+<!-- HISTORY:
+
+  2000-09-11:
+    Initial release.
+  2000-09-13:
+    Refactored into multiple templates. General cleanup.
+    Added support for containers, value, parseType.
+  2000-09-14:
+    Anonymous container objects had a different URI than the same container
+      as a subject to it's members.
+    Typed nodes with a resource attribute not in the rdf namespace weren't being
+      parsed correctly
+
+  -->
+
+<!DOCTYPE xsl:transform [
+
+<!ENTITY description-id-and-about "Description's cannot have both and ID and about attribute">
+<!ENTITY about-each-prefix-not-implemented "aboutEachPrefix not implemented">
+<!ENTITY alt-minimum-one-member "Alts need at least one member">
+<!ENTITY container-member-attributes-vs-elements "containers with member attributes cannot have elements">
+
+]>
+
+<xsl:transform version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+>
+  <!-- exclude-result-prefixes="rdf"  by AR 2000/09/25 -->
+
+<!--<xsl:output method="xml" indent="yes"/>-->
+
+<xsl:variable name="rdf" select="'http://www.w3.org/1999/02/22-rdf-syntax-ns#'"/>
+
+<!-- disable the built-in templates that copies text through -->
+
+<xsl:template match="text()|@*"></xsl:template>
+<xsl:template match="text()|@*" mode="objects"></xsl:template>
+<xsl:template match="text()|@*" mode="members"></xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:RDF">
+
+<model>
+  <xsl:apply-templates mode="objects"/>
+</model>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:Description" mode="objects">
+
+<xsl:call-template name="generate-statements"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:Description[@about]" mode="objects">
+
+<xsl:call-template name="generate-statements"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:Description[@about and @ID]" mode="objects">
+
+<xsl:message terminate="yes">&description-id-and-about;</xsl:message>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:Description[@aboutEach]" mode="objects">
+
+<xsl:call-template name="generate-statements-about-each">
+  <xsl:with-param name="node" select="."/>
+  <xsl:with-param name="about-each" select="@aboutEach"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:Description[@aboutEachPrefix]" mode="objects">
+
+<xsl:message terminate="yes">&about-each-prefix-not-implemented;</xsl:message>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@rdf:about]" mode="objects">
+
+<xsl:call-template name="generate-type-statement">
+  <xsl:with-param name="subject" select="@rdf:about"/>
+  <xsl:with-param name="type" select="concat(namespace-uri(), local-name())"/>
+</xsl:call-template>
+
+<xsl:call-template name="generate-statements"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*" mode="objects">
+
+<xsl:call-template name="generate-statements"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@rdf:aboutEach]" mode="objects">
+
+<xsl:call-template name="generate-statements-about-each">
+  <xsl:with-param name="node" select="."/>
+  <xsl:with-param name="about-each" select="@rdf:aboutEach"/>
+  <xsl:with-param name="type" select="concat(namespace-uri(), local-name())"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@aboutEachPrefix]" mode="objects">
+
+<xsl:message terminate="yes">&about-each-prefix-not-implemented;</xsl:message>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:Bag | rdf:Seq | rdf:Alt" mode="objects">
+
+<xsl:variable name="subject">
+  <xsl:call-template name="container-uri">
+    <xsl:with-param name="node" select="."/>
+  </xsl:call-template>
+</xsl:variable>
+
+<xsl:call-template name="generate-type-statement">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="type" select="concat(namespace-uri(), local-name())"/>
+</xsl:call-template>
+
+<!-- make sure Alts have at least one member -->
+<xsl:if test="local-name() = 'Alt' and count(rdf:li) = 0">
+  <xsl:message terminate="yes">&alt-minimum-one-member;</xsl:message>
+</xsl:if>
+
+<!-- make sure there are not both member attributes and elements -->
+<xsl:choose>
+  <xsl:when test="@rdf:*[starts-with(local-name(), '_')]">
+    <xsl:choose>
+      <xsl:when test="*">
+        <xsl:message terminate="yes">&container-member-attributes-vs-elements;</xsl:message>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="@rdf:*" mode="member-attributes">
+          <xsl:with-param name="subject" select="$subject"/>
+        </xsl:apply-templates>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+    <xsl:apply-templates select="rdf:li" mode="members">
+      <xsl:with-param name="container" select="$subject"/>
+    </xsl:apply-templates>
+  </xsl:otherwise>
+</xsl:choose>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="@rdf:*" mode="member-attributes">
+  <xsl:param name="subject"/>
+
+<xsl:if test="starts-with(local-name(), '_')">
+  <xsl:call-template name="generate-statement-string">
+    <xsl:with-param name="subject" select="$subject"/>
+    <xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+    <xsl:with-param name="predicate-local-name" select="local-name()"/>
+    <xsl:with-param name="object-type" select="'literal'"/>
+    <xsl:with-param name="object" select="."/>
+  </xsl:call-template>
+</xsl:if>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:li[@resource]" mode="members">
+  <xsl:param name="container"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$container"/>
+  <xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+  <xsl:with-param name="predicate-local-name" select="concat('_', position())"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="@resource"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<!-- this is mostly a copy of the previous template with the resource
+attribute explicitly in the rdf namespace. this isn't legal according to the
+spec but it probably should be. -->
+
+<xsl:template match="rdf:li[@rdf:resource]" mode="members">
+  <xsl:param name="container"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$container"/>
+  <xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+  <xsl:with-param name="predicate-local-name" select="concat('_', position())"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="@rdf:resource"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:li" mode="members">
+  <xsl:param name="container"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$container"/>
+  <xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+  <xsl:with-param name="predicate-local-name" select="concat('_', position())"/>
+  <xsl:with-param name="object-type" select="'literal'"/>
+  <xsl:with-param name="object" select="."/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="@*" mode="property-attributes">
+  <xsl:param name="subject"/>
+
+<xsl:variable name="attribute-namespace-uri" select="namespace-uri()"/>
+
+<xsl:if test="$attribute-namespace-uri != $rdf">
+  <xsl:if test="$attribute-namespace-uri != ''">
+    <xsl:call-template name="generate-statement-string">
+      <xsl:with-param name="subject" select="$subject"/>
+      <xsl:with-param name="predicate-namespace-uri" select="$attribute-namespace-uri"/>
+      <xsl:with-param name="predicate-local-name" select="local-name()"/>
+      <xsl:with-param name="object-type" select="'literal'"/>
+      <xsl:with-param name="object" select="."/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:if>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[rdf:Description | rdf:Bag | rdf:Seq | rdf:Alt]" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:variable name="container" select="rdf:Description | rdf:Bag | rdf:Seq | rdf:Alt"/>
+
+<xsl:variable name="object">
+  <xsl:call-template name="resource-uri">
+    <xsl:with-param name="node" select="$container"/>
+  </xsl:call-template>
+</xsl:variable>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="$object"/>
+</xsl:call-template>
+
+<xsl:apply-templates select="$container" mode="objects"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@resource]" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="@resource"/>
+</xsl:call-template>
+
+<xsl:apply-templates select="." mode="objects"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<!-- this is mostly a copy of the previous template with the resource
+attribute explicitly in the rdf namespace. this isn't legal according to the
+spec but it probably should be. -->
+
+<xsl:template match="*[@rdf:resource]" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="@rdf:resource"/>
+</xsl:call-template>
+
+<xsl:apply-templates select="." mode="objects"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="rdf:*[@resource]" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="@resource"/>
+</xsl:call-template>
+
+<xsl:apply-templates select="." mode="objects"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[*[1]/@rdf:about]" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="*[1]/@rdf:about"/>
+</xsl:call-template>
+
+<xsl:apply-templates select="*[1]" mode="objects"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'literal'"/>
+  <xsl:with-param name="object" select="."/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@rdf:parseType='Literal']" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:call-template name="generate-statement">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'literal'"/>
+  <xsl:with-param name="object" select="*|text()"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@rdf:parseType='Resource']" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:variable name="object">
+  <xsl:call-template name="resource-uri">
+    <xsl:with-param name="node" select="."/>
+  </xsl:call-template>
+</xsl:variable>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="$object"/>
+</xsl:call-template>
+
+<xsl:call-template name="generate-statements">
+  <xsl:with-param name="node" select="."/>
+  <xsl:with-param name="subject" select="$object"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<xsl:template match="*[@rdf:value]" mode="property-elements">
+  <xsl:param name="subject"/>
+
+<xsl:variable name="object">
+  <xsl:call-template name="resource-uri">
+    <xsl:with-param name="node" select="."/>
+  </xsl:call-template>
+</xsl:variable>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="namespace-uri()"/>
+  <xsl:with-param name="predicate-local-name" select="local-name()"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="$object"/>
+</xsl:call-template>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$object"/>
+  <xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+  <xsl:with-param name="predicate-local-name" select="'value'"/>
+  <xsl:with-param name="object-type" select="'literal'"/>
+  <xsl:with-param name="object" select="@rdf:value"/>
+</xsl:call-template>
+
+<xsl:call-template name="generate-statements">
+  <xsl:with-param name="node" select="."/>
+  <xsl:with-param name="subject" select="$object"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<!--
+<xsl:template name="resource-uri">
+  <xsl:param name="node" select="."/>
+
+<xsl:choose>
+  <xsl:when test="namespace-uri($node) = $rdf and $node/@about">
+    <xsl:value-of select="$node/@about"/>
+  </xsl:when>
+  <xsl:when test="namespace-uri($node) = $rdf and $node/@resource">
+    <xsl:value-of select="$node/@resource"/>
+  </xsl:when>
+  <xsl:when test="namespace-uri($node) != $rdf and $node/@rdf:resource">
+    <xsl:value-of select="$node/@rdf:resource"/>
+  </xsl:when>
+  <xsl:when test="namespace-uri($node) != $rdf and $node/@rdf:about">
+    <xsl:value-of select="$node/@rdf:about"/>
+  </xsl:when>
+  <xsl:when test="namespace-uri($node) = $rdf and $node/@ID">
+    <xsl:value-of select="concat('#', $node/@ID)"/>
+  </xsl:when>
+  <xsl:when test="namespace-uri($node) != $rdf and $node/@rdf:ID">
+    <xsl:value-of select="concat('#', $node/@rdf:ID)"/>
+  </xsl:when>
+  <xsl:otherwise>
+    <xsl:call-template name="anonymous-uri">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+  </xsl:otherwise>
+</xsl:choose>
+
+</xsl:template>
+-->
+
+<!--                                                                         -->
+
+<!--
+<xsl:template name="container-uri">
+  <xsl:param name="node" select="."/>
+
+<xsl:choose>
+  <xsl:when test="namespace-uri($node) = $rdf and $node/@ID">
+    <xsl:value-of select="concat('#', $node/@ID)"/>
+  </xsl:when>
+  <xsl:when test="namespace-uri($node) != $rdf and $node/@rdf:ID">
+    <xsl:value-of select="concat('#', $node/@rdf:ID)"/>
+  </xsl:when>
+  <xsl:otherwise>
+    <xsl:call-template name="anonymous-uri">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+  </xsl:otherwise>
+</xsl:choose>
+
+</xsl:template>
+-->
+
+<!--                                                                         -->
+
+<xsl:template name="anonymous-uri">
+  <xsl:param name="node"/>
+
+<xsl:value-of select="concat('anonymous:', generate-id($node))"/>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<!--
+<xsl:template name="generate-statement-string">
+  <xsl:param name="subject"/>
+  <xsl:param name="predicate-namespace-uri"/>
+  <xsl:param name="predicate-local-name"/>
+  <xsl:param name="object-type"/>
+  <xsl:param name="object"/>
+
+<xsl:call-template name="generate-statement">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="$predicate-namespace-uri"/>
+  <xsl:with-param name="predicate-local-name" select="$predicate-local-name"/>
+  <xsl:with-param name="object-type" select="$object-type"/>
+  <xsl:with-param name="object" select="string($object)"/>
+</xsl:call-template>
+
+</xsl:template>
+-->
+
+<!--                                                                         -->
+
+<!--
+<xsl:template name="generate-statement">
+  <xsl:param name="subject"/>
+  <xsl:param name="predicate-namespace-uri"/>
+  <xsl:param name="predicate-local-name"/>
+  <xsl:param name="object-type"/>
+  <xsl:param name="object"/>
+
+<statement>
+  <subject><xsl:value-of select="$subject"/></subject>
+  <predicate><xsl:value-of select="concat($predicate-namespace-uri, $predicate-local-name)"/></predicate>
+  <object type="{$object-type}"><xsl:copy-of select="$object"/></object>
+</statement>
+
+</xsl:template>
+-->
+
+<!--                                                                         -->
+
+<xsl:template name="generate-type-statement">
+  <xsl:param name="subject"/>
+  <xsl:param name="type"/>
+
+<xsl:call-template name="generate-statement-string">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="predicate-namespace-uri" select="$rdf"/>
+  <xsl:with-param name="predicate-local-name" select="'type'"/>
+  <xsl:with-param name="object-type" select="'resource'"/>
+  <xsl:with-param name="object" select="$type"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<!--                                                                         -->
+
+<!--
+<xsl:template name="generate-statements-about-each">
+  <xsl:param name="node"/>
+  <xsl:param name="about-each"/>
+  <xsl:param name="type"/>
+
+<xsl:variable name="id">
+  <xsl:choose>
+    <xsl:when test="starts-with($about-each, '#')">
+      <xsl:value-of select="substring-after($about-each, '#')"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$about-each"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+
+<xsl:for-each select="//rdf:*[@ID=$id]/rdf:li">
+
+  <xsl:if test="$type">
+    <xsl:call-template name="generate-type-statement">
+      <xsl:with-param name="subject" select="@resource"/>
+      <xsl:with-param name="type" select="$type"/>
+    </xsl:call-template>
+  </xsl:if>
+
+  <xsl:call-template name="generate-statements">
+    <xsl:with-param name="node" select="$node"/>
+    <xsl:with-param name="subject" select="@resource"/>
+  </xsl:call-template>
+
+</xsl:for-each>
+
+</xsl:template>
+-->
+
+<!--                                                                         -->
+
+<!--
+<xsl:template name="generate-statements">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="subject">
+    <xsl:call-template name="resource-uri">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+  </xsl:param>
+
+<xsl:variable name="reified-statement">
+  <xsl:value-of select="$node/@bagID"/>
+</xsl:variable>
+
+<xsl:apply-templates select="$node/@*" mode="property-attributes">
+  <xsl:with-param name="subject" select="$subject"/>
+</xsl:apply-templates>
+
+<xsl:apply-templates select="$node/*" mode="property-elements">
+  <xsl:with-param name="subject" select="$subject"/>
+  <xsl:with-param name="reified-statement" select="$reified-statement"/>
+</xsl:apply-templates>
+
+</xsl:template>
+-->
+
+</xsl:transform>

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf2dot.xsl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf2dot.xsl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf2dot.xsl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/samples/xslt/rdf2dot.xsl Fri Apr 13 01:56:01 2007
@@ -0,0 +1 @@
+<?xml version='1.0'?><!-- -*- mode: indented-text;-*- -->
<xsl:transform
    xmlns:xsl  ="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:web  ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:util ="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:g    ="http://www.w3.org/2001/02pd/gv#"
    >

<xsl:variable name="RCSId"
  select='"$Id: rdf2dot.xsl,v 1.1 2002/11/29 15:01:05 areggiori Exp $"'/>
<xsl:param name="Debug" select='0'/>

<div xmlns="http://www.w3.org/1999/xhtml">

<pre>
This transformation groks a limited subset of RDF:
  -- just one level of nesting (no Description/typedNodes
     as values of properties)
  -- properties are sorted by subject, collected
     in a Description element for that subject
  -- rdf:ID is not used; only rdf:about
  -- only absolute URIs are used

Arbitrary RDF can be converted to this form using
	  cwm --rdf foo.rdf --bySubject --base=bogus: > foo-limited.rdf

see <a href="http://www.w3.org/2000/10/swap/">Semantic Web
  Area for Play</a>
for details about cwm.
</pre>

<address>Dan Connolly <br class=""/>
$Id: rdf2dot.xsl,v 1.1 2002/11/29 15:01:05 areggiori Exp $</address>
</div>

<xsl:output method="text"/>

<xsl:param name="GVns"
	   select='"http://www.w3.org/2001/02pd/gv#"'/>

<xsl:template match="/web:RDF">
  <xsl:text>/* transformed by by </xsl:text>
  <xsl:value-of select='substring($RCSId, 2, string-length($RCSId)-2)'/>
  <xsl:text> */
</xsl:text>

  <xsl:for-each select="*/g:digraph/@web:resource">

    <!-- I suspect there's a way to use xsl:key instead
         of this /web:RDF/*[@web:about="..."] idiom
      -->
    <xsl:variable name="it" select="/web:RDF/*[@web:about=current()]"/>

    <xsl:text>digraph </xsl:text>
    <xsl:call-template name="eachGraph">
      <xsl:with-param name="it" select='$it'/>
    </xsl:call-template>

  </xsl:for-each>
</xsl:template>

<xsl:template name="eachGraph">
  <xsl:param name="it"/>
  <xsl:param name="cluster"/>

  <xsl:value-of select='conca
 t($cluster, generate-id($it))'/>
  <xsl:text> {
</xsl:text>

  <!-- graph attributes see Graphviz spec table 1 -->
  <xsl:for-each select='$it/*[namespace-uri() = $GVns and (
			      local-name() = "center"
		           or local-name() = "clusterrank"
		           or local-name() = "color"
		           or local-name() = "concentrate"
		           or local-name() = "fontcolor"
		           or local-name() = "fontname"
		           or local-name() = "fontsize"
		           or local-name() = "label"
		           or local-name() = "layerseq"
		           or local-name() = "margin"
		           or local-name() = "mclimit"
		           or local-name() = "nodesep"
		           or local-name() = "nslimit"
		           or local-name() = "ordering"
		           or local-name() = "orientation"
		           or local-name() = "page"
		           or local-name() = "rank"
		           or local-name() = "rankdir"
		           or local-name() = "ranksep"
		           or local-name() = "rati
 o"
		           or local-name() = "size"
			   )]'> <!--@@ ...others-->
    <xsl:value-of select='local-name()'/>
    <xsl:text>="</xsl:text>
    <xsl:value-of select='.'/> <!-- @@quoting? -->
    <xsl:text>";
</xsl:text>
  </xsl:for-each>

  <!-- explicit nodes -->
  <xsl:for-each select="$it/g:hasNode/@web:resource">
    <xsl:variable name="nodeURI" select='current()'/>
    <xsl:variable name="nodeElt" select='/web:RDF/*[@web:about=$nodeURI]'/>
    <xsl:if test='$nodeElt'>
      <xsl:call-template name="eachNode">
        <xsl:with-param name="graphElt" select='$it'/>
        <xsl:with-param name="nodeElt" select='$nodeElt'/>
        <xsl:with-param name="nodeURI" select='$nodeURI'/>
      </xsl:call-template>
    </xsl:if>
  </xsl:for-each>

  <xsl:for-each select="$it/g:subgraph/@web:resource">
    <xsl:variable name="it2" select="/web:RDF/*[@web:about=current()]"/>

    <xsl:text>subgraph </xsl:text>
    <xsl:call-template name="eachGraph">
      <xsl:with-param name="i
 t" select='$it2'/>
      <xsl:with-param name="cluster" select='"cluster"'/>
    </xsl:call-template>

  </xsl:for-each>

    <xsl:text>}
</xsl:text>
</xsl:template>

<xsl:template name="eachNode">
  <xsl:param name="graphElt"/>
  <xsl:param name="nodeElt"/>
  <xsl:param name="nodeURI"/>

  <xsl:text>"</xsl:text>
  <xsl:value-of select='$nodeURI'/>
  <xsl:text>" [</xsl:text>

  <!-- node attributes -->
  <xsl:for-each select='$nodeElt/*[namespace-uri() = $GVns and (
                                   local-name() = "label"
			        or local-name() = "color"
				or local-name() = "shape"
				or local-name() = "style"
				or local-name() = "fontcolor"
				or local-name() = "fontname"
				or local-name() = "fontsize"
				or local-name() = "height"
				or local-name() = "width"
				or local-name() = "layer"
				or local-name() = "URL"
				or local-name() = "sides"
				or local-name() = "shapefile")
				]'> <!-- "URL" not in the original file format docs, but seems to be suppor
 ted; cf http://www.graphviz.org/webdot/tut2.html-->
    <xsl:value-of select='local-name()'/>
    <xsl:text>="</xsl:text>
    <xsl:value-of select='.'/> <!-- @@quoting? -->
    <xsl:text>",
</xsl:text>
  </xsl:for-each>
  <xsl:text>];
</xsl:text>

  <!-- edges -->
  <xsl:for-each select="$nodeElt/*[@web:resource]"> <!-- iterate over all properties -->
    <!-- compute full name of property -->
    <xsl:variable name="obj" select='./@web:resource'/>
    <xsl:variable name="pred" select='concat(namespace-uri(),  local-name())'/>


    <xsl:if test='$Debug>4'>
    <xsl:message>propertyElt in nodeElt:
      subj: <xsl:value-of select='$nodeURI'/>
      pred: <xsl:value-of select='$pred'/>
    </xsl:message>
    </xsl:if>

    <xsl:choose>
      <xsl:when test='$graphElt/g:hasEdgeProperty/@web:resource=$pred'>
        <xsl:call-template name="doEdge">
          <xsl:with-param name="nodeURI" select='$nodeURI'/>
          <xsl:with-param name="pred" select='$pred'/>
          <xsl
 :with-param name="obj" select='$obj'/>
          <xsl:with-param name="edgeElt" select='/web:RDF/*[@web:about=$pred]'/>
          </xsl:call-template>

      </xsl:when>


      <xsl:when test='/web:RDF/g:EdgeProperty[@web:about=$pred]'>

        <xsl:message>
	  <xsl:value-of select='$pred'/> is an EdgeProperty.
	  A given property might be used to make edges
	  in one graph and not in another; so
	  EdgeProperty(p) isn't well-defined those p's.
	  It seems that edge-ness is a function of the
	  graph and the property; i.e. a relation between
	  them.

	  So EdgeProperty is deprecated... use hasEdgeProperty.

	  @@oops... what about g:style, g:label, etc... should
	  those be a function of the property and the graph?
	  Or should we have edgeLabel and nodeLabel properties?
	  Hmm...
	</xsl:message>

        <xsl:call-template name="doEdge">
          <xsl:with-param name="nodeURI" select='$nodeURI'/>
          <xsl:with-param name="pred" select='$pred'/>
          <xsl:with
 -param name="obj" select='$obj'/>
          <xsl:with-param name="edgeElt" select='/web:RDF/*[@web:about=$pred]'/>
        </xsl:call-template>
      </xsl:when>

      <xsl:when test='/web:RDF/*[@web:about=$pred]/web:type
                       [@web:resource=concat($GVns, "EdgeProperty")]'>
        <xsl:message>
	  <xsl:value-of select='$pred'/> is an EdgeProperty.

	  A given property might be used to make edges
	  in one graph and not in another; so
	  EdgeProperty(p) isn't well-defined those p's.
	  It seems that edge-ness is a function of the
	  graph and the property; i.e. a relation between
	  them.

	  So EdgeProperty is deprecated... use hasEdgeProperty

	  @@oops... what about g:style, g:label, etc... should
	  those be a function of the property and the graph?
	  Or should we have edgeLabel and nodeLabel properties?
	  Hmm... maybe
		 my:graph g:nodeType my:Marbles;
		    g:edgeType my:GEdgeProp;
		    g:labelProp my:label;
		    g:styleProp my:styleProp;
	</xsl:
 message>

        <xsl:call-template name="doEdge">
          <xsl:with-param name="nodeURI" select='$nodeURI'/>
          <xsl:with-param name="pred" select='$pred'/>
          <xsl:with-param name="obj" select='$obj'/>
          <xsl:with-param name="edgeElt" select='/web:RDF/*[@web:about=$pred]'/>
          </xsl:call-template>

      </xsl:when>

      <xsl:otherwise>
        <!-- nothing -->
      </xsl:otherwise>
    </xsl:choose>

  </xsl:for-each>

</xsl:template>

<xsl:template name="doEdge">
        <xsl:param name="nodeURI"/>
        <xsl:param name="pred"/>
        <xsl:param name="obj"/>
        <xsl:param name="edgeElt"/>

          <xsl:if test='$Debug>4'>
            <xsl:message>EdgeProperty:
              pred: <xsl:value-of select='$pred'/>
              obj: <xsl:value-of select='$obj'/>
            </xsl:message>
          </xsl:if>

	     <xsl:text>"</xsl:text>
             <xsl:value-of select='$nodeURI'/>
	     <xsl:text>" -&gt; "</xsl:text>
	     <xs
 l:value-of select='$obj'/>
	     <xsl:text>"</xsl:text>


             <xsl:text> [ /* edge attributes */
</xsl:text>
             <!-- edge attributes all except id -->
             <xsl:for-each select='$edgeElt/*[local-name() = "label"
			          or local-name() = "color"
			          or local-name() = "decorate"
			          or local-name() = "dir"
			          or local-name() = "fontcolor"
			          or local-name() = "fontname"
			          or local-name() = "fontsize"
			          or local-name() = "layer"
			          or local-name() = "minlen"
			          or local-name() = "style"
			          or local-name() = "weight"
				  ]'> <!--@@ ...others-->
               <xsl:value-of select='local-name()'/>
               <xsl:text>="</xsl:text>
               <xsl:value-of select='.'/> <!-- @@quoting? -->
               <xsl:text>",
</xsl:text>
             </xsl:for-each>
             <xsl:text>];
</xsl:text>
</xsl:template>



<!-- don't pass text thru -->
<xsl:te
 mplate match="text()|@*">
</xsl:template>


</xsl:transform>
\ No newline at end of file



Mime
View raw message