Page 1 of 1

Make Parents null if child is null

Posted: Thu Jan 27, 2011 1:38 pm
by buttagash
I have XML data where parent nodes exist in every record but child nodes do not.

Using XSL, is there anyway to create an if statement where if the child does not have a node (and any subsequent data), then do not create a parent node?

Really appreciate any code that can be posted.

Thanks

Re: Make Parents null if child is null

Posted: Fri Jan 28, 2011 1:38 pm
by adrian
Hello,

Could you give a small example of the XML file you have?

In theory you could test if the child exists with an XPath:
e.g. In the context of the parent

Code: Select all

<xsl:template match="parent">
...
<xsl:if test="child">
[create element]
</xsl:if>
...
</xsl:template>
Regards,
Adrian