| | 
xgmmlContext1xsl.xsl <?xml-stylesheet type="text/xsl" href="xgmmlContext1xsl.xsl"?> <!DOCTYPE graph SYSTEM "xgmml.dtd"> <graph xmlns="http://www.cs.rpi.edu/XGMML" > <node id="1" label="timestamp" weight="0"> <graphics type="circle" x="270" y="90" h="10" > </graphics> <att name="systemtimestamp" value="2004-06-19T17:47:33 07:00"/> <.!--EXSLT gets time and date from system puts it in node--> </node> <node id="2" label="AtRight" weight="0"> <graphics type="circle" x="350" y="190" h="10" > </graphics> <att name="object" value="1"/> <att name="object" value="2"/> <att name="origin" value="upperleft"/> </node> <node id="3" label="object1" weight="0"> <graphics type="circle" x="190" y="190" h="10" > </graphics> <att name="xcoord" value="110"/> <att name="ycoord" value="35"/> <att name="origin" value="upperleft"/> </node> <node id="4" label="object2" weight="0"> <graphics type="circle" x="290" y="290" h="10" > </graphics> <att name="xcoord" value="120"/> <att name="ycoord" value="39"/> <att name="origin" value="upperleft"/> </node> <node id="5" label="object1" weight="0"> <graphics type="circle" x="390" y="390" h="10" > </graphics> <att name="xcoord" value="210"/> <att name="ycoord" value="27"/> <att name="origin" value="upperleft"/> </node> <node id="7" label="object2" weight="0"> <graphics type="circle" x="490" y="090" h="10" > </graphics> <att name="xcoord" value="220"/> <att name="ycoord" value="29"/> <att name="origin" value="upperleft"/> </node> <edge source="2" target="4" weight="0" label="Edge from node AtRight to node object2" > </edge> <edge source="1" target="2" weight="0" label="Edge from node timestamp to node AtRight" > </edge> <edge source="2" target="3" weight="0" label="Edge from node AtRight to node object1" > </edge> </graph>
XGMMLgraphIntoSVG <?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xgmml="http://www.cs.rpi.edu/XGMML" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date"> <xsl:import href="date.msxsl.xsl" /> <!--put each ATT with its ID= stacked downward at the bottom of the SVG picture starting at x=100 y=700--> <xsl:output method="html" version="1.0" indent="yes"/> <xsl:key name="nodetable" match="xgmml:node" use="@id" /> <xsl:template match="/"> <html> <head> <title>David's Extreme 2004 Paper Context XGMML graph into SVG<./title> </head> <!--#993300 rust brown--><.!--#ff9900 orange--><!--#cccc99 pastel green--><.!--#c3d3c3 mulberrygreen--> <body background="bckmatte.gif"> <.!--bgColor="#c3d3c3"--> <!--<div>Its <.xsl:value-of select="date:time()"/> on <xsl:value-of select="date:date()"/> and all is swell. [<xsl:value-of select="date:dateTime()"/>]<./div> old code for debugging purposes only--> <xsl:variable name="rConstant" select="10"/> <.!-- old code for debugging purposes only--> <xsl:variable name="rConstantplus10" select="20"/> <.!--old code for debugging purposes only--> <?xml version="1.0" encoding="iso-8859-1"?><br/> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" <.br/> "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd"><.br/> <svg xmlns:a="http://www.adobe.com/svg10-extensions" <.br/> width="16cm" height="14cm" viewBox="0 0 1000 900"><.br/> <desc>Copyright 2001 - 2004 David Dodds. xgmml example of context graph <br/> diagram SVG visualization rendering with system datetimestamp</desc><br/> <!--the value of rConstantplus10 is <xsl:value-of select="$rConstantplus10"/>.old code for debugging purposes only--> <xsl:apply-templates /> <p/></svg><br/> </body> </html> </xsl:template> <xsl:template match="xgmml:graph"> <xsl:apply-templates /> </xsl:template> <xsl:template match="xgmml:node"> <xsl:apply-templates /> </xsl:template> <xsl:template match="xgmml:graphics"> <!--h for height in the DTD was used instead of r for radius because r isnt in the DTD--> <!--d for depth in the DTD is used to represent the z-axis depth. z-axis is perpendicular to the screen--> <xsl:choose> <xsl:when test="@type = 'circle'"> <circle id="<.xsl:value-of select="../@id"/>" cx="<xsl:value-of select="@x"/>" cy="<xsl:value-of select="@y"/>" <!--when xgmml:graphics/@type="circle" then 'r='<xsl:value-of select="@h"/>--> r="<xsl:value-of select="@h"/>" fill="black" stroke="blue" stroke-width="2"/><.br/> </xsl:when> <xsl:otherwise> <text x="<.xsl:value-of select='10 @h @x'/>" y="<xsl:value-of select='10 @y'/>"> type NOT = circle. build some other type= based SVG code here. type=<xsl:value-of select="@type"/> </text><br/> </xsl:otherwise> </xsl:choose> <text x="<.xsl:value-of select='10 @h @x'/>" y="<xsl:value-of select="10 @y"/>" >nodelabel<.xsl:value-of select="../@id"/>: <xsl:value-of select="../@label"/> nodeweight<xsl:value-of select="../@id"/>: <.xsl:value-of select="../@weight"/></text><p/> </xsl:template> <xsl:template match="xgmml:att"> <!-- put the attribute line by line into a table line towards the bottom of the display--> <!--that means changing the att template and meerely putting the line into TR--> <!--unfortunately that means using HTML Table *after* the location of the /svg! oops--> <!--so a Table effect has to be coded whereby text x is always the same starting location--> <!--and text y location is set to some base value for the first line, and incremented by--> <!-- 15 for each succeeding att text line--> <xsl:variable name="coord" select="key('nodetable', ../@id)"/> id="<xsl:value-of select="../@id"/> " <text x="<.xsl:value-of select='$coord/xgmml:graphics/@x'/>" y="<xsl:value-of select='$coord/xgmml:graphics/@y 500'/>" >attname: <.xsl:value-of select="@name"/> <xsl:choose> <xsl:when test="@name = 'systemtimestamp'"> attvalue: <xsl:value-of select="date:dateTime()"/></text> <p/> </xsl:when> <xsl:otherwise> <!--attribute name NOT = systemtimestamp--> attvalue: <xsl:value-of select="@value"/></text> <p/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="xgmml:edge"> <!--this green output is for debugging purposes only and isnt part of SVG output in finished program--> <!--source is an id value of an (SVG) graphic object earlier in this program's data/code--> <!--the id value here is to be used as an index reference to get the appropriate x,y values for line ends--> <!--target is an id value of an (SVG) graphic object earlier in this program's data/code--> <!--<FONT color="green"> edge source=<xsl:value-of select="@source"/> , target=<xsl:value-of select="@target"/> , weight=<xsl:value-of select="@weight"/> , label=<xsl:value-of select="@label"/> .<.br/> </FONT>--> <xsl:variable name="srce" select="key('nodetable', @source)"/> <line x1="<.xsl:value-of select='$srce/xgmml:graphics/@x'/>" y1="<xsl:value-of select='$srce/xgmml:graphics/@y'/>" <xsl:variable name="trgt" select="key('nodetable', @target)"/> x2="<xsl:value-of select='$trgt/xgmml:graphics/@x'/>" y2="<xsl:value-of select='$trgt/xgmml:graphics/@y'/>" stroke="black" stroke-width="1"/>
<!--once I have the two x,y end point values I code a calculation (here) that computes the line's center--> <!--x=(x1 x2)/2 y=(y1 y2)/2 ( some offset value (~10) to move away from edge-line)--> <xsl:variable name="x1" select='$srce/xgmml:graphics/@x'/> <xsl:variable name="y1" select='$srce/xgmml:graphics/@y'/> <xsl:variable name="x2" select='$trgt/xgmml:graphics/@x'/> <xsl:variable name="y2" select='$trgt/xgmml:graphics/@y'/> <br/><text x="<.xsl:value-of select='(($x1 $x2) div 2) 10'/>" <!--calculate the slope m. if the line is at or near horizontal make the y offset 25 instead of 10--> y="<xsl:value-of select='(($y1 $y2) div 2) 20'/>" >lineweight: <.xsl:value-of select="@weight"/> <xsl:value-of select="../@label"/> linelabel: <xsl:value-of select="@label"/></text><p/> </xsl:template> <!-- --> </xsl:stylesheet>
| |