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

RE: Incrementing position in the tree midstream (Part

Subject: RE: Incrementing position in the tree midstream (Part 3)
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Fri, 16 Apr 2004 17:41:42 +0200
insert count
> -----Original Message-----
> From: Durston, Andrew (AGRE)
>
>
> How would that be written?
>
> 	count(following::objecttext[.= 'string1' & 'string2']) ??
>

Hi,

Hmm. Would be more like:

count( following::objecttext[(.='string1') or (.='string2')] )

if you want to count the number of following objecttext nodes that have
'string1' or 'string2' as content.

If the '&' signifies a concatenation, simply use
count(following::objecttext[.=concat('string1','string2')])

However:
> And once I have the count, I use that in a for-each from '.' to
> following less than count, to output the cells?
>
> 	<xsl:for-each select=". |
> following::objecttext[position()&lt; <<insert count command here
> or a variable??>>]">

The above calculated number will bear no relation to the set of nodes
selected in the for-each, unless you write it like:

<xsl:for-each select=". |
                following::objecttext[(.='string1') or (.='string2')][
                  position() &lt; $varcount]">

Let's say there are 5 nodes counted by the count() expression (5 nodes
following the current node, and whose content is 'string1' or 'string2').
>From *all* following objecttext nodes, you will select only the first 4 and
the current node. Does this sound like what you intend to do?

If not, maybe we'd better start again 'from the top'. Can you post a reduced
sample of the XML, and clarify how you would like to see it transformed?
(mainly the mentioned 'field' tabletype remains a mystery to the list: where
does it appear in the XML? As attribute? Or as child node? Of object or
objecttext?)

I have the feeling there is a more efficient solution than having to
traverse the following-axis for all objecttext nodes, but I really need to
know the exact structure of the XML in order to come up with something
that's definitely useful...

As a further tip:

<xsl:for-each select="nodes">
  <xsl:copy-of select="." />
</xsl:for-each>

is actually the same as:

<xsl:copy-of select="nodes" />

The only difference is that on the above, you could add an xsl:sort, but
that could also be solved like:

<xsl:apply-templates select="nodes">
  <xsl:sort select="@attr" />
</xsl:apply-templates>
...
<xsl:template match="nodes">
  <xsl:copy-of select="." />
</xsl:template>



Cheers,

Andreas

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.