[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Wrapping two different elements in parent element.

Subject: RE: Wrapping two different elements in parent element.
From: Vladimir Rodimyuk <VladimirR@xxxxxxxxxxxxx>
Date: Fri, 28 Sep 2007 14:45:55 +0300
RE:  Wrapping two different elements in parent element.
Hi, Bruno!
In case you are using XSL 1.0 you may find it helpful:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="something">
        <something_else>
            <usg>
                <xsl:apply-templates select="word_case"/>
            </usg>
        </something_else>
    </xsl:template>

    <xsl:template match="word_case">
        <xsl:variable name="node-index"
              select="count(preceding-sibling::word_case)+1"/>
        <form>
            <case><xsl:value-of select="."/></case>
            <orth>
                <xsl:value-of select="following-sibling::word_form[1]"/>
            </orth>
        </form>
    </xsl:template>
</xsl:stylesheet>

BTW, is it misprinting in your post or this is malformed source XML? I mean
the following:
>
> <word>G</word_case>
       ^--- wrong tag
>
> <word>some_word_G</word_form>
       ^--- wrong tag


Respectfully,
Volodymyr Rodymyuk


> -----Original Message-----
> From: Bruno Nahod [mailto:bnahod@xxxxxxx]
> Sent: Friday, September 28, 2007 2:00 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Wrapping two different elements in parent element.
>
> Hello,
>
> I'm working on transforming xml export from a dictionary application;
> witch is unbelievably unstructured into a well formed xml document
> (based on TEI recommendations). My biggest problem is how to wrap two
> (or more) elements into parent element. This is the simplified example
> of what I have and what I'm hoping to get;
>
> This I have (export)
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <something>
>
> <word_case>N</word_case>
>
> <word_form>some_word_N</word_form>
>
> <word>G</word_case>
>
> <word>some_word_G</word_form>
>
> <word_case>D</word_case>
>
> <word>some_word_D</word_form>
>
> </something>
>
> This I hope to get;
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <something_else>
>
> <usg>
>
> <form>
>
> <case>N</case>
>
> <orth>some_word_N</orth>
>
> </form>
>
> <form>
>
> <case>G</case>
>
> <orth>some_word_G</orth>
>
> </form>
>
> <form>
>
> <case>D</case>
>
> <orth>some_word_D</orth>
>
> </form>
>
> </usg>
>
> </something_else>
>
> Thank you very much
>
> Bruno.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.