Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Replace element text within xml

From: DanKelley@-----------.---------.---
To: NULL
Date: 9/2/2005 4:09:00 AM
Fantastic! Thanks a lot for your help.

Dan

"Dimitre Novatchev" wrote:

> 
> "Dan Kelley" <DanKelley@d...> wrote in message 
> news:ECA376ED-22A2-434B-B314-97D2B1946DA0@m......
> > Thanks for both of your help. I tried the suggested solution, however 
> > there
> > was a problem. It replaced the first <test-suite> element, but then output
> > all of the xml between the elements as text, completely stripping out all 
> > of
> > the following xml elements and attributes.
> >
> > I tried google, but all articles seem to assume a solid understanding of
> > xslt, or contain the same content as
> > www.dpawson.co.uk/xsl/sect2/identity.html.
> 
> 
> Below is a transformation, which copies all nodes with the exception that it 
> removes all "-" from any element's name:
> 
> <xsl:stylesheet version="1.0"
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:output omit-xml-declaration="yes" indent="yes"/>
> 
>   <xsl:template match="node()|@*">
>     <xsl:copy>
>       <xsl:apply-templates select="node()|@*"/>
>     </xsl:copy>
>   </xsl:template>
> 
>   <xsl:template match="*[contains(name(),'-')]">
>     <xsl:element name="{translate(name(),'-','')}" 
> namespace="{namespace-uri()}">
>       <xsl:copy-of select="namespace::*"/>
>       <xsl:apply-templates select="node()|@*"/>
>     </xsl:element>
>   </xsl:template>
> </xsl:stylesheet>
> 
> When the above transformation is applied on your original source xml (made 
> just a little more complex by adding namespace prefixes) :
> 
> <x:test-results name="name" xmlns:x="x:x">
>     <test-suite name="name">
>         <results>
>             <test-case name="name">
>                 ...
>             </test-case>
>         </results>
>     </test-suite>
> </x:test-results>
> 
> the wanted result is produced:
> 
> <x:testresults name="name" xmlns:x="x:x">
>     <testsuite name="name">
>         <results>
>             <testcase name="name">
>                 ...
>             </testcase>
>         </results>
>     </testsuite>
> </x:testresults>
> 
> 
> Cheers,
> Dimitre Novatchev
> 
> 
> 
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent