I am developing an XSLT for adding value to some of my nodes which are empty. It works if the nodes are within a single or two parents e.g.
<?xml version="1.0" encoding="UTF-8"?>
<VehicleDataCustom>
<VehicleDataCustomHeader>
<Commessa>SSP100</Commessa>
<RecordType />
<AttivitaAnnullamento />
</VehicleDataCustomHeader>
</VehicleDataCustom>
Here is my XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="AttivitaAnnullamento[not(node())]">
<xsl:copy>yes</xsl:copy>
</xsl:template>
</xsl:stylesheet>
It cleanely puts a yes in my resulting XML as follows -
<?xml version="1.0" encoding="UTF-8"?><VehicleDataCustom>
<VehicleDataCustomHeader>
<Commessa>SSP100</Commessa>
<RecordType/>
<AttivitaAnnullamento>yes</AttivitaAnnullamento>
</VehicleDataCustomHeader>
</VehicleDataCustom>
But if my XML has the following structure, it does nothing -
<?xml version="1.0" encoding="UTF-8"?>
<ProcessVehicleDataCustom xmlns="http://schema.test.com/Testing/2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.test.com/2.2.0/Testing http://schema.test.com/2.2.0/Testing/BODs/Developer/ProcessVehicleDataCustom.xsd" releaseID="2">
<VehicleDataCustom>
<VehicleDataCustomHeader>
<Commessa>SSP100</Commessa>
<RecordType />
<AttivitaAnnullamento />
</VehicleDataCustomHeader>
</VehicleDataCustom>
</ProcessVehicleDataCustom>
Not sure what's wrong with this format. Is there any way to handle this tag? Am I missing something?