Re: [xsl] Identifying unique attribute values in nested sibling elements

Subject: Re: [xsl] Identifying unique attribute values in nested sibling elements
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Thu, 29 Sep 2011 11:37:01 -0700
Hi Ken and Martin,
Apparently in my attempt to simplify this problem when I asked for help earlier, I did not do what Einstein recommended: "Make everything just simple enough, but not too simple." However, I was able to adapt Martin's code to acquire the information I needed, but now could use a bit more help parsing it. This time, I'll give you all the facts.


In my modification, I write to the variable "$value" that contains all of the values related to the sequence of se-tenant <Values> currently of interest. My problem now is that I do not know how to use tokenize() or write regex expressions, if that is the correct method, so that I can output the needed XHTML.

My modification of Martin's code:

<xsl:variable name="values">
<xsl:for-each-group select="../Stamp" group-by="Formats/@se-tenant">
<xsl:for-each-group select="current-group()" group-by="string-join(Value/@*, '.')">
<xsl:value-of select="current-grouping-key()"/>
<xsl:value-of select="Value/@*/concat('=', local-name(), ';')"/>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:variable>


The variable will contain strings similar to this one that I actually extracted from the working code:
"3.60=kc-value; =h-value;5=kc-value;6=kc-value;8=kc-value;"


This string is exactly what I wanted earlier and was unable to describe acurately.

My problem: I now need to tokenize these strings (or break them into usable substrings) so that I can produce the output XHTML . I only need to pay attention to the digits on the left of '=' and the unit-name (kc-value, h-value) on its right. The substring (token) separator is ';'

"3.60=kc-value;" is transformed to: <a "href="../aval/3-60.htm">3.60kc</a>
" =h-value;" has no digits in front of the '=' and thus must be ignored (the needed information was actually absorbed by the previous token)
"5=kc-value;" is transformed to: <a href="../aval/5.htm">5kc</a>
"6=kc-value;" is transformed to: <a href="../aval/6.htm">6kc</a>
"8=kc-value;" is transformed to: <a href="../aval/8.htm">8kc</a>


Can you show me how to do this?
Thanks,
Mark


-----Original Message----- From: Martin Honnen
Sent: Thursday, September 29, 2011 6:00 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Identifying unique attribute values in nested sibling elements


Mark wrote:

Also, in your statement: <xsl:for-each-group select="current-group()"
select="string-join(Value/@*, '|'">, I assumed the second "select" was a
typo for "group-by". Is that assumption correct?

Yes, sorry about that mistake.


The string-join assembles the values of all attributes into one string
to have some key value for grouping the items.

--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/

Current Thread