generating tags using xslt

"Pierre-Yves" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Organization -= Belgacom Usenet Service =-
Message-ID <[email protected]>
hello,
I have a xml files that looks like :

<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_EN">
        <value>
            <item name="SubParagraph_EN">
                <value>sub-paragraph 1 (english)</value>
            </item>
            <item name="SubParagraph_EN">
                <value>sub-paragraph 2 (english)</value>
            </item>
        </value>
    </item>
    <item name="Paragraph_FR">
        <value>
            <item name="SubParagraph_FR">
                <value>sub-paragraph 1 (french)</value>
            </item>
        </value>
    </item>
</record>

and I would like to transform it like this :

<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 goal, is to put all items that ends with _EN into <item name="english">,
all items that ends with _FR into <item name="french">, and all remaining
items into <item name="common">.

Someone told me I can easily do this with XSLT.
I started by mapping some fields "1 to 1" but since all <items> elements
have the same structure <item name="XXXX"><value>YYY</value></item> I would
like to know if it's possible to write a kind of function that could get
arguments or use some variables to simplify the code.


I hope someone will understand my question because I'm new at this and I
don't know how to explain what I'm looking for.


Thanks in advance,
Pierre.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.