I'm using Saxon 9b
I have an XML file produced by a separate application. The structure was defined by someone besides me and I cannot change it.
I have a root node that has 0 or more 'payload-block' elements somewhere inside it. Each payload-block has an attribute ('@block) that takes on a value from 1 to 5. The child element is of type name-def-param and it also has an attribute (@name) that takes on a string name (letters, number)
What I want to do if find if there are any specific name-def-param elements with a specified @name value.
So.. I tried this:
Code:
<xsl:template match="name-def-param" mode="doNew">
<xsl:param name="inputMsg1"/>
<xsl:param name="block"/>
<xsl:variable name="name" select="upper-case(@name)"/>
<xsl:variable name="posi" select="@posi"/>
<xsl:if
test="empty($inputMsg1//payload-block[@block-id='$block']/name-def-param[upper-case(@name) = $name])">
<xsl:text>
</xsl:text>
<xsl:text>Named Block: </xsl:text>
<xsl:value-of select="$block"></xsl:value-of>
<xsl:text>
</xsl:text>
<xsl:text>New Attribute: </xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
If the target values is not in the source tree, then it's marked as a 'New' item.
The problem is I'm getting false hits. Even if the value is present in the target, this is still telling me it cannot find it.
Am I misunderstanding how empty() works?
I've also tried counting the instances with count($inputMsg1//payload-block[@block-id='$block']/name-def-param[upper-case(@name) = $name]) = 0 in the test. And it's no better.