This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: repetition using for-each (and generating "attributes")
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] repetition using for-each (and generating "attributes")
- From: James Melton <james dot melton at cylogix dot com>
- Date: Mon, 23 Jul 2001 11:48:23 -0400
- References: <3B5C2C1F.AA551B34@syncline.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Try:
<xsl:template match="//Polygon">
<RING>
<xsl:apply-templates select="./Point"/>
</RING>
</xsl:template>
<xsl:template match="Point">
<POINT>
<xsl:attribute name="x">
<xsl:value-of select="./@x"/>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="./@y"/>
</xsl:attribute>
</POINT>
</xsl:template>
-Jim
Kris Kolodziej wrote:
>
> Dear List,
>
> I am having trouble with the following transformation. I want the result
> to
> include all <Point> tags but I am only getting one <Point> tag.
> (I also tried using <xsl:for-each select="child::*"> <xsl:value-of
> select="name()"/>)
>
> Thanks for your help in advance. <Kris/>
>
> <!-- my XML -->
> <Polygon>
> <Point x="-122.5281" y="37.635" />
> <Point x="-122.4521" y="37.700" />
> <Point x="-122.4000" y="37.750" />
> <Point x="-122.3100" y="37.820" />
> </Polygon>
>
> <!-- my XSL -->
> <POINT>
> <xsl:for-each select="//Polygon">
> <xsl:attribute name="x">
> <xsl:value-of select="Point/@x"/>
> </xsl:attribute>
> <xsl:attribute name="y">
> <xsl:value-of select="Point/@y"/>
> </xsl:attribute>
> </xsl:for-each>
> </POINT>
>
> <!-- my result -->
> <RING>
> <POINT x="-122.5281" y="37.635" />
> </RING>
>
> <!-- what I want -->
> <RING>
> <POINT x="-122.5281" y="37.635" />
> <POINT x="-122.4521" y="37.700" />
> <POINT x="-122.4000" y="37.750" />
> <POINT x="-122.3100" y="37.820" />
> </RING>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
____________________________________________________________
James Melton CyLogix
609.750.5190 609.750.5100
james.melton@cylogix.com www.cylogix.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list