Archive for tag: Strip text from XML elements

Strip text from XML elements, rearrange it, and concatenate it with XSLT?

In XML how do I strip text from XML elements, or reaarrange it and concatenate it using XSLT

Considering the following XML: 

  <contrib contrib-type="author"> 
  <contrib contrib-type="author"> 

How can I transform the contents of these elements to get this output in an XML format using XSLT?

<Authors contrib-type="author">Bart Simpson</Authors> 
<Authors contrib-type="author">Dr. Zoidberg</Authors>

 Solution would be for above like that using XSLT with efficient way

<xsl:stylesheet version="1.0" xmlns:xsl=""> 
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml"/> 
<xsl:strip-space elements="*"/> 
    <!-- identity rule --> 
    <xsl:template match="node()|@*"> 
            <xsl:apply-templates select="node()|@*"/> 
        <!-- Authors --> 
        <xsl:template match="contrib[@contrib-type='author']"> 
            <Authors contrib-type="{@contrib-type}"> 
                <xsl:value-of select = "concat(name/first-name, ' ', name/last-name)" /> 

I hope this would help you guys,

Thank you for going through this article