xsl-list
[Top] [All Lists]

[xsl] change element to sibling's child node

2006-08-21 15:25:04

I need to do xml to xml transform. Here is my problem. Could you please
give me the help?

 

Original XML file:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint>
        <co>
                <co_body>
                        <source_id>100</source_id>

                        <CGMS_indicator>0</CGMS_indicator>
                        <c_PIP_indicator>0</c_PIP_indicator>
                        <c_definition>
                                <service_type>100</service_type>
                                <HTTP_indicator>0</HTTP_indicator>
                                <number_of_streams>2</number_of_streams>
                                <root_ID>100</root_ID>
                                <stream_loop>
                                        <stream_definition>
        
<stream_type>2</stream_type>                                            
                                                <SCID>100</SCID>
        
<descriptors_loop_length>compute</descriptors_loop_length>
                                                <descriptor_loop>
        
<about_descriptor>some description</about_descriptor>
        
<additional_descriptor>other description</additional_descriptor>
                                                </descriptor_loop>
                                        </stream_definition>
                                </stream_loop>
                        </c_definition>
                </co_body>
        </co>
</blueprint>


 

Need to do following transforms:

move CGMS_indicator and its text value under c_definition 
in c_definition: 
        add new element called PCR_PID_indicator, the text value equals
to the PID value of first stream in stream loop 
        calculate stream number which start from root_ID and end with
root_ID+ number_of_streams, the gap is 1 
        copy descriptors_loop_length and descriptor_loop from
c_definition\stream_loop\stream_definition to c_definition 
in stream_loop 
        rename stream_definition to stream 
        recursive create stream element number_of_streams times 
in each stream i: 
        rename SCID to PID, the text value equals 4112+2*i 
        add new element called ECM, the text value equals PID+1 
 

the result XML file:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint>
        <co>
                <co_body>
                        <source_id>100</source_id>

                        <c_PIP_indicator>0</c_PIP_indicator>
                        <c_definition>
                                <service_type>100</service_type>
                                <CGMS_indicator>0</CGMS_indicator>
        
<PCR_PID_indicator>4112</PCR_PID_indicator>
                                <HTTP_indicator>0</HTTP_indicator>
                                <number_of_streams>2</number_of_streams>
                                <root_ID>100</root_ID>
                                <stream_loop>
                                        <stream>
        
<stream_type>2</stream_type>                                            
                                                <PID>4112</PID>
                                                <ECM>4113</ECM>
        
<descriptors_loop_length>compute</descriptors_loop_length>
                                                <descriptor_loop>
        
<about_descriptor>some description</about_descriptor>
        
<additional_descriptor>other description</additional_descriptor>
                                                </descriptor_loop>
                                        </stream>
                                        <stream>
        
<stream_type>2</stream_type>                                            
                                                <PID>4114</PID>
                                                <ECM>4115</ECM>
        
<descriptors_loop_length>compute</descriptors_loop_length>
                                                <descriptor_loop>
        
<about_descriptor>some description</about_descriptor>
        
<additional_descriptor>other description</additional_descriptor>
                                                </descriptor_loop>
                                        </stream>

                                </stream_loop>
                        </c_definition>
        
<descriptors_loop_length>compute</descriptors_loop_length>
                        <descriptor_loop>
                                <about_descriptor>some
description</about_descriptor>
                                <additional_descriptor>other
description</additional_descriptor>
                        </descriptor_loop>
                </co_body>
        </co>
</blueprint>
 

 

Thanks,

Jesscia


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>