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

Re: xsl unique position

Subject: Re: xsl unique position
From: Steven.C.Kienle@xxxxxxxxxx
Date: Fri, 9 Mar 2001 08:37:29 -0500
position xsl
  Mat,
  
  You are getting 1 for the position() each time because Jack and Jill 
  are both the first Name in the list of Names for each Member.  That 
  is, position is not file dependent, but node-list dependent.  Since 
  you apply-templates for Name under each Member, you end up with a 
  different node-list each time.
  
  <Group>           <!-- position() = 1 -->
  <Member>          <!-- position() = 1 within /Group/Member -->
  <Name>Jack</Name> <!-- position() = 1 within member[1] -->
  </Member>
  <Member>          <!-- position() = 2 within /Group/Member -->
  <Name>Jill</Name> <!-- position() = 1 within member[2] -->
  </Member>
  </Group>
  
  It seems like what you really want is to use the "/Group/Member 
  position" for identifying the Name.  In that case, you can replace the 
  <xsl:apply-templates select="*"/> in your Member template with the 
  following
  
     Name:
     <xsl:element name="input">
     <xsl:attribute name="type">text</xsl:attribute>
     <xsl:attribute name="name">Name<xsl:value-of
          select="position()"/></xsl:attribute>
     <xsl:attribute name="value">
     <xsl:value-of select="Name"/>
     </xsl:attribute>
     </xsl:element>
     <br/>
  
  I am assuming you will have only one Name element under each Member 
  element here.  In that case, you don't really need to call 
  apply-templates.  If you may have more than one Name element under 
  each Member, you may need to pass the Member position() as a parameter 
  to the Name template to support uniqueness.
  
     Steve


______________________________ Reply Separator _________________________________
Subject:  xsl unique position
Author:  mat t <mat@xxxxxxxxxx> at Internet-America
Date:    09-03-2001 5:01 AM


Please can you help:
  
I am losing the variable due to duplication
  
<Group>
 <Member>
  <Name>Jack</Name>
 </Member>
 <Member>
  <Name>Jill</Name>
 </Member>
</Group>
-----------xsl-------
<xsl:template match="/">
 <html>
  <body>
   <xsl:apply-templates select="Group/Member"/>
  </body>
 </html>
</xsl:template>
  
<xsl:template match="Member">
 <xsl:apply-templates select="*"/>
 <xsl:element name="input">
  <xsl:attribute name="type">hidden</xsl:attribute> 
  <xsl:attribute name="name">Member<xsl:value-of
select="position()"/><xsl:value-of select="position()"/></xsl:attribute>
  
  <xsl:attribute name="value"></xsl:attribute> 
  </xsl:element><br/>
</xsl:template>
  
<xsl:template match="Name">
Name:
 <xsl:element name="input">
  <xsl:attribute name="type">text</xsl:attribute> 
  <xsl:attribute name="name">Name<xsl:value-of
select="position()"/></xsl:attribute>
  <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
  
  </xsl:element><br/>
</xsl:template>
  
The variables sent are -
  
Member1 =>
Name1 => Jack
Member2
  
Unfortunately I don't get the second name. I assume that Name1 means 
it's position 1 in parent node "Member"
Which means that the second name will also have name1 as it's name and 
the form has ignored it thinking it's a duplicate.
  
Please can you tell me if there is any way to solve this problem.
  
  
  
_____________________________________________________________
Pick up your email anywhere in the world ---> http://www.remail.net
  
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
  

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


Current Thread
  • xsl unique position
    • mat t - Fri, 9 Mar 2001 08:01:48 -0500 (EST)
      • <Possible follow-ups>
      • Steven . C . Kienle - Fri, 9 Mar 2001 08:39:49 -0500 (EST) <=

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.