First xslt extract one element from xml and apply a root node, second one simply removes namespaces and attributes. Needs to combine both into one

1st xslt contains

    <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />         
    <xsl:template match="/">
        <xsl:apply-templates select="/ns0:ClinicalDocument_HEPPI30_Epic_CCDA"/> 
    </xsl:template>

    <xsl:template match="/ns0:ClinicalDocument_HEPPI30_Epic_CCDA">
        <ns0:MrmMessages_3_0>
            <CCD>
                <xsl:copy-of select="./@*" />
                <xsl:copy-of select="./*" />
            </CCD>
             </ns0:MrmMessages_3_0>

2nd xslt contains

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

  <xsl:template match="*">
    <xsl:element name="{local-name(.)}">
      <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="@*">
    <xsl:attribute name="{local-name(.)}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
</xsl:stylesheet>

I want to combine the two xslts to one.

1

There are 1 answers

0
y.arazim On

I think you want:

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

<xsl:template match="*">
    <xsl:element name="{local-name()}">
        <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
</xsl:template>

<xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
        <xsl:value-of select="."/>
    </xsl:attribute>
</xsl:template>

<xsl:template match="/ns0:ClinicalDocument_HEPPI30_Epic_CCDA">
    <ns0:MrmMessages_3_0>
        <CCD>
            <xsl:apply-templates select="@* | node()"/>
        </CCD>
    </ns0:MrmMessages_3_0>
</xsl:template>
    
</xsl:stylesheet>

I could not test this because you did not post an input example. And your first XSLT is missing both the beginning and the end, so I could not assign a proper value to the ns0 namespace.