in reply to XML::Twig question
As per the error message: the expression is not valid. The '//' is not recognized in the expression (see twig_handlers syntax). Is there any reason why you don't use just plainanchor?
Oh, and why the monkeying with '<' in the expression?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Twig question
by anniyan (Monk) on Nov 24, 2005 at 11:11 UTC | |
mirod If you go through my yesterday's posting you can able to know my requirement. I want to avoid giving full path, i just want to give only the starting tags and ending tags with any depth inbetween. How to do that? Also as per my ini file i am getting the input with '<' symbol, but i will replace that before passing it to twig handler. Regards, | [reply] |
by mirod (Canon) on Nov 24, 2005 at 17:35 UTC | |
Honestly, I can't think of too many cases where being able to specify the top and lowest level tags only would make much sense. So maybe a more realistic example, or a quick explanation of why you need to do this, would probably get a more relevant answer. Anyway, in general, when you get to the limit of the mini-language used to declare handlers, the solution is to "finish the job" in the handler itself. So filter first the regular way, and test the rest of the condition at the begining of the handler, returning if it is not met. So you would have for example:
Does it help? | [reply] [d/l] |
by anniyan (Monk) on Nov 25, 2005 at 11:30 UTC | |
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.
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
I apologise for such long post. Regards, | [reply] [d/l] [select] |