[Solved] I need to add a text value to an self closing empty tag, using XSLT


You need an identity transformation template:

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

plus a template for the name tag:

<xsl:template match="name[not(node())]">
   <name>UNK</name>
</xsl:template>

Wrap this within the stylesheet tag, and add an xml header:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="name[not(node())]">
   <name>UNK</name>
  </xsl:template>
</xsl:stylesheet>

11

solved I need to add a text value to an self closing empty tag, using XSLT