|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need advice on splitting xml data
Hi, I have an xml file which I need split into two files due to a change in our implementation for a newer version.
Basically I've got something like this: <store> <inventory> <item name="a" price="1" stock="9"/> <item name="b" price="2" stock="8"/> <item name="c" price="1" stock="7"/> </inventory> <inventory> <item name="d" price="3" stock="6"/> <item name="e" price="5" stock="0"/> </inventory> </store> and using xslt I want to split it into two files like this: File A: <store> <item id="1" stock="9"/> <item id="2" stock="8"/> <item id="3" stock="7"/> <item id="4" stock="6"/> <item id="5" stock="0"/> </store> File B: <items> <item id="1" name="a" price="1"/> <item id="2" name="b" price="2"/> <item id="3" name="c" price="1"/> <item id="4" name="d" price="3"/> <item id="5" name="e" price="5"/> </items> Should I generate one of the files first and then generate the 2nd file by getting the 1st as an external document? Seems like a little bit of a hassle; I'd like to find a simpler way if possible. Also, is there any easy way to get a random unique id #? Thanks Joseph |
|
#2
|
|||
|
|||
|
ah, never mind was making this problem a lot more complicated than it had to be. Friend gave me a solution to create a secondary xml file:
<inventory> <item name="a" price="1" stock="9"/> <item name="b" price="2" stock="8"/> <item name="c" price="1" stock="7"/> <item name="d" price="3" stock="6"/> <item name="e" price="5" stock="0"/> </inventory> and use the position function to create the other 2 with linked ids. thanks anyways ![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Need advice on splitting xml data |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|