How to convert self-terminating xml tag to empty xml tags when integrating WSO2
I'm working on a project where I need to have empty xml tags formatted like this instead of self-closing tags , although both are equal, it looks like client execution is wrong. It accepts an empty tag and rejects the self-closing tag. <xyz></xyz>
<xyz/>
I am using WSO2 Integrator, however it forces all empty tags to be formatted as self-closing tags. Is there a way to reformat it as empty tags as explained?
+3
source to share
1 answer
Try with XSLT mediator. They can work.
<!-- Define a dummy variable with empty content -->
<xsl:variable name="empty" select="''"/>
<!-- Copy input to output, most of the time -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
<!-- Insert empty content into copied element -->
<xsl:value-of select="$empty"/>
</xsl:copy>
</xsl:template>
or
<!-- Identity template for empty elements -->
<xsl:template match="*[not(node())]">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
<xsl:value-of select="$empty"/>
</xsl:copy>
</xsl:template>
0
source to share