Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: XML::Twig question

by anniyan (Monk)
on Nov 25, 2005 at 11:30 UTC ( #511634=note: print w/ replies, xml ) Need Help??


in reply to Re^3: XML::Twig question
in thread XML::Twig question

mirod thanks for your patience and assistance. I will explain fully the job i am doing now.

I am having an ini file in which they give conditions like shown below.

########## condition ############## <condition> <chap/<ch/<sec/<p/<anchor==<anchors </condition> ########## andcondition ############## <andcondition> <book&&<chap/<ch/<sec/<p/<para==<paragraph </andcondition> ########## orcondition ############## <orcondition> <book||<chap/<ch/<sec/<p/<ca==<caption </orcondition> ########## noncondition ############## <noncondition> <para/<author==<auth </noncondition> ########## andnoncondition ############## <andnoncondition> <book&&<chap//<anchor/<para/<it==<italics </andnoncondition> ########## ornoncondition ############## <ornoncondition> <book||<chap//<anchor/<para/<b==<bold </ornoncondition>

Now i will explain what the ini file is to do.


1. <condition>: we have to fetch that path and search in the xml file and replace 'anchor' with 'anchors' which is given after == sign.
2. <andcondition>: In and condition 'para' element should be checked in both parent 'book' and 'chap' and if it is present in both then replace 'para' with 'paragraph' which is given after == sign
3. <orcondition>: In or condition 'ca' element should be checked in both parent 'book' and 'chap' and if it is present either in one or both then replace 'para' with 'caption' which is given after == sign
4. <noncondition>: In non condition we have to fetch that path and search in the xml file and don't replace 'author' with 'auth' in that location and replace it in other locations which is given after == sign.
5. <andnoncondition>: In and non condition 'it' element should be checked in both parent 'book' and 'chap' and if it is present in both then replace 'para' with 'paragraph' in all locations except in the given path.
6. <ornoncondition>: In or non condition 'b' element should be checked in both parent 'book' and 'chap' and if it is present either in one or both then replace 'b' with 'bold' in all locations except in the given path.

I will give just a sample xml file for the above conditions. Also the tool should do from 6 to 1 ie in reverse order, <ornonconition> to <condition>.

This is my requuirement and i am doing as shown in my original node. How to do this. There will be more than one entries in each condition.

input xml

<chap> <ch> <sec> <p> <anchor><b>THE ILIAD</b></anchor> <para> <author>HOMER</author> </para> <ca>check</ca> </p> </sec> <sec> <author><it>HOMER</it></author> <p> <anchor>BOOK I</anchor> <para> Sing, O goddess, <it>the anger </it>of Achilles son of Peleu +s, that brought countless ills upon the Achaeans. </para> </p> </sec> </ch> </chap>

I apologise for such long post.

Regards,
Anniyan
(CREATED in HELL by DEVIL to s|EVILS|GOODS|g in WORLD)


Comment on Re^4: XML::Twig question
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://511634]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-10-21 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls