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]
Other format: [Raw text]

Re: Testing for presence of node, etc.


Hello Joel,

you can easily describe it as "grouping problem" ;-) And there is a easy 
method to solve such problems: Muenchian Method 
(http://www.jenitennison.com/xslt/grouping/muenchian.xml).

<xsl:key name="links" match="link" use="@type"/>

<xsl:template match="root">
   <xsl:apply-templates select="link[count(. | key('links', @type)[1]) = 
1]" mode="unique"/>
</xsl:template>

<!-- first occurence of a link with a specific type" -->
<xsl:template match="link" mode="unique">
   type: <xsl:value-of select="@type"/>
   <xsl:apply-templates select="key('links', @type)"/>
</xsl:template>

<xsl:template match="link">
   <xsl:value-of select="@url"/>
</xsl:template>

Regards,

Joerg


Joel Konkle-Parker schrieb:
>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> In my xml document, I have several nodes of type <link type=""
> url=""></link>, where type may one of several different things, and
> more than one node may have the same @type. I want to be able to test
> whether any nodes exist that have a specific @type and if so, output
> a certain heading. I then need to output a string of text for each
> occurrance of a specific @type. Obviously I don't want the heading to
> output for each occurance.
> 
> If I haven't confused everyone already, what suggestions do you have
> about the best way to do this?
> 
> - -joeljkp


 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]