Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Muenchian grouping problem

From: "r@----" <------------@-----.--->
To: NULL
Date: 10/12/2007 11:56:00 AM

Thanks to Mukul Ghandi for this solution:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="by-location" match="location" use="./@name" />
<xsl:template match="/partners">
	<locations>
	<xsl:for-each select="partner/location[../@area = 'Australia']">
		<xsl:if test="generate-id(.) = generate-id(key('by-location', ./
@name)[1])">
			<xsl:copy-of select="." />
		</xsl:if>
	</xsl:for-each>
	</locations>
</xsl:template>
</xsl:stylesheet>

Rob

Problem solved




On 12 okt, 11:44, "r@face" <rshwebwer...@gmail.com> wrote:
> Hi,
>
> Can someone help me out with the following:>From this XML I want unique locationnames in an area.
>
> So for the USA : Boston, New York, Chigago and Las Vegas.
> My stylesheet result in: Boston, Boston, New York, Chicaco, the
> locations in the first partner in USA.
>
> How can I get the desired result?
> Thanks in advance.
>
> Rob
>
> XML:
> <partners>
>         <partner id="A1" name="name1" area="Australia">
>                 <location name="Adelaide" />
>                 <location name="Adelaide" />
>                 <location name="Brisbane" />
>                 <location name="Melbourne"/>
>         </partner>
>         <partner id="A2" name="name2" area="Australia">
>                 <location name="Adelaide" />
>                 <location name="Brisbane" />
>                 <location name="Darwin" />
>         </partner>
>         <partner id="A3" name="name3" area="USA">
>                 <location name="Boston" />
>                 <location name="Boston" />
>                 <location name="New York" />
>                 <location name="Chigago" />
>         </partner>
>         <partner id="A4" name="name4" area="USA">
>                 <location name="Boston" />
>                 <location name="New York" />
>                 <location name="Las Vegas" />
>         </partner>
> </partners>
>
> Stylesheet:
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output version="1.0" encoding="UTF-8" indent="yes"/>
> <xsl:key name="by-location" match="//partner" use="location/@name" />
> <xsl:template match="/">
>         <locations>
>         <xsl:for-each select="//partner[@area = 'USA' and generate-id(.) =
> generate-id(key('by-location' , location/@name))]">
>                 <xsl:copy-of select="location" />
>         </xsl:for-each>
>         </locations>
> </xsl:template>
> </xsl:stylesheet>
>
> Result output stylesheet:
> <locations>
>         <location name="Boston"/>
>         <location name="Boston"/>
>         <location name="New York"/>
>         <location name="Chigago"/>
> </locations>
>
> Desired output:
> <locations>
>         <location name="Boston" />
>         <location name="New York" />
>         <location name="Chigago" />
>         <location name="Las Vegas" />
> </locations>




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent