[xsl] tansforming an XML into another XML help needed !

Subject: [xsl] tansforming an XML into another XML help needed !
From: Pierre-Yves <kyrios@xxxxxxxxxxxxxx>
Date: Wed, 20 Apr 2005 06:43:44 -0700 (PDT)
*** Hello,
***
*** I have XML files that look like this :

<record name="myRecord">
    <item name="PageName">
        <value>myPage</value>
    </item>
    <item name="Title_EN">
        <value>english title</value>
    </item>
    <item name="Title_FR">
        <value>french title</value>
    </item>
    <item name="Paragraph">
        <value>
            <item name="SubParagraph_EN">
                <value>sub-paragraph 1 (english)</value>
            </item>
            <item name="SubParagraph_EN">
                <value>sub-paragraph 2 (english)</value>
            </item>
        </value>
        <value>
            <item name="SubParagraph_FR">
                <value>sub-paragraph 1 (french)</value>
            </item>
        </value>
     </item>
</record>

*** And I would like to convert them in this format :

<record name="myRecord">
    <item name="common">
        <value>
            <item name="PageName">
                <value>myPage</value>
            </item>
        </value>
    </item>
    <item name="english">
        <value>
            <item name="Title">
                <value>english title</value>
            </item>
            <item name="Paragraph">
                <value>
                    <item name="SubParagraph">
                        <value>sub-paragraph 1 (english)</value>
                    </item>
                    <item name="SubParagraph">
                        <value>sub-paragraph 2 (english)</value>
                    </item>
                </value>
            </item>
        </value>
    </item>
    <item name="french">
        <value>
            <item name="Title">
                <value>french title</value>
            </item>
            <item name="Paragraph">
                <value>
                    <item name="SubParagraph">
                        <value>sub-paragraph 1 (french)</value>
                    </item>
                </value>
            </item>
        </value>
    </item>
</record>


*** The items that ends with _EN should go in "english" and
*** the _EN suffix must be removed (Title_EN -> Title)
*** The ones that ends with _FR should go in "french" and
*** the _FR suffix must be removed (Title_FR -> Title)
*** The ones that don't end with _EN or _FR should go in "common"
*** if they only have 1 <value> child.
*** if they have many value childs, it depends on the items they
*** contains (look at Paragraph & SubParagraph).
*** Ideally there migth be several sub levels
*** (i.e: Paragraph -> SubParagraph -> SubSubParagraph_EN)
***
*** I have done something that works more or less for the items
*** that contains only 1 <value> tag but I don't succeed doing
*** an XSL file that works with this "complex" structure.
***
*** I would be grateful if someone could help me !
*** Regards,
*** Pierre.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread