R
Rolf Kemper
Dear All,
somehow I remember that such or similar question was discussed already
somewhere. But I can't find it anymore.
I have a template calling itself. As long it goes deeper into the
hierarchy (by the key) I can set the CurrentY parameter by itself +
some constant correctly. Hence which each call the CurrentY gets
bigger.
But when the template reaches a leave and the caller is poped from
stack the old parameter is valid. Hence the absolute sum is lost.
Finally, as a minimun information, I would like to know how often the
recursive template has been called at all (at any time during
recursive execution).
Please find below a xslt which outputs svg rectangles with some text
(the OrgaID) Actually it should draw many rectangles, but as the
currentY is not computed correctly the rectangles overlap and we see
only 5 (which is determined by the maximum hierarchy depth) .
Any hint and help is highly welcome
Rolf
################## xslt ####################################
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:a3="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"<xslutput method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:key name="kOrga" match="/Orga/OrgaBox" use="@BelongsTo"/>
<xsl:template match="/">
<svg contentScriptType="text/ecmascript" width="500" height="500"
viewBox="0 0 10000 30000" a3:scriptImplementation="Adobe"
zoomAndPan="magnify" contentStyleType="text/css" id="PinFunction"
preserveAspectRatio="xMidYMid meet">
<g id="all" transform="translate(2000,2000)">
<xsl:apply-templates select="/Orga/OrgaBox[@OrgaID=169]"/><!--
this is the top one -->
</g>
</svg>
</xsl:template>
<xsl:template name="BuildBoxes" match="*">
<xslaram name="CurrentX" select="0"/>
<xslaram name="CurrentY" select="0"/>
<g>
<xsl:attribute name="transform"><xsl:value-of
select="concat('translate(',$CurrentX,',',$CurrentY,')')"/></xsl:attribute>
<rect style="fill:yellow;stroke:red;stroke-width:10" width="5000"
height="2000"/>
<text x="200" y="1000" pointer-events="none"
style="fill:black;font-size:800">
<xsl:value-of select="@OrgaID"/>
</text>
</g>
<xsl:apply-templates select="key('kOrga',@OrgaID)">
<xsl:with-param name="CurrentY" select="$CurrentY+3000"/>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
######## xml test data ###########################################
<?xml version="1.0" encoding="UTF-8"?>
<Orga>
<OrgaBox OrgaID="131" BelongsTo="169" />
<OrgaBox OrgaID="132" BelongsTo="135" />
<OrgaBox OrgaID="133" BelongsTo="169" />
<OrgaBox OrgaID="135" BelongsTo="169" />
<OrgaBox OrgaID="136" BelongsTo="169" />
<OrgaBox OrgaID="137" BelongsTo="171" />
<OrgaBox OrgaID="138" BelongsTo="171" />
<OrgaBox OrgaID="139" BelongsTo="171" />
<OrgaBox OrgaID="140" BelongsTo="171" />
<OrgaBox OrgaID="141" BelongsTo="136" />
<OrgaBox OrgaID="142" BelongsTo="132" />
<OrgaBox OrgaID="143" BelongsTo="135" />
<OrgaBox OrgaID="144" BelongsTo="135" />
<OrgaBox OrgaID="145" BelongsTo="143" />
<OrgaBox OrgaID="146" BelongsTo="132" />
<OrgaBox OrgaID="147" BelongsTo="133" />
<OrgaBox OrgaID="148" BelongsTo="162" />
<OrgaBox OrgaID="149" BelongsTo="139" />
<OrgaBox OrgaID="150" BelongsTo="139" />
<OrgaBox OrgaID="151" BelongsTo="139" />
<OrgaBox OrgaID="155" BelongsTo="182" />
<OrgaBox OrgaID="156" BelongsTo="136" />
<OrgaBox OrgaID="157" BelongsTo="139" />
<OrgaBox OrgaID="158" BelongsTo="136" />
<OrgaBox OrgaID="159" BelongsTo="133" />
<OrgaBox OrgaID="160" BelongsTo="137" />
<OrgaBox OrgaID="161" BelongsTo="138" />
<OrgaBox OrgaID="162" BelongsTo="138" />
<OrgaBox OrgaID="163" BelongsTo="138" />
<OrgaBox OrgaID="164" BelongsTo="139" />
<OrgaBox OrgaID="165" BelongsTo="139" />
<OrgaBox OrgaID="166" BelongsTo="140" />
<OrgaBox OrgaID="167" BelongsTo="140" />
<OrgaBox OrgaID="168" BelongsTo="140" />
<OrgaBox OrgaID="169" BelongsTo="0" />
<OrgaBox OrgaID="170" BelongsTo="169" />
<OrgaBox OrgaID="171" BelongsTo="169" />
<OrgaBox OrgaID="172" BelongsTo="169" />
<OrgaBox OrgaID="174" BelongsTo="182" />
<OrgaBox OrgaID="175" BelongsTo="138" />
<OrgaBox OrgaID="182" BelongsTo="136" />
<OrgaBox OrgaID="192" BelongsTo="132" />
</Orga>
################ END #####################################
somehow I remember that such or similar question was discussed already
somewhere. But I can't find it anymore.
I have a template calling itself. As long it goes deeper into the
hierarchy (by the key) I can set the CurrentY parameter by itself +
some constant correctly. Hence which each call the CurrentY gets
bigger.
But when the template reaches a leave and the caller is poped from
stack the old parameter is valid. Hence the absolute sum is lost.
Finally, as a minimun information, I would like to know how often the
recursive template has been called at all (at any time during
recursive execution).
Please find below a xslt which outputs svg rectangles with some text
(the OrgaID) Actually it should draw many rectangles, but as the
currentY is not computed correctly the rectangles overlap and we see
only 5 (which is determined by the maximum hierarchy depth) .
Any hint and help is highly welcome
Rolf
################## xslt ####################################
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:a3="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"<xslutput method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:key name="kOrga" match="/Orga/OrgaBox" use="@BelongsTo"/>
<xsl:template match="/">
<svg contentScriptType="text/ecmascript" width="500" height="500"
viewBox="0 0 10000 30000" a3:scriptImplementation="Adobe"
zoomAndPan="magnify" contentStyleType="text/css" id="PinFunction"
preserveAspectRatio="xMidYMid meet">
<g id="all" transform="translate(2000,2000)">
<xsl:apply-templates select="/Orga/OrgaBox[@OrgaID=169]"/><!--
this is the top one -->
</g>
</svg>
</xsl:template>
<xsl:template name="BuildBoxes" match="*">
<xslaram name="CurrentX" select="0"/>
<xslaram name="CurrentY" select="0"/>
<g>
<xsl:attribute name="transform"><xsl:value-of
select="concat('translate(',$CurrentX,',',$CurrentY,')')"/></xsl:attribute>
<rect style="fill:yellow;stroke:red;stroke-width:10" width="5000"
height="2000"/>
<text x="200" y="1000" pointer-events="none"
style="fill:black;font-size:800">
<xsl:value-of select="@OrgaID"/>
</text>
</g>
<xsl:apply-templates select="key('kOrga',@OrgaID)">
<xsl:with-param name="CurrentY" select="$CurrentY+3000"/>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
######## xml test data ###########################################
<?xml version="1.0" encoding="UTF-8"?>
<Orga>
<OrgaBox OrgaID="131" BelongsTo="169" />
<OrgaBox OrgaID="132" BelongsTo="135" />
<OrgaBox OrgaID="133" BelongsTo="169" />
<OrgaBox OrgaID="135" BelongsTo="169" />
<OrgaBox OrgaID="136" BelongsTo="169" />
<OrgaBox OrgaID="137" BelongsTo="171" />
<OrgaBox OrgaID="138" BelongsTo="171" />
<OrgaBox OrgaID="139" BelongsTo="171" />
<OrgaBox OrgaID="140" BelongsTo="171" />
<OrgaBox OrgaID="141" BelongsTo="136" />
<OrgaBox OrgaID="142" BelongsTo="132" />
<OrgaBox OrgaID="143" BelongsTo="135" />
<OrgaBox OrgaID="144" BelongsTo="135" />
<OrgaBox OrgaID="145" BelongsTo="143" />
<OrgaBox OrgaID="146" BelongsTo="132" />
<OrgaBox OrgaID="147" BelongsTo="133" />
<OrgaBox OrgaID="148" BelongsTo="162" />
<OrgaBox OrgaID="149" BelongsTo="139" />
<OrgaBox OrgaID="150" BelongsTo="139" />
<OrgaBox OrgaID="151" BelongsTo="139" />
<OrgaBox OrgaID="155" BelongsTo="182" />
<OrgaBox OrgaID="156" BelongsTo="136" />
<OrgaBox OrgaID="157" BelongsTo="139" />
<OrgaBox OrgaID="158" BelongsTo="136" />
<OrgaBox OrgaID="159" BelongsTo="133" />
<OrgaBox OrgaID="160" BelongsTo="137" />
<OrgaBox OrgaID="161" BelongsTo="138" />
<OrgaBox OrgaID="162" BelongsTo="138" />
<OrgaBox OrgaID="163" BelongsTo="138" />
<OrgaBox OrgaID="164" BelongsTo="139" />
<OrgaBox OrgaID="165" BelongsTo="139" />
<OrgaBox OrgaID="166" BelongsTo="140" />
<OrgaBox OrgaID="167" BelongsTo="140" />
<OrgaBox OrgaID="168" BelongsTo="140" />
<OrgaBox OrgaID="169" BelongsTo="0" />
<OrgaBox OrgaID="170" BelongsTo="169" />
<OrgaBox OrgaID="171" BelongsTo="169" />
<OrgaBox OrgaID="172" BelongsTo="169" />
<OrgaBox OrgaID="174" BelongsTo="182" />
<OrgaBox OrgaID="175" BelongsTo="138" />
<OrgaBox OrgaID="182" BelongsTo="136" />
<OrgaBox OrgaID="192" BelongsTo="132" />
</Orga>
################ END #####################################