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

Replacing the element's attribute in sequential order

Subject: Replacing the element's attribute in sequential order
From: "varun bhatnagar varun292006@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 1 Aug 2014 08:16:07 -0000
 Replacing the element's attribute in sequential order
Hi,

I have few xml files (depends on user how much he/she wants to pass). I
have to take those files and merge them, so I have created a loop and in
that I am passing these files one by one. For this I have written few rules
to merge. But there is this <Procedure> tag where I am stuck. To merge this
I need to parse each Procedure and have to modify its attributes (attrProc
and attrLevel). I have to replace the attrProc attribute with a sequential
value and for me this will set a unique "Level" for each Procedure tag and
later I will process them based on their level.


*File1.xml*

*<?xml version="1.0" encoding="UTF-8"?>*
*<InfoTag>*
*<Procedure attrProc="TestProcA" attrLevel="1">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*

* <Procedure attrProc="TestProcB" attrLevel="2">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
*</InfoTag>*


*File2.xml*

*<?xml version="1.0" encoding="UTF-8"?>*
*<InfoTag>*
*<Procedure attrProc="TestProcC" attrLevel="3">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*

* <Procedure attrProc="TestProcD" attrLevel="4">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
*</InfoTag>*


I am trying to fetch an output file which looks like this:

*Output.xml*

*<InfoTag>*
*<Procedure attrProc="1" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
* <Procedure attrProc="2" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
*<Procedure attrProc="3" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>*
* <Procedure attrProc="4" attrLevel="### NOT UNIQUE ###">*
*      <downTime>*
*        <acceptableDownTime>*
*          <all/>*
*        </acceptableDownTime>*
*        <downTimePeriod time="600000000"/>*
*      </downTime>*
*    </Procedure>    *
*</InfoTag>*


I am thinking of looping it and will count the occurrences of it and then I
am thinking to replace the value. But I am not able to do that.
Can anyone tell me how to achieve this. How can I loop every Procedure tag
and and append the attrProc attribute value in a sequential order?

Thanks,
BR,
Varun

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.