Project

Profile

Help

Bug #1545 » svg-t5-browser-v2-test.xsl

Manfred Staudinger, 2012-06-19 07:55

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT"
xmlns:prop="http://saxonica.com/ns/html-property"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink"
extension-element-prefixes="ixsl"
xmlns:plan="http://www.plan.com"
xmlns:js="http://saxonica.com/ns/globalJS"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="svg-t5-browser-v2.xsl"/>

<xsl:template match="/">
<xsl:next-match/>
<xsl:variable name="room_0" select="number(translate($g[@id='Räume']/svg:g[@id='Räume_2']/svg:path[1]/@id, '_', '')) - 1" as="xs:double?"/>
<xsl:for-each select="doc('')/*/xsl:template[starts-with(@match, 'svg:path[@id=')]">
<xsl:variable name="id" select="tokenize(@match, '''')[2]" as="xs:string"/>
<xsl:variable name="curr-elem" select="$g[@id='Räume']/svg:g[@id='Räume_2']/svg:path[@id=$id]" as="element()"/>
<xsl:variable name="room_no" select="number(translate($id, '_', '')) - $room_0" as="xs:double"/>
<xsl:variable name="BBox" select="ixsl:call($curr-elem, 'getBBox')" as="item()"/>
<xsl:variable name="text_xy" select="((: round() only because of Bug #1545 :)
round(ixsl:get($BBox, 'x') + ixsl:get($BBox, 'width') div 2),
round(ixsl:get($BBox, 'y') + ixsl:get($BBox, 'height') div 2)
)" as="xs:double+"/>
<xsl:result-document href="#Texte_4" method="ixsl:append-content">
<text id="no{$id}" x="{$text_xy[1]}" y="{$text_xy[2]}" xmlns="http://www.w3.org/2000/svg">
<xsl:sequence select="$room_no"/>
</text>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template name="init_test">
<xsl:message select="'test: init_test'"/>
<xsl:result-document href="#head" method="ixsl:append-content">
<style type="text/css" xmlns="http://www.w3.org/1999/xhtml">
/* causes scroll bars
svg {
border: 1px solid blue;
}
*/
</style>
</xsl:result-document>
<xsl:call-template name="init_last"/>
</xsl:template>

<xsl:template match="svg:path[@id='_2101']" mode="ixsl:onclick">
<xsl:variable name="evt" select="ixsl:event()"/>
<xsl:variable name="evt_pageXY" select="ixsl:get($evt, 'pageX'), ixsl:get($evt, 'pageY')" as="xs:double+"/>
<xsl:variable name="curr-elem" select="(.|..)[svg:title][1]" as="element()"/>
<xsl:variable name="t" select="ixsl:call(ixsl:call($curr-elem, 'getScreenCTM'), 'inverse')" as="item()"/>
<xsl:variable name="ScreenCTM" select="ixsl:get($t, 'a'), ixsl:get($t, 'b'), ixsl:get($t, 'c'), ixsl:get($t, 'd'), ixsl:get($t, 'e'), ixsl:get($t, 'f')" as="xs:double+"/>
<xsl:variable name="ScreenCTM" select="for $i in $ScreenCTM return round(1000 * $i) div 1000" as="xs:double+"/>
<xsl:variable name="x_wrong" select="($evt_pageXY[1] * $ScreenCTM[1]) + $ScreenCTM[5],
round(($evt_pageXY[1] * $ScreenCTM[1]) + $ScreenCTM[5])" as="xs:double+"/>
<xsl:message select="'Saxon-CE', getVersion(), 'Bug #1545 path/@id:', @id, 'path/title:', svg:title, 'room number:', id(concat('no', @id))"/>
<xsl:message select="'wrong?', $x_wrong[1], 'correct:', $x_wrong[2]"/>
<xsl:variable name="x_wrong" select="(546 * 1552.244) + 175917.984, round((546 * 1552.244) + 175917.984)" as="xs:double+"/>
<xsl:message select="'wrong:', $x_wrong[1], 'correct:', $x_wrong[2]"/>
</xsl:template>
<xsl:template match="svg:path[@xx='_2149']" mode="ixsl:onclick">
<xsl:message select="'svg-t5-browser-v2-test.xsl: match=svg:path'"/>
<xsl:variable name="evt" select="ixsl:event()"/>
<xsl:variable name="curr-elem" select="(.|..)[svg:title][1]" as="element()"/>

<xsl:variable name="t" select="ixsl:page()" as="document-node()"/>
<xsl:message select="'onclick path, test: document-node()', count($t), name($t)"/>
<!-- Mouse position "event." -->
<xsl:variable name="evt_clientXY" select="ixsl:get($evt, 'clientX'), ixsl:get($evt, 'clientY')" as="xs:double+"/>
<xsl:variable name="evt_pageXY" select="ixsl:get($evt, 'pageX'), ixsl:get($evt, 'pageY')" as="xs:double+"/>
<xsl:variable name="evt_screenXY" select="ixsl:get($evt, 'screenX'), ixsl:get($evt, 'screenY')" as="xs:double+"/>
<xsl:message select="'onclick path, test: $evt_clientXY', $evt_clientXY, '$evt_pageXY', $evt_pageXY, '$evt_screenXY', $evt_screenXY"/>
<!-- WindowView properties "window." -->
<xsl:variable name="innerWH" select="ixsl:get(ixsl:window(), 'innerWidth'), ixsl:get(ixsl:window(), 'innerHeight')" as="xs:double+"/>
<xsl:variable name="pageXYOffset" select="ixsl:get(ixsl:window(), 'pageXOffset'), ixsl:get(ixsl:window(), 'pageYOffset')" as="xs:double+"/>
<xsl:variable name="screenXY" select="ixsl:get(ixsl:window(), 'screenX'), ixsl:get(ixsl:window(), 'screenY')" as="xs:double+"/>
<xsl:message select="'onclick path, test: $innerWH', $innerWH, '$pageXYOffset', $pageXYOffset, '$screenXY', $screenXY"/>

<xsl:message select="'onclick path', $curr-elem/svg:title, $curr-elem/@id,
'A=', boolean(id('Texte_4')/*[@id = concat('_', $curr-elem/svg:title)]),
'B=', boolean(id('clip-path')/*[@xlink:href = concat('#', $curr-elem/@id)])"/>
<xsl:variable name="t" select="ixsl:call($curr-elem, 'getBBox')" as="item()"/>
<xsl:variable name="BBox" select="ixsl:get($t, 'x'), ixsl:get($t, 'y'), ixsl:get($t, 'width'), ixsl:get($t, 'height')" as="xs:double+"/>
<xsl:variable name="BBox" select="for $i in $BBox return round(1000 * $i) div 1000" as="xs:double+"/>
<xsl:message select="'onclick path: $BBox', $t, $BBox"/>

<xsl:variable name="t" select="ixsl:call(ixsl:call($curr-elem, 'getScreenCTM'), 'inverse')" as="item()"/>
<xsl:variable name="ScreenCTM" select="ixsl:get($t, 'a'), ixsl:get($t, 'b'), ixsl:get($t, 'c'), ixsl:get($t, 'd'), ixsl:get($t, 'e'), ixsl:get($t, 'f')" as="xs:double+"/>
<xsl:message select="'onclick path: $ScreenCTM inverse', $t, $ScreenCTM"/>
<xsl:variable name="t" select="ixsl:call(ixsl:call($curr-elem, 'getCTM'), 'inverse')" as="item()"/>
<xsl:variable name="CTM" select="ixsl:get($t, 'a'), ixsl:get($t, 'b'), ixsl:get($t, 'c'), ixsl:get($t, 'd'), ixsl:get($t, 'e'), ixsl:get($t, 'f')" as="xs:double+"/>
<xsl:message select="'onclick path: $CTM inverse', $t, $CTM"/>
<xsl:variable name="evt_pageXY" select="ixsl:get($evt, 'pageX'), ixsl:get($evt, 'pageY')" as="xs:double+"/>
<xsl:message select="'onclick path: $evt_pageXY', $evt_pageXY"/>
<xsl:variable name="t" select="js:reflectXY((486, 634))" as="xs:anyAtomicType*"/>
<xsl:message select="'onclick path: js:reflectXY', count($t), $t"/>

<xsl:variable name="p" select="ixsl:call($svg, 'createSVGPoint')" as="xs:anyAtomicType*"/>
<xsl:message select="'onclick path: createSVGPoint', $p"/>
<xsl:variable name="t" select="js:convertXY(ixsl:get($evt, 'pageX'), ixsl:get($evt, 'pageY'), $p, $ScreenCTM)" as="xs:anyAtomicType*"/>
<xsl:message select="'onclick path: js:convertXY', count($t), $t"/>
<!--xsl:message select="'onclick path: js:convertXY', ixsl:get($t, 'x'), ixsl:get($t, 'y')"/-->

<xsl:next-match/>
</xsl:template>

<xsl:template match="svg:circle" mode="scale">
<xsl:param name="scale_next" as="xs:double" tunnel="yes"/>
<ixsl:set-attribute name="r" select="round(xs:double(@r) * xs:double($svg/@data-scale_curr) div $scale_next)"/>
</xsl:template>
<xsl:template match="svg:circle" mode="ixsl:onclick">
<xsl:message select="name(.), @id, @cx, @cy"/>
<xsl:for-each select="preceding-sibling::*[1]">
<xsl:message select="name(.), @id"/>
<xsl:choose>
<xsl:when test="not(@stroke)">
<ixsl:set-attribute name="stroke" select="'pink'"/>
<ixsl:set-attribute name="stroke-width" select="960"/>
</xsl:when>
<xsl:otherwise>
<ixsl:remove-attribute name="stroke"/>
<ixsl:remove-attribute name="stroke-width"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>

</xsl:transform>
(8-8/12)