Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > tricky xsl transformation needed...

Reply
Thread Tools

tricky xsl transformation needed...

 
 
stefan.oedenkoven@googlemail.com
Guest
Posts: n/a
 
      06-16-2008
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?

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-16-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xslutput 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/
 
Reply With Quote
 
 
 
 
stefan.oedenkoven@googlemail.com
Guest
Posts: n/a
 
      06-16-2008
Hi Martin,

thanks a lot...!!!

//stefan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tricky XSL transformation jl XML 3 08-23-2006 01:57 PM
a tricky if else(maybe not tricky but impossible) nirkheys@gmail.com C Programming 9 04-25-2006 06:13 PM
Use output of XSL transformation as new XSL stylesheet barney.b@iname.com XML 0 01-16-2006 02:29 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
Tricky XSL question (?) Jyrki Keisala XML 4 01-05-2004 09:18 AM



Advertisments