View Single Post
 
Old October 17th, 2013, 02:52 AM
SRTrice SRTrice is offline
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use an attributes value in a conditional statement in XPATH

I've been struggling with building this code for about 6 hours now and each forum I consult do not seem to have a viable solution. Hoping to get some help here.

I have an XML that references attributes of idOwner. I want to use the value of one of the attributes in a conditional statement in an XSLT.

Here is a snippet of the XML:
Code:
<Id idOwner="Onboarding_Event"> 
     <IdValue>US Onboarding</IdValue> 
</Id>
Code:
<xsl:choose>
<xsl:when test="@idOwner = 'Onboarding_Event' and hr:IdValue/text() = 'US Onboarding'">
<xsl:if test="@idOwner = 'Managers_Email_ID' and hr:IdValue !=''"> 
	<Person>
	  <Name>Manager</Name>
		  <Value><xsl:value-of select="hr:IdValue"/></Value>
            </Person>
</xsl:if>

<xsl:if test="@idOwner = 'Onboarding_Co' and hr:IdValue !=''"> 
	<Person>
	  <Name>Onboarding Coordinator</Name>
		<Value><xsl:value-of select="hr:IdValue"/></Value>
            </Person>
</xsl:if>
<xsl:if test="@idOwner = 'HR_Rep_email_ID' and hr:IdValue !=''">
	<Person>
	  <Name>HR Representative</Name>
   	             <Value><xsl:value-of select="hr:IdValue"/></Value>
	</Person>
</xsl:if>
</xsl:when>

<xsl:otherwise>											
  <xsl:if test="@idOwner = 'Managers_Email_ID' and hr:IdValue !=''"> 
        <Person>
	  <Name>EMEA Manager</Name>
	  <Value>Test</Value>
        </Person>
  </xsl:if>

   <xsl:if test="@idOwner = 'Onboarding_Co' and hr:IdValue !=''"> 
	<Person>
		<Name>EMEA Onboarding Coordinator</Name>
		<Value>Test</Value>
	</Person>
    </xsl:if>

	<xsl:if test="@idOwner = 'HR_Rep_email_ID' and hr:IdValue !=''">
		<Person>
		  <Name>EMEA HR Representative</Name>
			<Value>Test</Value>
		</Person>
			</xsl:if>
	</xsl:otherwise>
				
</xsl:choose>
No matter how I build the When statement it always defaults to the <Otherwise> statement. Its as if the When statement is never evaluated.

any help would be greatly appreciated.

Last edited by SRTrice; October 17th, 2013 at 03:00 AM..