Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 22nd, 2007, 05:02 PM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default generate index

Hi,

Below provided is the source and the transformed xml. I am facing problem generating the value for 'index' attribute of the <C> tag in the transformed XML. As the data needs to be read from two different nodes, i am not sure how to do this. any help on this would be great.

Structure of source XML:

<A>
  <B>
    <F>
      <C>
        <name> bnn </name>
        .
        .
      </C>
      <C>
        <name> wer</name>
        .
        .
      </C>
      <C>
        <name> 234</name>
        .
        .
      </C>
    </F>
    <D>
     <E>
      <C>
        <name> tyu</name>
        .
        .
      </C>
     <E>
    </D>
  </B>
</A>

Structure of transformed XML:

<A>
  <B>
     <D/>
     <new-node>
               <C index=0>
                  <name> bnn </name>
                  .
                  .
                </C>
                <C index=1>
                  <name> wer</name>
                  .
                  .
                </C>
                <C index=2>
                  <name> 234</name>
                  .
                  .
                </C>

                <C index=3>
                  <name> tyu</name>
                  .
                  .
                </C>

     <new-node>
  </B>
</A>
 
Old May 23rd, 2007, 01:14 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well you should be able to use position() function if you just create the outer shell and then populate the C elements. Alternatively the xsl:number instruction might be needed. Without seeing how you are doing the transform it's hard to say.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate xsml m_rajib Crystal Reports 0 May 4th, 2006 07:13 AM
generate too may threads mikel79 All Other Wrox Books 0 April 13th, 2006 07:52 AM
Generate birthday wish Prabhakar_dt Classic ASP Basics 8 January 29th, 2005 02:09 AM
Generate links darkocobe Classic ASP Basics 1 October 15th, 2004 09:18 AM
can i generate index column alyeng2000 SQL Server 2000 0 February 25th, 2004 07:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.