Testing with Xalan it seems it has a problem with - placed immediately
after 1.5 so try again with
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg">
<xsl:output indent="yes"/>
<xsl:param name="linefactor" select="1"/>
<xsl:key name="vertex" match="coordinates" use="@id"/>
<xsl:variable name="root" select="/"/>
<xsl:template match="embedding">
<svg:svg width="3" height="3">
<xsl:apply-templates select="document('graph.xml')/graph"/>
<xsl:apply-templates select="coordinates"/>
</svg:svg>
</xsl:template>
<xsl:template match="coordinates">
<svg:circle r="{0.075*$linefactor}"
style="stroke:black; stroke-width:{0.05*$linefactor}; fill:white;"
cx="{number(double[1]/@value)+1.5}" cy="{1.5 -
number(double[2]/@value)}"/>
</xsl:template>
<xsl:template match="edge">
<xsl:variable name="this" select="."/>
<xsl:for-each select="$root">
<svg:line style="stroke:black; stroke-width:{0.05*$linefactor};
fill:none;"
x1="{number(key('vertex',$this/@from)/double[1]/@value)+1.5}"
y1="{1.5 - number(key('vertex',$this/@from)/double[2]/@value)}"
x2="{number(key('vertex',$this/@to)/double[1]/@value)+1.5}"
y2="{1.5 - number(key('vertex',$this/@to)/double[2]/@value)}"/>
</xsl:for-each>
</xsl:template>
</xsl:transform>
See the following page for determining what Xalan you are running:
http://xml.apache.org/xalan-j/faq.html#faq-N10064
Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Nico Van Cleemput wrote:
Hi,
I'm sorry, but this still returns NaN in JDK 6, and the desired output
in JDK 5.
Greets,
Nico Van Cleemput
Ghent University
On 30 Jan 2007, at 09:39, George Cristian Bina wrote:
Hi Niko,
I think it is a problem with the context the key function is executed
in. Change the context to the main document and it should work, see
below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg">
<xsl:output indent="yes"/>
<xsl:param name="linefactor" select="1"/>
<xsl:key name="vertex" match="coordinates" use="@id"/>
<xsl:variable name="root" select="/"/>
<xsl:template match="embedding">
<svg:svg width="3" height="3">
<xsl:apply-templates select="document('graph.xml')/graph"/>
<xsl:apply-templates select="coordinates"/>
</svg:svg>
</xsl:template>
<xsl:template match="coordinates">
<svg:circle r="{0.075*$linefactor}"
style="stroke:black; stroke-width:{0.05*$linefactor}; fill:white;"
cx="{number(double[1]/@value)+1.5}"
cy="{1.5-number(double[2]/@value)}"/>
</xsl:template>
<xsl:template match="edge">
<xsl:variable name="this" select="."/>
<xsl:for-each select="$root">
<svg:line style="stroke:black; stroke-width:{0.05*$linefactor};
fill:none;"
x1="{number(key('vertex',$this/@from)/double[1]/@value)+1.5}"
y1="{1.5-number(key('vertex',$this/@from)/double[2]/@value)}"
x2="{number(key('vertex',$this/@to)/double[1]/@value)+1.5}"
y2="{1.5-number(key('vertex',$this/@to)/double[2]/@value)}"/>
</xsl:for-each>
</xsl:template>
</xsl:transform>
Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--