xsl-list
[Top] [All Lists]

[xsl] xsl:value-of issue

2010-09-07 11:30:42
I have a source XML file which has a number of elements whose name ends
with 'List'.  For each of these there will be another element whose name
ends with 'ListLocalVal'.  In the transform I am trying to do I need to
move the value from the LocalVal to the List element and not output the
LocalVal element.

I.e. 

Source:

<MilkList>A value</MilkList>
<MilkListLocalVal>Another value</ MilkListLocalVal>

Desired output:
<MilkList>Another value</MilkList>

The relevant bit of XSLT is:

<xsl:template name="process-list">
        <xsl:variable name="tempname" select="local-name()" />
        <xsl:choose>
                <xsl:when test="contains($tempname, 'ListLocalVal')">
                </xsl:when>
                <xsl:otherwise>
                        <xsl:element name="{$tempname}">
                        <xsl:variable
name="local-element-val"><xsl:value-of
select="$tempname"/><xsl:text>LocalVal</xsl:text><xsl:variable>
                        <xsl:value-of
select="../[local-name()=$local-element-val" />
                        </xsl:element>
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

What happens is I get the desired element created, i.e. <MilkList> but
it is empty.  I have experimented with various constructs in the
<xsl:value-of> but all raise processor errors (xalan) apart from the
above.

Can anyone tell me where I am going wrong with the value select?

Many thanks

Steve

Stephen Etheridge


Please help Logica to respect the environment by not printing this email  / 
Pour contribuer comme Logica au respect de l'environnement, merci de ne pas 
imprimer ce mail /  Bitte drucken Sie diese Nachricht nicht aus und helfen Sie 
so Logica dabei, die Umwelt zu schützen. /  Por favor ajude a Logica a 
respeitar o ambiente nao imprimindo este correio electronico.



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>