I have the source file like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<container id="111A" name="DEFAULT HARDDISK">
<list_of_folder id="listofcontainer_111A">
<folder id="222A">
<fileRef>3332</fileRef>
<fileRef>3333</fileRef>
</folder>
<folder id="222B">
<fileRef>3331</fileRef>
<fileRef>3335</fileRef>
<fileRef>3336</fileRef>
<fileRef>3334</fileRef>
<fileRef>3337</fileRef>
</folder>
</list_of_folder>
<coreldraw id="3332" name="model1"/>
<photoshop id="3331" name="model2" />
<excel id="3336" name="schedule" />
<access id="3335" name="program1" />
<mp3 id="3333" name="hello song" />
<mp4 id="3337" name="pop music" />
<wmv id="3334" name="rock rock music" />
</container>
-----------------
And the second source file, named dictionary.xml file to combine related information for the transformation
Code:
<?xml version="1.0" encoding="UTF-8"?>
<definition id="MANAGE_STORAGE">
<def id="HARDDISK" class="HARDDISK" drag= "editAttributeDblClk(evt,'$ID');MouseDown(evt);">
<def transform=" size(200 200)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="ABC" transform="rotate(270)">
<tspan>DEFAULT HARDDISK</tspan>
</text>
</def>
<def id="FOLDERS_$ID" class ="FOLDERS"/>
</def>
<def id="FOLDER" class=" FOLDER" drag= "editAttributeDblClk(evt,'$ID');MouseDown(evt);">
<def transform=" size100 100)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>DEFAULT FOLDER</tspan>
</text>
</def>
<def id="GRAPHICS_$ID" class ="GRAPHICS"/>
<def id="OFFICES_$ID" class ="OFFICES"/>
<def id="MUSICS_$ID" class ="MUSICS"/>
<def id="VIDEOS_$ID" class ="VIDEOS"/>
</def>
<def id ='CORELDRAW' class="CORELDRAW">
<def transform=" size(90 70)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>CORELDRAW FILE</tspan>
</text>
</def>
</def>
<def id ='PHOTOSHOP' class="PHOTOSHOP">
<def transform=" size(90 70)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCWD" transform="rotate(270)">
<tspan>PHOTOSHOP FILE</tspan>
</text>
</def>
</def>
<def id ='MP3' class="MP3">
<def transform=" size(70 70)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BWCD" transform="rotate(270)">
<tspan>MP3 FILE</tspan>
</text>
</def>
</def>
<def id ='MP4' class="MP4">
<def transform=" size(80 90)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="WBCD" transform="rotate(270)">
<tspan>MP4 FILE</tspan>
</text>
</def>
</def>
<def id ='WMV' class="WMV">
<def transform=" size(80 90)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>WMV FILE</tspan>
</text>
</def>
</def>
<def id ='ACCESS' class="ACCESS">
<def transform=" size100 50)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>ACCESS FILE</tspan>
</text>
</def>
</def>
<def id ='EXCEL' class="EXCEL">
<def transform=" size100 50)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>EXCEL FILE</tspan>
</text>
</def>
</def>
</definition>
-------------------
And the target file like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<def id="MANAGE_STORAGE" transform="scale(1)">
<def id="HARDDISKS" class="HARDDISKS">
<def id="111A" class="HARDDISK" drag= "editAttributeDblClk(evt,'$ID');MouseDown(evt);">
<def transform=" size(200 200)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="ABC" transform="rotate(270)">
<tspan>DEFAULT HARDDISK</tspan>
</text>
</def>
<def id="FOLDERS_111A" class ="FOLDERS">
<def id="222A" class="FOLDER" drag= "editAttributeDblClk(evt,'$ID');MouseDown(evt);">
<def transform=" size100 100)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan> FOLDER 1</tspan>
</text>
</def>
<def id="GRAPHICS_222A" class ="GRAPHICS">
<def id ='3332' class="CORELDRAW">
<def transform=" size(90 70)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>model1</tspan>
</text>
</def>
</def>
</def>
<def id="OFFICES_222A" class ="OFFICES"/>
<def id="MUSICS_222A" class ="MUSICS">
<def id ='3333' class="MP3">
<def transform=" size(70 70)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BWCD" transform="rotate(270)">
<tspan>hello song</tspan>
</text>
</def>
</def>
</def>
<def id="VIDEOS_222A" class ="VIDEOS"/>
</def>
<def id="222B" class="FOLDER" drag= "editAttributeDblClk(evt,'$ID');MouseDown(evt);">
<def transform=" size100 100)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan> FOLDER 2</tspan>
</text>
</def>
<def id="GRAPHICS_222B" class ="GRAPHICS">
<def id ='3331' class="PHOTOSHOP">
<def transform=" size(90 70)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCWD" transform="rotate(270)">
<tspan>model2</tspan>
</text>
</def>
</def>
</def>
<def id="OFFICES_222B" class ="OFFICES">
<def id ='3335' class="ACCESS">
<def transform=" size100 50)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>program1</tspan>
</text>
</def>
</def>
<def id ='3336' class="EXCEL">
<def transform=" size100 50)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>schedule</tspan>
</text>
</def>
</def>
</def>
<def id="MUSICS_222B" class ="MUSICS"/>
<def id="VIDEOS_222B" class ="VIDEOS">
<def id ='3337' class="MP4">
<def transform=" size(80 90)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="WBCD" transform="rotate(270)">
<tspan>pop music</tspan>
</text>
</def>
</def>
<def id ='3334' class="WMV">
<def transform=" size(80 90)"/>
<def transform="size(-25,100)" textgroup="yes">
<text x="0" y="0" style="BCD" transform="rotate(270)">
<tspan>rock rock music</tspan>
</text>
</def>
</def>
</def>
</def>
</def>
<def id="SHOTCUTS_111A" class ="SHOTCUTS"/>
</def>
</def>
</def>
My problem is how to deal with the transformation from 2 source files to 1 target file?
Explane use case: the harddisk contains 2 folders. Each folder contain some files. And the file will be categoried in the specific type of file. For example: mp3 in MUSIC class; mp4 and wmv in VIDEO class; excel and access in OFFICE class; coreldraw and photoshop in graphic class.
The first source file contains just name and id of each element. The second source file defines dictionary of extra information for each element that is presented in first source. And the target file is combination and restructure of source file.
Could anybody help me to deal with this transformation?
I'm in studying XSLT and try to find out the solution for my assignments that are ofcourse difference and also same difficulty level with this exercise.
Thanks