Make Parents null if child is null

Here should go questions about transforming XML with XSLT and FOP.
buttagash
Posts: 1
Joined: Thu Jan 27, 2011 1:31 pm

Make Parents null if child is null

Post 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
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Make Parents null if child is null

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply