Reputation: 1168
Choose statement goes as positive on test="./Category" even if /Category is empty.
The value of Category values is < ![CDATA[]] > if empty and < ![CDATA[some_code]] > if full.
It seems like CDATA leaves "" to the value or something like that.
<xsl:when test="./Category">
<ref type="category"><xsl:value-of select="./Category" /></ref>
</xsl:when>
<xsl:otherwise>
<id_category_default>2</id_category_default>
</xsl:otherwise>
</xsl:choose>
Upvotes: 0
Views: 401
Reputation: 70618
The test test="./Category"
is simply testing for the existing of an element named Category
in your XML, and does not take into an child nodes of that element.
The test you want is probably this (Note that ./
is not necessary here)
<xsl:when test="Category[normalize-space()]">
This will ignore text consisting of nothing but white-space. If you consider the presence white-space to be "non-empty", try this instead...
<xsl:when test="Category[. != '']">
Upvotes: 3