Here is what is in my source xml:
<g transform="translate( 40.00, 59.55)"><rect id="line 1277 rect"
title="0002 0001 scan 001 ` ~" width="12.5" height="12.5"
class="keyoutline" /> <text x=" 6" y="11" class="tch">巷</text><text
x=" 6" y="11" class="ru-up">Ȅ</text><text x=" 6" y="11"
class="ru-lo">ȅ</text>
</g>
How do I extract the 40.00 and 59.55 from the translate attribute for each
child that has an attribute [class='tch']?
Here is my attempt -- it is almost working. I get the text(), the @x and the
@y but I cannot get the sibling or parent attributes! What am I doing wrong?
I'm using saxon.
I guess this is a two part question. After I get the parent's transform
attribute, I want to extract the two numerical values from the translation.
Thanks!
Siegfried
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg"
version="2.0">
<xsl

utput indent="yes"/>
<xsl:template match="/">
<keys>
<xsl:apply-templates select="//svg:text[@class='tch']"/>
</keys>
</xsl:template>
<xsl:template match="//*[@class='tch']">
<xsl:element name="key">
<xsl:attribute name="x"><xsl:value-of select="@x"/></xsl:attribute>
<!-- works!-->
<xsl:attribute name="title"><xsl:value-of
select="../../svg:g[@title]"/></xsl:attribute> <!-- does not
work! -->
<xsl:attribute name="width"><xsl:value-of
select="../svg:text[@svg:width]"/></xsl:attribute> <!-- does not
work! -->
<xsl:attribute name="pos"><xsl:value-of
select="position()"/></xsl:attribute> <!-- this seems to give the
grandchild position and not the child position, I want the child
position -->
<xsl:value-of select="text()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>