I know that questions similar to this have been asked but I can't work out what is wrong with my test.
Here are 3 variations of how my XML could be like;
I am trying to work out the presence of a value for <apsite:address>
, an empty string or a missing element.
<apsite:apsite xmlns="http://www.w3.org/1999/xhtml" >
<apsite:name>John</apsite:name>
<apsite:address>Some Address</apsite:name>
</apsite:apsite>
<apsite:apsite xmlns="http://www.w3.org/1999/xhtml" >
<apsite:name>John</apsite:name>
<apsite:address></apsite:name>
</apsite:apsite>
<apsite:apsite xmlns="http://www.w3.org/1999/xhtml" >
<apsite:name>John</apsite:name>
</apsite:apsite>
I need to find the instances where the value of is an empty string or null. These are my if conditions.
<xsl:if
test="../apsite:address = ''">
<dc:source>
<xsl:value-of select="." />
</dc:source>
</xsl:if>
<xsl:if
test="not(apsite:apsite/apsite:address)">
<dc:source>
<xsl:value-of select="." />
</dc:source>
</xsl:if>
<xsl:if
test="../apsite:adress != ''">
<dc:source>
<xsl:value-of select="../apsite:oldAddress" />
</dc:source>
</xsl:if>
My test for the empty string works but not for the missing element i.e test="not(apsite:apsite/apsite:address)"> is not working.
Could someone please advise what I am missing ?
Thanks.