Subject: RE: Linking Variable to the Path
From: "Yaswanth Kumar Ravella" <yaswanth.mtrx@xxxxxxxxx>
Date: Wed, 22 Aug 2007 17:06:03 +0530
|
Hi Peter,
Thanks,
This will work fine for me only when I have @destination as
//every[..]/event[...]
As u guessed this will not be always same or say never same again !
I am working on implementing dyn:evaluate function !
http://www.xmleverywhere.com/tips/xslt.htm
but I am unable to work with it !
Any idea about how to use this function or any other technique that would be
best suited for this situation?
Regards
Yaswanth Ravella
-----Original Message-----
From: Hofman, Peter [mailto:peter.hofman@xxxxxxxxxxxxx]
Sent: Wednesday, August 22, 2007 2:28 PM
To: Yaswanth Kumar Ravella
Subject: RE: Linking Variable to the Path
Just not possible dynamically.
It seems you expect $dest to be substituted in the following xpath
expression. This is not happening.
The select you do in setting the variable $dest gives you a sequence of
attribute values.
There is no substitution when you use the variable.
Assuming the @destination always contains '//every[..]/event[...]'
(which will most probably not be the case) you need something like this
to get the name:
Keep the dest selection as you have and then do following (of course
only one solution, which is based on an assumption too):
<xsl:variable name="every"
select="substring-before(substring-after($dest,'/every['),']')"/>
<xsl:variable name="event"
select="substring-before(substring-after($dest,'/event['),']')"/>
<xsl:value-of select="//every[$every]/event[$event]/@name"/>
As you can see, you may need a lot of analyzing of the @destination when
my assumption is not correct.
Regards,
Peter
>-----Original Message-----
>From: Yaswanth Kumar Ravella [mailto:yaswanth.mtrx@xxxxxxxxx]
>Sent: woensdag 22 augustus 2007 10:36
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Cc: Hofman, Peter
>Subject: RE: Linking Variable to the Path
>
>Hi Peter and Everyone out there!
> Thanks for the reply ~
>
>I have '//every[1]/event[1]' as the destination attributes value.
>And there is 'name' attribute for '//every[1]/event[1]'
>i.e //every[1]/event[1]/@name gives me the Value 'Ready'.
>
>Why not $dest/@name gives me the same ?
>How to get it ?
>
>Regards
>Yaswanth
>
>
Hi Yaswanth,
> Hi Peter and Everyone out there!
> Thanks for the reply ~
>
> I have '//every[1]/event[1]' as the destination attributes value.
> And there is 'name' attribute for '//every[1]/event[1]'
> i.e //every[1]/event[1]/@name gives me the Value 'Ready'.
>
> Why not $dest/@name gives me the same ?
> How to get it ?
In your fisrt xsl <xsl:variable name="dest"
select="//every[1]/event[1]"/> will get a *node* /root/every[1]/event[1],
which do has a @name attribute. Then $dest/@name will get this attribute
value.
But in your second xsl <xsl:variable name="dest"
select="//pattern[1]/connection[1]/@destination"/> will get the *string*
"//every[1]/event[1]"
which is the value of @destination. $dest is not a node, it's a string and
you can't do $dest/@name, it doesn't make sens.
As said Christoph you need to evaluate the string, and there is
unfortunately no xslt 1.0 native way to do this !
You need a extension eval function depending on your xslt processor.
If you use saxon for example, something like this should go <xsl:value-of
select="saxon:eval($dest)/@name"/>.
With msxml you can do your own eval function in jscript, have a look at
http://www.xmleverywhere.com/tips/xslt.htm
You can also use EXSLT extensions I think.
Hope this help,
Cheers,
Matthieu.
>-----Original Message-----
>From: Hofman, Peter [mailto:peter.hofman@xxxxxxxxxxxxx]
>Sent: Wednesday, August 22, 2007 1:54 PM
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: RE: Linking Variable to the Path
>
>Your variable $dest contains a sequence of destination
>attributes values, which (of course) do not contain a name attribute.
>
>You need to analyze the contents of connection/@destination
>and use this in a selection of event elements.
>
>Regards,
>Peter
>
>>-----Original Message-----
>>From: Yaswanth Kumar Ravella [mailto:yaswanth.mtrx@xxxxxxxxx]
>>Sent: woensdag 22 augustus 2007 10:16
>>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>>Subject: Linking Variable to the Path
>>
>>
>>Hi,
>>
>>::I am having an XML file like this ::
>>
>><root>
>> <every>
>> <event name="Ready"/>
>> </every>
>> <pattern>
>> <connection destination="//every[1]/event[1]" />
>> </pattern>
>></root>
>>-------------------------------
>>::When my XSL file has this code::
>>
>><xsl:template match="root">
>> <xsl:variable name="dest" select="//every[1]/event[1]"/>
>> <xsl:value-of select="$dest/@name"/>
>></xsl:template>
>>
>>It prints 'Ready'.
>>Here I am directly assigning variable 'dest' to the path of the event.
>>This is ok.
>>-------------------------------
>>::When I changed my XSL code to ::
>>
>><xsl:template match="root">
>> <xsl:variable name="dest"
>>select="//pattern[1]/connection[1]/@destination"/>
>> <xsl:value-of select="$dest/@name"/>
>></xsl:template>
>>
>>It doesn't print 'Ready' or anything.
>>Here I am storing variable 'dest' with the value of the
>>'connection/@destination', Which I expected to work properly
>>but it is not working.
>>------------------------------
>>
>>How can I print 'event-name' using 'connection-destination'?
>>
>>
>>Regards
>>Yaswanth Ravella
>>
>>
>
>
>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.
| Current Thread |
|
Yaswanth Kumar Ravella - 22 Aug 2007 11:36:49 -0000 <=
|
|