<?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="navnodeinoutprop.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'
		]">
		<saxon:output method="text" href="{concat('temp\',concat(pb:local-part(subject/text()),'.dot'))}">
		digraph G { rankdir="LR";margin=".1";fontsize="14";size="9,7"
			<saxon:assign name="action" select="'name'"/>
			subgraph cluster_c0 {label="sign is property of:"; labeljust="r"; 
			<xsl:apply-templates select="." mode="nodein"/>
			;}
			subgraph cluster_c1 {label="sign has properties:" 
			<xsl:apply-templates select="." mode="nodeout"/>
			;}
			subgraph cluster_c2 {label="sign is of type:";style="invis"; rank="samerank";
				<xsl:value-of select="pb:local-part(object/text())"/> [shape="hexagon",URL="classmodel.html?showclass=<xsl:value-of select="pb:local-part(object/text())"/>"]
				<xsl:value-of select="pb:local-part(subject/text())"/> [color="red",URL="emblem.html?sign=<xsl:value-of select="pb:local-part(subject/text())"/><xsl:text>&amp;amp;</xsl:text>class=<xsl:value-of select="pb:local-part(object/text())"/>"]
			;}
			<saxon:assign name="action" select="'edge'"/>
			<xsl:apply-templates select="." mode="nodein"/>
			<xsl:apply-templates select="." mode="nodeout"/>
			<xsl:value-of select="pb:local-part(subject/text())"/> -> <xsl:value-of select="pb:local-part(object/text())"/> [constraint="false"]
		}
		</saxon:output>
	</xsl:for-each>
	<saxon:output method="xml" omit-xml-declaration="yes" href="temp\signdescdivs.xml">
		<div>
			<xsl:for-each select="//statement[
			predicate/text() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
			]">
				<div id="{pb:local-part(subject/text())}" style="display:none">
					<xsl:variable name="type">
						<xsl:apply-templates select="subject" mode="nodeclass"/>
					</xsl:variable>
					<table>
						<colgroup span="2" valign="top"/>
						<tr>
							<td><b>Shown here:</b></td>
							<td>Sign or sign vehicle with id: 
								<xsl:value-of select="pb:local-part(subject/text())"/>
								of type: 
								<xsl:value-of select="$type"/></td>
						</tr>
						<tr>
							<xsl:choose>
								<xsl:when test="$type='TextFrag'">
									<td><b>Raw text of text fragment:</b></td>
									<td><xsl:apply-templates select="document(pb:global-part(subject/text()))//*[@id=pb:local-part(current()/subject/text())]" mode="plain"/></td>
								</xsl:when>
								<xsl:when test="$type=ImgFrag"/>
								<xsl:otherwise>
									<td><b>Meaning of sign:</b></td>
									<td><xsl:apply-templates select="subject" mode="nodemeaning"/></td>
								</xsl:otherwise>
							</xsl:choose>
						</tr>
					</table>
					 
					<br/>
				</div>
			</xsl:for-each>
		</div>
	</saxon:output>
	<xsl:for-each select="//statement[
		predicate/text() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
		]">
		<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="genpics.cmd">
		<xsl:text>&#x0D;&#x0A;type modelbegin.txt &gt; signmodel.html</xsl:text>
		<xsl:text>&#x0D;&#x0A;type temp\signdescdivs.xml &gt;&gt; signmodel.html</xsl:text>
		<xsl:for-each select="//statement[
			predicate/text() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
			]">
			<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; signmodel.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; signmodel.html</xsl:text>
			<xsl:text>&#x0D;&#x0A;type mapend.txt &gt;&gt; signmodel.html</xsl:text>
		</xsl:for-each>
		<xsl:text>&#x0D;&#x0A;type modelend.txt &gt;&gt; signmodel.html</xsl:text>
	</saxon:output>
</xsl:template>

<xsl:template match="statement" mode="arcactionin">
	<xsl:choose>
		<xsl:when test="$action='name'">
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text> [label="</xsl:text>
			<xsl:apply-templates select="subject" mode="nodeclass"/>
			<xsl:text>",URL="signmodel.html?show=</xsl:text>
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text>"] </xsl:text>
		</xsl:when>
		<xsl:when test="$action='edge'">
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text> -> </xsl:text>
			<xsl:value-of select="pb:local-part(object/text())"/>
			<xsl:text> [label="</xsl:text>
			<xsl:value-of select="pb:local-part(predicate/text())"/>
			<xsl:text>",URL="classmodel.html?showprop=</xsl:text>
			<xsl:value-of select="pb:local-part(predicate/text())"/>
			<xsl:text>"];
			</xsl:text>
		</xsl:when>
		<xsl:otherwise>
			<xsl:message>arcactionin onbegrijpelijk</xsl:message>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="statement" mode="arcactionout">
	<xsl:choose>
		<xsl:when test="$action='name' and object/@type='resource'">
			<xsl:value-of select="pb:local-part(object/text())"/>
			<xsl:text> [label="</xsl:text>
			<xsl:apply-templates select="object" mode="nodeclass"/>
			<xsl:text>",URL="signmodel.html?show=</xsl:text>
			<xsl:value-of select="pb:local-part(object/text())"/>
			<xsl:text>"] </xsl:text>
		</xsl:when>
		<xsl:when test="$action='name' and object/@type='literal'">
			<xsl:value-of select="concat('t',count(preceding::object[@type='literal']))"/>
			<xsl:text> [shape="box"] </xsl:text>
		</xsl:when>
		<xsl:when test="$action='edge'">
			<xsl:value-of select="pb:local-part(subject/text())"/>
			<xsl:text> -> </xsl:text>
			<xsl:choose>
				<xsl:when test="object/@type='resource'">
					<xsl:value-of select="pb:local-part(object/text())"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="concat('t',count(preceding::object[@type='literal']))"/>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text> [label="</xsl:text>
			<xsl:value-of select="pb:local-part(predicate/text())"/>
			<xsl:text>",URL="classmodel.html?show=prop</xsl:text>
			<xsl:value-of select="pb:local-part(predicate/text())"/>
			<xsl:text>"];
			</xsl:text>
		</xsl:when>
		<xsl:otherwise>
			<xsl:message>arcactionout onbegrijpelijk</xsl:message>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

</xsl:stylesheet>
