Reputation: 26159
I'm trying to get the Social Security of a parent.I tried this code but it returns empty, but I know the value is not empty.
<xsl:call-template name="render-Employee">
<xsl:with-param name="ssno" select="normalize-space(SocialSecurityNumber)"></xsl:with-param>
<xsl:with-param name="firstName" select="normalize-space(FirstName)"></xsl:with-param>
<xsl:with-param name="middleName" select="normalize-space(MiddleName)"></xsl:with-param>
<xsl:with-param name="lastName" select="normalize-space(LastName)"></xsl:with-param>
<xsl:with-param name="creationDate" select="ChangeDate"></xsl:with-param>
</xsl:call-template>
<xsl:for-each select="Dependents">
<xsl:for-each select="Dependent">
<xsl:call-template name="render-Dependent">
<xsl:with-param name="recordType" select="'BN'" />
<xsl:with-param name="employeeSsno" select="normalize-space(ancestor::Employee[1]/@SocialSecurityNumber)"/>
sample xml
<Employee>
<EntityKey>
<EntitySetName>Employees</EntitySetName>
<EntityContainerName>...</EntityContainerName>
<EntityKeyValues>
<EntityKeyMember>
<Key>EmployeeId</Key>
<Value xsi:type="xsd:int">873</Value>
</EntityKeyMember>
<EntityKeyMember>
<Key>CompanyId</Key>
<Value xsi:type="xsd:int">33</Value>
</EntityKeyMember>
</EntityKeyValues>
</EntityKey>
<Dependents>
<Dependent>
<EntityKey>
....
</EntityKeyValues>
</EntityKey>
...
<SocialSecurityNumber>123456789</SocialSecurityNumber>
...
</Dependent>
</Dependents>
<EmployeeId>873</EmployeeId>
...
<SocialSecurityNumber>000000000</SocialSecurityNumber>
...
</Employee>
Upvotes: 1
Views: 2908
Reputation: 107357
As it stands, the Employees SSN is an element, not an attribute, so you need to change the xpath to
select="normalize-space(ancestor::Employee[1]/SocialSecurityNumber/text())"
Upvotes: 2
Reputation: 122414
Your XPath expression says
ancestor::Employee[1]/@SocialSecurityNumber
but in your example XML SocialSecurityNumber
is an element, not an attribute.
Upvotes: 3