variables inside itemsets

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

variables inside itemsets

Jeremiah Jahn-4
I have a situation where I get the label of an item in an itemset from a different instance. I do this all over the place w/ repeats, and keep the name() as a variable to use to do the look up in my xpath [id = $name] kinda thing. I can't seem to figure out a way to do this with an itemset in a select1.  Or is there a way to generate an set of items for use in a select1 using a repeat? 

I've included an example of what I'm trying to do, I know it won't work, but will give you an idea of what I'm trying to accomplish. Thanks for any help.

                       <xforms:itemset nodeset="instance('view')/template-view/query/*[1]/*">
    <xforms:variable name="currentItemName" select="name()"/>                           
                            <xforms:label ref="xxforms:attribute(name(),instance('types')/types/type[@typeID = $currentItemName]/label)"/>
                            <xforms:value ref="xxforms:attribute(name(),name())"/>
                        </xforms:itemset>




--
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: variables inside itemsets

Alessandro  Vernet
Administrator
Jeremiah,

First, those ref="xxforms:attribute(foo, bar)" look a bit fishy to me ;). Instead, what about using value="bar"?

Assuming you can, the difficulty seems to be with the expression:

instance('types')/types/type[@typeID = $currentItemName]/label

Supporting xxforms:variable inside a xforms:itemset would make sense, so I added an RFE for this: http://forge.ow2.org/tracker/index.php?func=detail&aid=314643&group_id=168&atid=350207. But in the meantime, you can rewrite the above expression as:

for $currentItemName in name() return instance('types')/types/type[@typeID = $currentItemName]/label

Also, relying on the name() function can be dangerous, as it returns the lexical form of a QName, that is: prefix:local-name. Different authors can choose different prefixes but map them to the same namespace URI, so in general it is better to rely on local-name() and namespace-uri().

Alex



On Jan 18, 2010, at 4:35 PM, Jeremiah Jahn <[hidden email]> wrote:

I have a situation where I get the label of an item in an itemset from a different instance. I do this all over the place w/ repeats, and keep the name() as a variable to use to do the look up in my xpath [id = $name] kinda thing. I can't seem to figure out a way to do this with an itemset in a select1.  Or is there a way to generate an set of items for use in a select1 using a repeat? 

I've included an example of what I'm trying to do, I know it won't work, but will give you an idea of what I'm trying to accomplish. Thanks for any help.

                       <xforms:itemset nodeset="instance('view')/template-view/query/*[1]/*">
    <xforms:variable name="currentItemName" select="name()"/>                           
                            <xforms:label ref="xxforms:attribute(name(),instance('types')/types/type[@typeID = $currentItemName]/label)"/>
                            <xforms:value ref="xxforms:attribute(name(),name())"/>
                        </xforms:itemset>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email]
For general help: [hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws


--
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
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Re: variables inside itemsets

Jeremiah Jahn-4
Awesome, thank you so much. worked like a dream.
I didn't realize you could use value="" there. Yeah! cleaner code. 


On Jan 19, 2010, at 10:01 PM, Alessandro Vernet wrote:

Jeremiah,

First, those ref="xxforms:attribute(foo, bar)" look a bit fishy to me ;). Instead, what about using value="bar"?

Assuming you can, the difficulty seems to be with the expression:

instance('types')/types/type[@typeID = $currentItemName]/label

Supporting xxforms:variable inside a xforms:itemset would make sense, so I added an RFE for this: http://forge.ow2.org/tracker/index.php?func=detail&aid=314643&group_id=168&atid=350207. But in the meantime, you can rewrite the above expression as:

for $currentItemName in name() return instance('types')/types/type[@typeID = $currentItemName]/label

Also, relying on the name() function can be dangerous, as it returns the lexical form of a QName, that is: prefix:local-name. Different authors can choose different prefixes but map them to the same namespace URI, so in general it is better to rely on local-name() and namespace-uri().

Alex



On Jan 18, 2010, at 4:35 PM, Jeremiah Jahn <[hidden email]> wrote:

I have a situation where I get the label of an item in an itemset from a different instance. I do this all over the place w/ repeats, and keep the name() as a variable to use to do the look up in my xpath [id = $name] kinda thing. I can't seem to figure out a way to do this with an itemset in a select1.  Or is there a way to generate an set of items for use in a select1 using a repeat? 

I've included an example of what I'm trying to do, I know it won't work, but will give you an idea of what I'm trying to accomplish. Thanks for any help.

                       <xforms:itemset nodeset="instance('view')/template-view/query/*[1]/*">
    <xforms:variable name="currentItemName" select="name()"/>                           
                            <xforms:label ref="xxforms:attribute(name(),instance('types')/types/type[@typeID = $currentItemName]/label)"/>
                            <xforms:value ref="xxforms:attribute(name(),name())"/>
                        </xforms:itemset>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: [hidden email][hidden email]
For general help: [hidden email][hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws

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



--
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