tags:

views:

47

answers:

3

I have an XML file that looks like this:

..
<PersonalInfo>
<LastName>Smith</LastName>
...
</PersonalInfo>
<DependentInfo>
<LastName>Johnson</LastName>
...
</DependentInfo>
...

and I need to convert the last name of the dependent to upper case.

I wrote this XSLT

<xsl:value-of select="translate(//LastName, $smallcase, $uppercase)" /> 

It converts last name of the dependent to the last name of the personal info in upper case. So it converts it to SMITH and I want it to be converted to JOHNSON. Could someone tell me how I can do this? Thanks you very much.

+1  A: 

It's hard to tell for certain based on the XML example and the small XSL snippet, but it sounds like the context where you use the xsl:value-of is DependentInfo. By using //LastName in the translate() function, you're telling the processor to select any LastName in the XML. (In this case it appears to be selecting the first occurrence of LastName in PersonalInfo.)

Try removing the // from your xsl:value-of:

<xsl:value-of select="translate(LastName, $smallcase, $uppercase)" />

If this doesn't work, try posting more of your XSL for us to look at.

DevNull
A: 

<xsl:value-of select="translate(DependentInfo/LastName, $smallcase, $uppercase)" />

Treemonkey
A: 

Use:

translate(/*/DependentInfo/LastName, $smallcase, $uppercase)
Dimitre Novatchev