P
Phoebian
Hi all,
Here is a little concept problem, and I need some guideline. I am
currently developing a application which delivers XML files. I want
then to sequentially perform some actions on selected part of that XML
file through a XPath expression. These action have actually to modify
the structure of the XML file itself and that seems to me like a big
hurdle. Maybe I am wrong but I will try to explain what I want to
do...
the XML file ressembles that... very roughly
<Root>
<Obj1>
<Head action="yes">blah</Head>
<Body>blah</Body>
<Foot action="yes">blah</Foot>
</Obj1>
...
<Obj2>
<Head>blah</Head>
<Body action="yes">blah</Body>
<Foot>blah</Foot>
</Obj2>
</Root>
let say my XPath expression is '//*[@action="yes"]'. Now for each of
the 3 concerned element I want to do some formatting...
<Root>
<Obj1>
<Head action="yes">
<bonus>yo</bonus> <--- added as part of the formatting
<text>blah<text> <--- formatting
</Head>
<Body>blah</Body>
<Foot action="yes">
<text>blah<text> <--- formatting
<bonus>yo</bonus> <--- added as part of the formatting
</Foot>
</Obj1>
...
<Obj2>
<Head>blah</Head>
<Body action="yes">
<text>blah<text> <--- formatting
</Body>
<Foot>blah</Foot>
</Obj2>
</Root>
Here is my problem. I first convert my XML file to a DOM
representation, in order to be able to do sequential processing.
Indeed a mere XSLT transfo is of no help since I want to be able to do
many thing between two actions. I then do the XPath evaluation but
further modification of the resulting nodelist will never be reflected
in the original XML files. I should say that I am using python 2.3,
and Domlette/XPath from 4suite to do that.
My question is:
How can I use the resulting XPath result as a live representation of
the underlying XML nodes (DOM concept) so that I can both perform
sequential action (by traversing the resulting xpath nodelist) and
reflects modifications done on those same nodes in the original XML
file?
Maybe I am wrong on the live object concept of the DOM but I thought
it would be possible. Any idea to achieve that would be welcome...
Phoebian
Here is a little concept problem, and I need some guideline. I am
currently developing a application which delivers XML files. I want
then to sequentially perform some actions on selected part of that XML
file through a XPath expression. These action have actually to modify
the structure of the XML file itself and that seems to me like a big
hurdle. Maybe I am wrong but I will try to explain what I want to
do...
the XML file ressembles that... very roughly
<Root>
<Obj1>
<Head action="yes">blah</Head>
<Body>blah</Body>
<Foot action="yes">blah</Foot>
</Obj1>
...
<Obj2>
<Head>blah</Head>
<Body action="yes">blah</Body>
<Foot>blah</Foot>
</Obj2>
</Root>
let say my XPath expression is '//*[@action="yes"]'. Now for each of
the 3 concerned element I want to do some formatting...
<Root>
<Obj1>
<Head action="yes">
<bonus>yo</bonus> <--- added as part of the formatting
<text>blah<text> <--- formatting
</Head>
<Body>blah</Body>
<Foot action="yes">
<text>blah<text> <--- formatting
<bonus>yo</bonus> <--- added as part of the formatting
</Foot>
</Obj1>
...
<Obj2>
<Head>blah</Head>
<Body action="yes">
<text>blah<text> <--- formatting
</Body>
<Foot>blah</Foot>
</Obj2>
</Root>
Here is my problem. I first convert my XML file to a DOM
representation, in order to be able to do sequential processing.
Indeed a mere XSLT transfo is of no help since I want to be able to do
many thing between two actions. I then do the XPath evaluation but
further modification of the resulting nodelist will never be reflected
in the original XML files. I should say that I am using python 2.3,
and Domlette/XPath from 4suite to do that.
My question is:
How can I use the resulting XPath result as a live representation of
the underlying XML nodes (DOM concept) so that I can both perform
sequential action (by traversing the resulting xpath nodelist) and
reflects modifications done on those same nodes in the original XML
file?
Maybe I am wrong on the live object concept of the DOM but I thought
it would be possible. Any idea to achieve that would be welcome...
Phoebian