As always, clear and to the point.
Thanks,
Mark
-----Original Message-----
From: G. Ken Holman
Sent: Tuesday, October 04, 2011 5:50 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Identifying unique attribute values in nested sibling
elements
At 2011-10-04 07:23 -0700, Mark wrote:
Despite my confused presentation of the problem last week, you supplied me
with two functions that obtain the unique attributes from <Value> element
within a set of <Stamp> elements. Works beautifully, but I did make some
modifications to the second function. Please let me know if my
modifications are consistent with the idiom you have been talking about or
if I have slipped back into C++.
You have made one slip to note.
<!-- kc-value + h-value -->
<xsl:when test="Value/@h-value">
<xsl:variable name="h">
<xsl:for-each select="Value/@h-value">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
The waste is that you are creating a two-node
variable consisting of a document node and a text
node, then later only getting the variable's text value.
The above could simply be: <xsl:variable name="h" select="Value/@h-value"/>
Then you are simply pointing to the existing node
in the tree and getting that node's value at each
reference. And since the node is an attribute
node, the node's value is self-contained and no
calculations or tree traversals are needed (as is
true for obtaining an element's value or a
document node's value which was true for your attempt).
<xsl:for-each select="Value/@kc-value">
<xsl:choose>
<xsl:when test="not(. eq '0')">
<a class="button" href="../aval/{concat(., '-', $h)}.htm">
<xsl:value-of select="concat(., '.', $h)"/>
<xsl:text>KÄ?</xsl:text>
</a>
</xsl:when>
<xsl:otherwise>
<a class="button" href="../aval/{concat(., '-', $h)}.htm">
<xsl:value-of select="$h"/>
<xsl:text>h</xsl:text>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Oh, I know earlier you indicated your preference
for being more explicit about what is going on
with concatenation, but I would make another change:
</xsl:when>
<xsl:otherwise>
<!-- Only when there is no h-value -->
<xsl:for-each select="Value/@kc-value">
<a class="button" href="../aval/{concat(., '-0')}.htm">
I would have used: href="../aval/{.}-0.htm"
I hope this helps.
. . . . . . . . . . . Ken
--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--