Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

What;s wrong with my XSLT?

$
0
0
Hi, 
I have an XML document from which I have to exclude records with all their child elements empty.

<Employees><Employee><FirstName>Sam</FirstName></Employee><Employee><FirstName></FirstName></Employee></Employees>
 
  So the resulting XML Document have to look like this:  
<Employees><Employee><FirstName>Sam</FirstName></Employee></Employees>


After whole day of banging with it I came up with the following XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="@*|node()"><xsl:if test=". != ''"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:if></xsl:template></xsl:stylesheet>
which still gives me not what I want - here is what I am getting, note that empty <Employee/> record: 

<Employees><Employee><FirstName>Sam</FirstName></Employee><Employee/></Employees>
Somebody, please, how do I modify the XSLT to get rid of whole Employee record, not only its empty elements? Thank you very much!





Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>