in reply to section nesting

It's still not clear what you are trying to achieve. Do you want to validate that the XML is well formed (regardless of the content), or do you want to check that the content is consistent with the structure (so that 1.1.1 is nested two levels for example), or do you want to check that there is some semantic consistency (for example between id="xxx" and <no>yyy</no>)?

Can you provide an example including well formed data and bad data with the output you wish to generate?


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: section nesting
by anniyan (Monk) on Jul 26, 2005 at 05:02 UTC

    GrandFather thanks for your assistance. Here the section closings are correctly nested.

    <sec id="00005"><no>1.1</no> sfasfasdfadsfsdaf <sec id="00010"><no>1.1.1</no> sahfjsahdfasddfj </sec <sec id="00015"><no>1.1.2</no> sahfjsahdfasddfj <sec id="00020"><no>1.1.2.1</no> sahfjsahdfasddfj </sec> <sec id="00025"><no>1.1.2.2</no> safksajdklfasd </sec> </sec> <sec id="00015"><no>1.1.3</no> sahfjsahdfasddfj </sec> </sec> <sec id="00005"><no>1.2</no>....

    This is bad example

    <sec id="00005"><no>1.1</no> sfasfasdfadsfsdaf <sec id="00010"><no>1.1.1</no> sahfjsahdfasddfj </sec <sec id="00015"><no>1.1.2</no> sahfjsahdfasddfj </sec> #it should not be closed here (beca +use next sublevel is opening here) <sec id="00020"><no>1.1.2.1</no> sahfjsahdfasddfj </sec> <sec id="00025"><no>1.1.2.2</no> safksajdklfasd </sec> #that should be closed here <sec id="00015"><no>1.1.3</no> sahfjsahdfasddfj </sec> </sec> <sec id="00005"><no>1.2</no>....

    Whereas here the second level section should close after third level is closed. This is wrong nesting. Actually the levels are identified by number with dots.

    1.1 - first level 1.1.1 - second level (first section's sub level) 1.1.1.1 - third level (second section's sub level) 1.1.1.1.(i) - fourth level (third section's sub level) 1.1.1.1.(i).(a) - fifth level (fourth section's sub level)

    Here the elements are same for all levels <sec, so parser not showing errors. If the elements are different for subsections like <sec, <sec1 , <sec2, the parser would have showed error. so here the nesting we are finding with the help of numbers 1.1, 1.1.1,...

    updated

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