xsl-list
[Top] [All Lists]

Re: [xsl] How to restrict xsl:key

2019-09-12 16:59:46
It looks as if this can be done simply by changing the match attribute to

match="Period[@domain='c']//Stamp"

Or have I misunderstood?

Michael Kay
Saxonica

On 12 Sep 2019, at 22:55, Mark Wilson mark(_at_)knihtisk(_dot_)org 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

I have established a key:
 <xsl:key name="placement-index" match="Stamp" 
use="concat(CatNumbers/@pofis-prefix, CatNumbers/@pofis-number, 
CatNumbers/@pofis-suffix)"/>

It uses an XML file that contains the element Stamp. It worked until today. 
What changed is that the CatNumbers fall into two Periods (seedata  below). 
Until today, the Catnumbers referenced always fell in Period domain='c' in my 
data. They now also fall into Period domain='cr'.  I need to restrict the 
output of the template to only keys built from the @domain='c' part of the 
data. Have not a clue how to do this.

The code using building and using the key is:

<xsl:key name="placement-index" match="Stamp" 
use="concat(CatNumbers/@pofis-prefix, CatNumbers/@pofis-number, 
CatNumbers/@pofis-suffix)"/>

    <xsl:template match="Flaws">
          <Flaws>
            <xsl:attribute name="placement-index" 
select="key('placement-index', concat(@pofis-prefix, @pofis-number, 
@pofis-suffix), doc('../work/data-with-index.xml'))/@placement-index"
            />
            <xsl:attribute name="flaw-width" select="key('placement-index', 
concat(@pofis-prefix, @pofis-number, @pofis-suffix), 
doc('../work/data-with-index.xml'))/@flaw-width"
            />
            <xsl:copy-of select="@*"/>
            <xsl:copy-of select="node()"/>
          </Flaws>
    </xsl:template>


The data is:
<Period domain="c">
      <Year year="1918">
         <Month month="12">
            <Day day="18">
               <Set>
                  <Motif concept="Definitive Issues"/>
                  <Stamp>
                     <CatNumbers scott-number="2" pofis-number="3"/>
                     <Value kc-value="0" h-value="5"/>
                     <Inscriptions czech="$" eng="$"/>
                     <Formats other="3"/>
                     <Formats gutter="3"/>
                  </Stamp>
                  <Stamp>
                     <CatNumbers scott-number="3" pofis-number="5"/>
                     <Value kc-value="0" h-value="10"/>
                     <Inscriptions czech="$" eng="$"/>
                     <Formats other="5"/>
                     <Formats gutter="5"/>
                  </Stamp>
               </Set>
...
<Period/>
<Period domain="cr">
      <Year year="1918">
         <Month month="12">
            <Day day="18">
               <Set>
                  <Motif concept="Definitive Issues"/>
                  <Stamp>
                     <CatNumbers scott-number="2" pofis-number="3"/>
                     <Value kc-value="0" h-value="5"/>
                     <Inscriptions czech="$" eng="$"/>
                     <Formats other="3"/>
                     <Formats gutter="3"/>
                  </Stamp>
                  <Stamp>
                     <CatNumbers scott-number="3" pofis-number="5"/>
                     <Value kc-value="0" h-value="10"/>
                     <Inscriptions czech="$" eng="$"/>
                     <Formats other="5"/>
                     <Formats gutter="5"/>
                  </Stamp>
               </Set>
...
<Period/>


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>