<?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:param name="entry" select="'http://www.xs4all.nl/~pboot/p01/p01rdfs.rdf#SignVehicleProp'"/>

<xsl:variable name="action" saxon:assignable="yes"/>

<xsl:include href="navclass.xsl"/>
<xsl:include href="function.xsl"/>

<xsl:output method="text" />

<xsl:template match="/">
	<xsl:for-each select="//statement[
		predicate/text() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' and
		object/text() = 'http://www.w3.org/2000/01/rdf-schema#Class'
		]">
		<saxon:output method="text" href="{concat('temp\',concat(pb:local-part(subject/text()),'.dot'))}">
		digraph G { rankdir="LR";margin=".1";fontsize="14";size="10,13"
			<saxon:assign name="action" select="'propshortplusurl'"/>
			subgraph cluster_c0 {label="class with related properties (if any):"; labeljust="r"; rank="samerank";
			<xsl:apply-templates select="." mode="classpropin"/>
			<xsl:apply-templates select="." mode="classpropout"/> 
			<xsl:value-of select="pb:local-part(subject/text())"/> [color="red",URL="emblem.html?class=<xsl:value-of select="pb:local-part(subject/text())"/>"]
			;}
			<saxon:assign name="action" select="'classshortplusurl'"/>
			subgraph cluster_c2 {label="class supertypes:"; 
			<xsl:apply-templates select="." mode="classsubof"/> 
			;}
			subgraph cluster_c3 {label="class subtypes:";
			<xsl:apply-templates select="." mode="classhassub"/> 
			;}
			<saxon:assign name="action" select="'propedgein'"/>
			<xsl:apply-templates select="." mode="classpropin"/>
			<saxon:assign name="action" select="'propedgeout'"/>
			<xsl:apply-templates select="." mode="classpropout"/>
			<saxon:assign name="action" select="'classedgeout'"/>
			<xsl:apply-templates select="." mode="classsubof"/> 
			<saxon:assign name="action" select="'classedgein'"/>
			<xsl:apply-templates select="." mode="classhassub"/> 
		}
		</saxon:output>
	</xsl:for-each>
	<xsl:for-each select="//statement[
		predicate/text() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' and
		object/text() = 'http://www.w3.org/2000/01/rdf-schema#Class'
		]">
		<saxon:output method="text" href="{concat('temp\map',concat(pb:local-part(subject/text()),'.txt'))}">
		&lt;map name="map<xsl:value-of select="pb:local-part(subject/text())"/>"&gt;
		</saxon:output>
	</xsl:for-each>
	<saxon:output method="text" href="genclasspics.cmd">
		<xsl:text>&#x0D;&#x0A;type classmodelbegin.txt &gt; classmodel.html</xsl:text>
		<xsl:for-each select="//statement[
			predicate/text() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' and
			object/text() = 'http://www.w3.org/2000/01/rdf-schema#Class'
			]">
			<xsl:text>&#x0D;&#x0A;\programs\ATT\graphviz\bin\dot -ojpg\</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>.jpg -Tjpg &lt;temp\</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>.dot</xsl:text>
			<xsl:text>&#x0D;&#x0A;\programs\ATT\graphviz\bin\dot -otemp\</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>.map -Tcmap &lt;temp\</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>.dot</xsl:text>
			<xsl:text>&#x0D;&#x0A;type temp\map</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>.txt &gt;&gt; classmodel.html</xsl:text>
			<xsl:text>&#x0D;&#x0A;type temp\</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>.map &gt;&gt; classmodel.html</xsl:text>
			<xsl:text>&#x0D;&#x0A;type mapend.txt &gt;&gt; classmodel.html</xsl:text>
		</xsl:for-each>
		<xsl:text>&#x0D;&#x0A;type classmodelend.txt &gt;&gt; classmodel.html</xsl:text>
	</saxon:output>
</xsl:template>

<xsl:template match="subject|object">
	<xsl:choose>
		<xsl:when test="$action='classshortplusurl'">
			<xsl:value-of select="pb:local-part(text())"/> [URL="classmodel.html?showclass=<xsl:value-of select="pb:local-part(text())"/>"]
		</xsl:when>
		<xsl:when test="$action='propshortplusurl'">
			<xsl:value-of select="pb:local-part(text())"/> [URL="classmodel.html?showprop=<xsl:value-of select="pb:local-part(text())"/>"]
		</xsl:when>
		<xsl:when test="$action='propedgein'">
			<xsl:value-of select="pb:local-part(text())"/> -> <xsl:value-of select="pb:local-part(parent::*/object/text())"/>  [label="domain",constraint="false"];
		</xsl:when>
		<xsl:when test="$action='propedgeout'">
			<xsl:value-of select="pb:local-part(parent::*/object/text())"/> -> <xsl:value-of select="pb:local-part(text())"/>  [label="range",constraint="false"];
		</xsl:when>
		<xsl:when test="$action='classedgeout'">
			<xsl:value-of select="pb:local-part(parent::*/subject/text())"/> -> <xsl:value-of select="pb:local-part(text())"/> ;
		</xsl:when>
		<xsl:when test="$action='classedgein'">
			<xsl:value-of select="pb:local-part(text())"/> -> <xsl:value-of select="pb:local-part(parent::*/object/text())"/> ;
		</xsl:when>
		<xsl:otherwise>
			<xsl:message>Onbegrijpelijke actie subject/object <xsl:value-of select="$action"/></xsl:message>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>


</xsl:stylesheet>
