tags:

views:

24

answers:

0

I have two xml document: one as source file and one as dictionary file. Because I need to restructure the source file and also combine extra information for each element in first source file. I'm new bie in XSL transformation that why this is the hard assignment for me. I think somebody can help me to resolve this problem. - First I don't know how to deal with $ID in dictionary file. - Second I don't know how to deal with hierarchical structure in transformation. First file(source file 1)

<?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>

dictionary file that define more detail of main element (source file 2)

<?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>

the target file will become this:

<?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>

So I know that I have to deal with document() function that is declared as a variable in transformation file. But I need to know how to combine and restructure from two XML source file to 1 XML target file. Anybody help me? Every helping is welcome. Or could you show me some stuff to deal with this problem? Or you can help me to identify the algorithm for this transformation. Thank alot