Empty nodes vs no nodes
Posted: Mon Sep 30, 2019 3:09 am
Hi, pleas help! I am creating a XSLT 1.0 formato to export data from an XML doc. I have an example of my problem below:
I am extracting all the data using only wildcards like name(), /* or . so I do not know the name of any node this is just an example.
My problem is that when getting the values the node <title> returns nothing I need to get an error text or something worning me that there is a node with nothing. My test code lookes like this but it cant see the empty tag pleas help
Code: Select all
<cd name="Bonny" size="">
<title></title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>19.90</price>
<year>1928</year>
</cd>
My problem is that when getting the values the node <title> returns nothing I need to get an error text or something worning me that there is a node with nothing. My test code lookes like this but it cant see the empty tag pleas help
Code: Select all
<xsl:for-each select="*//@*">
<xsl:choose>
<xsl:when test=".='' "><text style="color:red;"> Error </text></xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
'