[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
RE: Reg Counters
Subject: RE: Reg Counters
From: "Lawrence Pravin" <pravinl@xxxxxxxxxxx>
Date: Mon, 19 Mar 2001 20:34:12
|
Hi Jason,
Thank you very much. It works.
Regards
Lawrence.
From: "Diamond, Jason" <Jason.Diamond@xxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: Reg Counters
Date: Mon, 19 Mar 2001 13:51:14 -0600
Hi, Lawrence.
You were probably using position() with <Name> as the context node. <Name>
is always at position 1 within its <Contact> parent (unless we're counting
whitespace).
The following transform uses <Contact> as the context node when invoking
the
position() function:
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<NewMessage>
<ListOfContact>
<xsl:apply-templates select="/Message/ListOfContact/Contact"/>
</ListOfContact>
</NewMessage>
</xsl:template>
<xsl:template match="Contact">
<Contact>
<Name index="{position()}">
<xsl:value-of select="Name"/>
</Name>
<Phone>
<xsl:value-of select="Phone"/>
</Phone>
</Contact>
</xsl:template>
</xsl:transform>
Hope this helps,
Jason.
> -----Original Message-----
> From: Lawrence Pravin [mailto:pravinl@xxxxxxxxxxx]
> Sent: Monday, March 19, 2001 11:30 AM
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Reg Counters
>
>
> Hi,
>
> I need some help on counters.
>
> The following is the sample XML file
>
> <Message>
> <ListOfContact>
> <Contact>
> <Name>AAA</Name>
> <Phone>123</Phone>
> </Contact>
> <Contact>
> <Name>BBB</Name>
> <Phone>321</Phone>
> </Contact>
> <Contact>
> <Name>CCC</Name>
> <Phone>432</Phone>
> </Contact>
> </ListOfContact>
> </Message>
>
> Should get turned into a XML like
>
> <NewMessage>
> <ListOfContact>
> <Contact>
> <Name index="1">AAA</Name>
> <Phone>123</Phone>
> <Name index="2">BBB</Name>
> <Phone>321</Phone>
> <Name index="3">CCC</Name>
> <Phone>432</Phone>
> </Contact>
> </ListOfContact>
> </NewMessage>
>
> So for each contact I should be able to display index=1, 2, 3
> etc., I tried
> Position but I get always only one.
>
> Thanks for your help.
>
> Regards
> Lawrence.
>
>
>
>
>
> ______________________________________________________________
> ___________
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|