This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Position or Count



Jenni,

The call to the 'state-lookup' key DOES have to occur in
the document holding the ROWSET elements. So your suggestion for using
substring() function seems most viable. However, I am not sure how to go
about doing it.
Once I have written out the comma it is a text format. Not sure how I would
then use substring?




                                                                                                         
                    Jeni Tennison                                                                        
                    <jeni@jenitennison.com>           To:     Kevin_Gutch@mapinfo.com                    
                    Sent by:                          cc:     xsl-list@lists.mulberrytech.com            
                    owner-xsl-list@lists.mulber       Subject:     Re: [xsl] Position or Count           
                    rytech.com                                                                           
                                                                                                         
                                                                                                         
                    10/31/2001 01:38 PM                                                                  
                    Please respond to xsl-list                                                           
                                                                                                         
                                                                                                         




Hi Kevin,

> What I am trying to do is print the position number with a comma
> until it is the last number which will then only print the number.
> This has been easy enough in the past but I have a new wrinkle in my
> code. With <xsl:if test="$layerExistence2 ='TRUE'"> only some layers
> pass the test. So the result is mass confusion (on my part) for the
> $Position variable determining if it is the last element or not. I
> only want it to use elements that pass the test to determine
> position.

I'm not sure if I'm following the code correctly, but it looks as if
you're trying to print the position of the layer_params element
amongst other layer_params elements in the document, but only for
certain of those layer_params elements.

The easiest way to do something to all but the last of a list is to
iterate over the list in order and pick out the last one. To do this,
you need to be interested in all the items in the list. So what about
only selecting those layer_params elements that fulfil the condition,
and using xsl:number to number them? Something like:

  <xsl:for-each
    select="//layer_params
              [key('state-lookup',
                   substring-after(../data_params/data_description_params
                                     /properties/property/@value,
                                   '&#xA;'))/EXIST = 'TRUE']">
    <xsl:number level="any" />
    <xsl:if test="position() != last()">,</xsl:if>
  </xsl:for-each>

This won't work if the call to the 'state-lookup' key has to occur in
the document holding the ROWSET elements rather than the document
holding the layer_params element. If that's the case, I suggest always
generating the comma, and then stripping the comma from the resulting
string using the substring() function.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]