i am trying to assign unique values to nodes read from XML file.. eg: consider this XML file:
<breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description> ...Strong Belgian waffles...</description> <calories>650</calories> <chef type="Senior"> <chef1>Mr. A</chef1> <chef2>Mr. B</chef2> </chef> </food> <food> <name>Strawberry Waffles</name> <price>$7.95</price> <description>...Light Strawberry waffles...</description> <calories>900</calories> <chef type="Senior"> <chef1>Mr. A</chef1> <chef2>Mr. B</chef2> </chef> </food> <breakfast_menu>
now assigning these nodes "a unique value" has to be done following the LSDX labelling pattern i.e:
To the document element we first give an “a”.As there is no parent node for the document element, we assign “0” at the front of that “a” . “0a” is the unique code for the document element (breakfast_menu). For the children nodes of “0a”, we continue with the next level of the XML tree which is “1” then the code of its parent node which is “a” and a concatenation “.” . We then add a letter “b” for the first child, letter “c” for the second child, “d” for the third child and so on.Unique codes for children nodes of “0a” shall be “1a.b”, “1a.c”, “1a.d”, etc.Hence foe the above given XML the mapping would look something like this:
0a breakfast_menu 1a.b food 2ab.b name 2ab.c price 2ab.d description 2ab.e calories 2ab.f chef 3abf.b chef1 3abf.c chef2 1a.c food 2ac.b name 2ac.c price 2ac.d description 2ac.e calories 2ac.f chef 3acf.b chef1 3acf.c chef2
For more samples about LSDX labelling : 1.) Section 3.1 LSDX Labelling on this link: http://crpit.com/confpapers/CRPITV39Duong.pdf
2.) Fig 3 on page 1189 on this link: http://books.google.co.in/books?id=F...0nodes&f=false
right now i am using SAX parser to read xml and get the nodes in their hierarchical order..now the problem is that i have to assign these specific value to their respective nodes using java..can any1 help me out as to how to do this..