tricky xsl transformation needed...

Discussion in 'XML' started by stefan.oedenkoven@googlemail.com, Jun 16, 2008.

  1. Guest

    Hi ng,

    how can i transform this source-xml in the target xml? is it possible
    to get <a>Ax</a> enclosed?

    source-xml:
    <z>
    A1
    <b>B1</b>
    A2
    </z>


    desired target-xml:
    <z>
    <a>A1</a>
    <b>B1</b>
    <a>A2</a>
    </z>


    ....anyone?
    , Jun 16, 2008
    #1
    1. Advertising

  2. wrote:

    > how can i transform this source-xml in the target xml? is it possible
    > to get <a>Ax</a> enclosed?
    >
    > source-xml:
    > <z>
    > A1
    > <b>B1</b>
    > A2
    > </z>
    >
    >
    > desired target-xml:
    > <z>
    > <a>A1</a>
    > <b>B1</b>
    > <a>A2</a>
    > </z>


    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:eek:utput method="xml" indent="yes"/>

    <xsl:template match="z/text()[starts-with(normalize-space(.), 'A')]">
    <a>
    <xsl:value-of select="normalize-space(.)"/>
    </a>
    </xsl:template>

    <xsl:template match="@* | node()">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
    </xsl:template>

    </xsl:stylesheet>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jun 16, 2008
    #2
    1. Advertising

  3. Guest

    Hi Martin,

    thanks a lot...!!!

    //stefan
    , Jun 16, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jyrki Keisala

    Tricky XSL question (?)

    Jyrki Keisala, Jan 2, 2004, in forum: XML
    Replies:
    4
    Views:
    450
    Jyrki Keisala
    Jan 5, 2004
  2. Replies:
    1
    Views:
    3,598
    A. Bolmarcich
    May 27, 2005
  3. Replies:
    0
    Views:
    529
  4. jl
    Replies:
    3
    Views:
    418
    Andy Dingley
    Aug 23, 2006
  5. Replies:
    9
    Views:
    532
    CBFalconer
    Apr 25, 2006
Loading...

Share This Page