-
problem with XML / XSLT / SVG
Hi,
I have a little problem with XML, my goal is to parse an XML file with an XSL stylesheet to generate SVG.
This is the XML content :
<?xml version="1.0" encoding="ISO-8859-1"?>
<tree>
<node depth="1" width="4" label="a">
<node depth="2" width="1" label="b"/>
<node depth="2" width="1" label="c"/>
<node depth="2" width="2" label="d">
<node depth="3" width="1" label="e"/>
<node depth="3" width="1" label="f"/>
</node>
</node>
</tree>
And this is the XSL file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Layout to SVG -->
<!-- Magnifying factor -->
<xsl:param name="hedge.scale" select="10"/>
<!-- Convert layout to SVG -->
<xsl:template match="tree" name="layout2svg">
<!-- Find depth of the tree -->
<xsl:variable name="maxDepth">
<xsl:for-each select="node">
<xsl:sort select="@depth" data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="@depth"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!-- Create SVG wrapper -->
<svg:svg xmlns:svg = "http://www.w3.org/2000/svg" viewBox="0 0 {sum(node/@width) * 2 * $hedge.scale} {$maxDepth * 2 * $hedge.scale}">
<svg:g transform="translate(0,-{$hedge.scale div 2}) scale({$hedge.scale})">
<xsl:apply-templates select="node" mode="layout2svg"/>
</svg:g>
</svg:svg>
</xsl:template>
<!-- Draw one node -->
<xsl:template match="node" mode="layout2svg">
<svg:text x="4" y="1.8" style="text-anchor: middle; font-size: 0.9;">xxx</svg:text>
</xsl:template>
</xsl:stylesheet>
The document does not load, like if I had an infinite loop .. the page loads with no content if I remove the svg line from the second xsl:template and I dunno why ...
Please can someone help me ?
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks