[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: Thu, 29 Sep 2011 13:49:28 -0700
Re:  Identifying unique attribute values in nested    s
Ken,
I still have not correctly said what I need:

(1) Please think of the <Value> attributes as though 'kc-value' were equivalent to 'dollars' and 'h-value' to 'cents' (the l-value mentioned earlier is like those US stamps issued just before a rate change that are expressed as a letter value). <Value> attributes can only appear [ignoring the specific instance values given here] in the following combination:

<Value kc-value="1"> think of this as $1.
<Value kc-value="1" h-value="50"> Think of this as $1.50
<Value kc-value="0" h-value="50"> Think of this as $0.50
<Value kc-value="0" l-value="A" Think of this as one of those strange rate-change postage stamps that have a letter value of 'A'.


Note that kc-value is required, the other two, h-value and l-value, are both optional and are mutually exclusive. When l-value is present, kc-value must be set to the value '0'.

(2) These <Value> elements would produce this XHTML for the particular target XHTML page:

<a href="../aval/1.htm">1kc</a>
<a href="../aval/1-50.htm">1.50kc</a>
<a href="../aval/0-50.htm">40h</a> <!-- think of 40cents -->
<a href="../aval/a.htm">A</a>

I have two functions that can transform these attributes into their final text formats for the 'href' part of the output:

xsl:function name="cps:letter-file-name" as="xs:string">
   <xsl:param name="l" as="xs:string"/>
   <xsl:value-of select="concat(lower-case($l), '.htm')"/>
 </xsl:function>

 <xsl:function name="cps:value-file-name" as="xs:string">
   <xsl:param name="kc" as="xs:string"/>
   <xsl:param name="h" as="xs:string"/>
   <xsl:choose>
     <xsl:when test="$h">
       <xsl:value-of select="concat($kc, '-', $h, '.htm')"/>
     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="concat($kc, '.htm')"/>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:function>

And another that creates the <a></a> text:

<xsl:function name="cps:display-denomination" as="xs:string">
  <xsl:param name="kc" as="xs:string"/>
  <xsl:param name="h" as="xs:string"/>
  <xsl:choose>
    <xsl:when test="$kc eq '0'">
      <xsl:value-of select="concat($h,'h')"/>
    </xsl:when>
    <xsl:when test="not($h eq '0')">
      <xsl:value-of select="concat($kc, '.', $h, 'KD
')"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="concat($kc, 'KD
')"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>

This is why I was ineptly trying to change my strings back into nodes.

(3) I need to modify your 'reports' function to accommodate all four possibilities, but do not know enough about XPath to do it. May I bother you one more time to show me how?

As an aside, the stylesheet transforms the XML into an XHTML page for every <Stamp> element, and to an additional page for each of the different <Formats> elements (there are five optional possibilities). It is *extremely* easy for me to identify which pages to generate when I am in the context of a <Stamp> element that has certain characteristics (and these characteristics change). I suspect that someone with your sophistication could do it from the context of the <Set> element, but it escapes me how to do it that way. This is why I keep rewriting the suggestions I have received to operate from within the context of a <Stamp> element rather than from within the context of the enclosing <Set> element. Dumb, I know, but I already know how to do it.

Thanks again,
Mark

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.