Subject:"Select" - help Author:Richard Potts Date:19 May 2006 08:26 AM
Got a question why my select doesn't match one way but works another:
<xsl:value-of select="//PID[@id = ../@id and @service = ../@service and @type = ./PIDElementDataType]/PIDResolution"></xsl:value-of>
The above xsl doesn't match (and so doesn't output a value)
However if I define all the 'values' as variables and use these in the select statement I do get a match:
<!-- Value 1 -->
<xsl:variable name="pidDataType">
<xsl:value-of select="./PIDElementDataType"></xsl:value-of>
</xsl:variable>
<!-- Value 2 -->
<xsl:variable name="pidID">
<xsl:value-of select="../@id"></xsl:value-of>
</xsl:variable>
<!-- value 3 -->
<xsl:variable name="pidService">
<xsl:value-of select="../@service"></xsl:value-of>
</xsl:variable>
<xsl:value-of select="//PID[@id = $pidID and @service = $pidService and @type = $pidDataType ]/PIDResolution"></xsl:value-of>
To me, with the substitution, the two statements are identical... I must be missing something fundamental to xsl? Any ideas?
If I could write my code similar to the first statement my code would be a lot shorter.
Subject:No Topic Author:Ivan Pedruzzi Date:22 May 2006 11:12 AM
Hi Richard,
The expression return nothing. If you break it down it says
for any PID elements in the document
-- select those where
------ the attribute "pid" is equal to the attribute "pid" of its parent element
------- and the attribute "service" is equal the attribute service of its parent
------- ...
In the document posted there is no PID element that has parent element
with the attributes id and service.
If you explain what you are trying to select, we may be able to help.