xslt - XSL:if statement is not identifying required items in xml data -
i'm novice @ xsl, please forgive ignorance. i'm trying construct table pulls out elements resource pool - tagged "teammember". think have problem either xsl:if syntax, or way i'm referencing xml data.
the xsl code -
<xsl:for-each select="miradi:resource/miradi:resourcerolecodescontainer/.."> <xsl:if test="miradi:resource/miradi:resourcerolecodescontainer/miradi:code = teammember"> <xsl:value-of select="miradi:resourcesurname"/>
the xml data -
<miradi:resourcepool><miradi:resource id="2530"> <miradi:resourceresourcetype>person</miradi:resourceresourcetype> <miradi:resourceidentifier>da</miradi:resourceidentifier> <miradi:resourcesurname>andrews</miradi:resourcesurname> <miradi:resourceposition>manager</miradi:resourceposition> <miradi:resourcerolecodescontainer><miradi:code>teammember</miradi:code </miradi:resourcerolecodescontainer> </miradi:resource>
when remove xsl:if statement code correctly builds table showing row each resource; want show row each resource tagged "teammember". when include xsl:if statement don't rows in table.
any appreciated. thanks
there several issues code:
first, after doing:
<xsl:for-each select="miradi:resource/miradi:resourcerolecodescontainer/..">
you (probably) in context of miradi:resource
. "probably", because not show starting context. makes little sense go down miradi:resourcerolecodescontainer
, parent miradi:resource
, that's issue.
from context, expression use in xsl:if
test:
miradi:resource/miradi:resourcerolecodescontainer/miradi:code
selects nothing, because miradi:resource
not child of context node.
the other issue condition tests against non-existing node, instead of literal string. test should be:
<xsl:if test="miradi:resourcerolecodescontainer/miradi:code = 'teammember'">
or do:
<xsl:for-each select="miradi:resource[miradi:resourcerolecodescontainer/miradi:code = 'teammember']"> <xsl:value-of select="miradi:resourcesurname"/> </xsl:for-each>
Comments
Post a Comment