I am new to XSLT in general so please bear with me...
With that in mind, what I am trying to do is check for a certain tag in the XML. If it is there I want to apply a template. If not, I want to add it (as a blank value). Basically always forcing it to be in the final output. How would I do this?
I had something like this...
<xsl:choose>
<xsl:when test="@href">
<xsl:apply-templates select="country" />
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
The top poriton of the code is what I think I have wrong. Need something in the otherwise
tag and my when
part is wrong i think.
<xsl:template match="country">
<xsl:if test=". != '' or count(./@*) != 0">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
Can anyone help? Thank you in advance.
EDIT:
Yes in the end i need at the very least a <country />
tag to be in the XML. But it is possible that it does not exist at all. If it doesn't exist, I have to put it in. An example good input would be <country>US</country>