Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75370

How to loop through nodes of xml through xslt

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <varun292006@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'output': 0.05; 'attribute': 0.07; '&lt;?xml': 0.09; 'append': 0.09; 'subject:xml': 0.09; 'subject:How': 0.10; '8bit%:32': 0.16; 'fetch': 0.16; 'order?': 0.16; 'sequential': 0.16; 'files.': 0.16; 'thanks,': 0.17; 'trying': 0.19; 'merge': 0.24; 'skip:e 30': 0.24; 'looks': 0.24; 'this:': 0.26; 'xml': 0.29; 'message- id:@mail.gmail.com': 0.30; 'anyone': 0.31; 'file': 0.32; 'this.': 0.32; 'skip:# 10': 0.33; 'skip:& 30': 0.33; 'received:google.com': 0.35; 'hi,': 0.36; 'two': 0.37; 'skip:& 10': 0.38; 'to:addr :python-list': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'how': 0.40; 'read': 0.60; 'skip:\xc2 10': 0.60; 'tell': 0.60; 'skip:a 30': 0.61; 'skip:t 30': 0.61; 'tag': 0.61; '8bit%:10': 0.64; 'different': 0.65; '\xc2\xa0\xc2\xa0': 0.74; 'br,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=wPUtr24a6d/jcSFX2CLYBr/o7IaeOM6Ua6AJONKJ48s=; b=g6PFLoPWMT2QJ5BIk/TTf3Ry7GN1CLxnWIk4hQg3xCyf5Te0JcKPBzQAyRIvhqxVhh /44lPkz5tfzHI6TDeQQsb+v5Mn2D7fbVgdt0fJ9J7C0ldkY0SHYMZI8akhHVtw314C8f MFLWZV9kIVW9N6BkpS5MbFGA4YVkgO4eBvkt1ntDupGkuMlXwv3GEfvpYAZRtjIqRccw ru0L/BEsCZ8h4sUWY26hFRrNXIYncmqszt11rNFUuaLEklhuDjC+kwiCaC5cIq3+DuSY aZgcQg7XRd2WuJHG/UMN8qt4ZeqPcf4P5+j9pgK8ja6aNpzanZeUdLwrIdHK2FwMjn0I YCLg==
MIME-Version 1.0
X-Received by 10.236.2.72 with SMTP id 48mr6014964yhe.124.1406722598633; Wed, 30 Jul 2014 05:16:38 -0700 (PDT)
Date Wed, 30 Jul 2014 14:16:38 +0200
Subject How to loop through nodes of xml through xslt
From varun bhatnagar <varun292006@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=089e013a0d6eca083d04ff6820db
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12432.1406722601.18130.python-list@python.org> (permalink)
Lines 200
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406722601 news.xs4all.nl 2943 [2001:888:2000:d::a6]:60957
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75370

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

I have two xml files.

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

The number of Procedure tag (<Procedure>) can be different every time. So I
have to read this tag every time from each xml and then merge it
sequentially.
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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

How to loop through nodes of xml through xslt varun bhatnagar <varun292006@gmail.com> - 2014-07-30 14:16 +0200

csiph-web