[Home] [By Thread] [By Date] [Recent Entries]


You need a recursive template for this. The logic is:

occs(x, s):
  if contains(x, s) 
  then 1 + occs(substring-after(x, s), s) 
  else 0

The XSLT 1.0 syntax, unfortunately, is rather wordier than this.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Esteban Pizzini [mailto:eplx2002@y...] 
> Sent: 28 September 2004 16:17
> To: xml-dev@l...
> Subject:  xsl question
> 
> Hi,
> 
> I'm trying to write a xsl script that counts all times an 
> attribute contains some text
> I use contain() and count(), but is it possible to count 
> elements that contains some value??
> I try somethins like this:
> <xsl:if 
> test="count(contains(document($ARCH_LNK_JJ)/Doc/Laes/JudDoc/Re
> f/@idproducto,$producto)) &gt; 0">
> 
> but I get an error... because contains returns a boolean value..
> 
> thank you!
> Esteban
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 


  • References:
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member