[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Identifying unique attribute values in nested s

Subject: Re: Identifying unique attribute values in nested sibling elements
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Tue, 4 Oct 2011 07:23:37 -0700
Re:  Identifying unique attribute values in nested    s
Hi Ken,
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++. Any improvements would be greatly appreciated if and when you have the time and desire. The h-value and l-value were not presented to you as part of the original use case.


They do exactly what I wanted.
Thanks,
Mark

the XML with the  output:
<Value kc-value="1">                        Text: 1kc     File: 1-0.htm
<Value kc-value="1" h-value="50"> Text 1.50kc File: 1-50.htm
<Value kc-value="0" h-value="50"> Text: 50h  File: 0-50.htm
<Value kc-value="0" l-value="A"     Text: A  File:a.htm

Only the second function, cps:report, has been modified:

<!--compose a string of attribute names and their values;
   avoid the possibility of co-incidental string values;-->
 <xsl:function name="cps:attrs">
   <xsl:param name="this"/>
   <xsl:value-of>
     <xsl:for-each select="$this/@*">
       <xsl:sort select="name(.)"/>
       <xsl:value-of select="name(.),'&#xfdd0;',.,'&#xfdd0;'"/>
     </xsl:for-each>
   </xsl:value-of>
 </xsl:function>

 <!--common reporting-->
 <xsl:function name="cps:report">
   <xsl:param name="Stamp"/>
   <xsl:for-each select="$Stamp">
     <!-- l-value -->
     <xsl:choose>
       <xsl:when test="Value/@l-value">
         <xsl:for-each select="Value/@l-value">
           <a class="button" href="../aval/{lower-case(.)}.htm">
             <xsl:value-of select="."/>
           </a>
         </xsl:for-each>
       </xsl:when>
       <!-- 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>
         <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>KD
</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>
       </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">
<xsl:value-of select="."/>KD
<xsl:text/>
</a>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:function>


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.