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

Re: repetition using for-each (and generating "attribu

Subject: Re: repetition using for-each (and generating "attributes")
From: Lawrence Mielniczuk <lwm@xxxxxxxxxxxxxxx>
Date: Mon, 23 Jul 2001 16:39:51 +0100 (GMT Daylight Time)
xml polygon
try something like:

<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="Polygon">
	<RING>
	<xsl:for-each select="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:for-each>
	</RING>
</xsl:template>

</xsl:transform>

this produces:

<?xml version="1.0" encoding="utf-8"?>
<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>

using saxon

> 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
> 

-------------------------------------
Lawrence Mielniczuk
Room 314
Bodleian Library
Oxford OX1 3BG
Tel: (01865) 277 114
Mobile: 0794 101 5689
-------------------------------------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.