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

Re: How to do an 'existence' test in XSL?

Subject: Re: How to do an 'existence' test in XSL?
From: Dimtre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 23 Dec 2004 08:01:01 +1100
tooltip tutorial
In case you know all possible types in advance, a simple (but not
too-efficient) way of picking up all "existing" gui types is the
following:

<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 >
 
 <xsl:output method="text"/>

 <xsl:param name="pAllStyles" as="xs:string+" 
 select="'alertBox', 'combo', 'help', 'tooltip'"/>
  
 <xsl:variable name="vDoc" select="/"/>

  <xsl:template match="/">
    <xsl:value-of separator="&#xA;" select=
    "$pAllStyles[. = $vDoc/styles/gui/@type ]" />
  </xsl:template>
</xsl:stylesheet>

When this transformation is applied on your source xml (provided with
a single element parent):

<styles>
  <gui type="alertBox"/>
  <gui type="tooltip"/>
  <gui type="help"/>
  <gui type="tooltip"/>
  <gui type="alertBox"/>
  <gui type="tooltip"/>
  <gui type="help"/>
</styles>

the wanted result is produced:

alertBox
help
tooltip


Cheers,
Dimitre.



On Wed, 22 Dec 2004 14:33:06 +0000, ben@xxxxxxxxxxxxx <ben@xxxxxxxxxxxxx> wrote:
> I'm having great difficulty understanding how/if XSL provides the tool to satisfy the following simple requirement.
> 
> Lets say I have some simple xml like :
> 
> <gui type="alertBox">...</gui>
> <gui type="tooltip">...</gui>
> <gui type="help">...</gui>
> <gui type="tooltip">...</gui>
> <gui type="alertBox">...</gui>
> <gui type="tooltip">...</gui>
> <gui type="help">...</gui>
> 
> To simplify things... imagine transforming this document in such a way that we have something like :
> 
> <alertBox/>
> <tooltip/>
> <help/>
> 
> i.e. I would like the XSL to result in one output per gui type.
> 
> So there is the problem... how on earth do I process the xml such that it results in an output per +type+ rather than for each instance (is that explained well enough?)... i.e. it's easy to match on the attributes but each match produces output so I would get :
> 
> <alertBox/><alertBox/>
> <tooltip/><tooltip/><tooltip/>
> <help/><help/>
> 
> Can anyone offer advice on the way in which I ought to approach this problem?
> 
> Kindest regards,
> 
> Ben

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.