xxforms:variable inside xPath declaration?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

xxforms:variable inside xPath declaration?

Karolin Heiss
Hello

Is it generally possible to use Orbeon xforms variables inside xPath? In my sample it's not working and I wonder if its possible at all to write ref declarations like:

<xforms:output ref="$test1/data/text[@language='$test2/language']"/>


Thank you for your help,

Karolin



<xforms:instance id="test1-instance">
  <root xmlns="">
    <data>
      <text language='de'>Hallo</text>
      <text language='en'>Hello</text>
      <text language='fr'>Allô</text>   
    </data>
  </root>
</xforms:instance>

<xforms:instance id="test2-instance">
  <root xmlns="">
    <language>en</language>
  </root>
</xforms:instance>

<xxforms:variable model="test1-model" name="test1" select="instance('test1-instance')" />
<xxforms:variable model="test2-model" name="test2" select="instance('test2-instance')" />


<xforms:output  ref="$test2/language"/>


<xforms:output ref="$test1/data/text[@language='de']"/>


<xforms:output ref="$test1/data/text[@language='$test2/language']"/>
Reply | Threaded
Open this post in threaded view
|

Re: xxforms:variable inside xPath declaration?

Hank Ratzesberger-2
Hi Karolin,

Do you mean the interpolation of $test2 ?  Then move it out
of the quotes:

[@language=concat($test2,'/language')]

or something similar may work.

Regards,
Hank

On Aug 30, 2010, at 4:40 AM, Karolin Krieg wrote:

>
> Hello
>
> Is it generally possible to use Orbeon xforms variables inside xPath? In my
> sample it's not working and I wonder if its possible at all to write ref
> declarations like:
>
> <xforms:output ref="$test1/data/text[@language='$test2/language']"/>
>
>
> Thank you for your help,
>
> Karolin
>
>
>
> <xforms:instance id="test1-instance">
>  <root xmlns="">
>    <data>
>      <text language='de'>Hallo</text>
>      <text language='en'>Hello</text>
>      <text language='fr'>Allô</text>    
>    </data>
>  </root>
> </xforms:instance>
>
> <xforms:instance id="test2-instance">
>  <root xmlns="">
>    <language>en</language>
>  </root>
> </xforms:instance>
>
> <xxforms:variable model="test1-model" name="test1"
> select="instance('test1-instance')" />
> <xxforms:variable model="test2-model" name="test2"
> select="instance('test2-instance')" />
>
> <!-- ok -->
> <xforms:output  ref="$test2/language"/>
>
> <!-- ok -->
> <xforms:output ref="$test1/data/text[@language='de']"/>
>
> <!-- NOT ok -->
> <xforms:output ref="$test1/data/text[@language='$test2/language']"/>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/xxforms-variable-inside-xPath-declaration-tp2399957p2399957.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
Hank Ratzesberger
NEES@UCSB
Earth Research Institute
University of California, Santa Barbara
805-893-8042








--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xxforms:variable inside xPath declaration?

Karolin Heiss
Hey Hank,

thank you for your answer.
In the end the ' ' was the problem. Using xxforms:variables you have to write it like this:

<xforms:output ref="$test1/data/text[@language=$test2/language]"/>


Cheers,
Karolin


PS:
concat($test2,'/language') won't work because $test2 is interpreted as String = "fr". So concat($test2,'/language') gives back "fr/language"

 <xforms:instance id="test1-instance">
  <root xmlns="">
    <data>
      <text language='de'>Hallo</text>
      <text language='en'>Hello</text>
      <text language='fr'>Allô</text>   
    </data>
  </root>
 </xforms:instance>