This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
AW: (re-)calculating attribute values
- From: "Christian Timmerer (ITEC)" <christian dot timmerer at itec dot uni-klu dot ac dot at>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 11 Mar 2002 22:37:21 +0100
- Subject: AW: [xsl] (re-)calculating attribute values
- Reply-to: xsl-list at lists dot mulberrytech dot com
fine - thanks for your fast answer :-) i'm not in my office anymore and no
access to my files but i will try out your proposal
bye, good night ;-)
christian
-----Ursprüngliche Nachricht-----
Von: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]Im Auftrag von Michael Kay
Gesendet: Montag, 11. März 2002 22:23
An: xsl-list@lists.mulberrytech.com
Betreff: RE: [xsl] (re-)calculating attribute values
Well, you haven't shown us your code, so you can't expect us to debug it for
you.
But I would think the following should work:
<xsl:variable name="base" select="*[not(self::C)][1]/@start"
<xsl:for-each select="*[not(self::C)]">
<xsl:copy>
<xsl:variable name="start" select="$base
+ sum(preceding-sibling::*[not(self::C)]/@end)
- sum(preceding-sibling::*[not(self::C)]/@start)
+ count(preceding-sibling::*[not(self::C)])"/>
<xsl:attribute name="start">
<xsl:value-of select="$start"/>
</xsl:attribute>
<xsl:attribute name="end">
<xsl:value-of select="$start + (@end - @start)"/>
</xsl:attribute>
</xsl:copy>
</xsl:for-each>
Not tested.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Christian
> Timmerer
> Sent: 11 March 2002 20:42
> To: XSL-List@lists.mulberrytech.com
> Subject: [xsl] (re-)calculating attribute values
>
>
> hello *.*,
> following xml-file:
>
> <A start="20" end="28">Text1</A>
> <B start="29" end="35">Text2</B>
> <C start="36" end="39">Text3</C>
> <C start="40" end="44">Text4</C>
> <A start="45" end="51">Text5</A>
> <C start="52" end="58">Text6</C>
> <B start="59" end="69">Text7</B>
> ...
>
> i want to write a xslt file which removes all <C> elements
> (no problem) and
> recalculates start and end values by filling up the gaps. and
> here i have
> the problem: in the first case it is possible to fill up the
> gab between the
> first <B> and second <A>:
>
> 1: <A start="20" end="28">Text1</A>
> 2: <B start="29" end="35">Text2</B>
> 3: <!-- removed <C> element(s) -->
> 4: <A start="36" end="42">Text5</A>
> 5: <!-- removed <C> element(s) -->
> 6: <B start="52" end="62">Text7</B> (problem!!!)
>
> The problem arises at the second gap (line 6). the gap is
> calculated by
> using end value of second <A> and start value of last <B>
> (59-51=8) and not
> by using already recalculated values in previous step (59-42=17).
>
> what's going wrong here? has anyone a hint or maybe a solution for me?
>
> any help would be appreciated!
>
> regards
> christian
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list