Concatenating instance data

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

Concatenating instance data

Stephanie Hall (TT)

Hi,

 

I have an instance that looks like the following:

<instance id=”instance”>

<project>

                <category>sales</category>

<name>myProduct</name>

</project>

</instance>

 

And we want to use this instance,  set in an earlier repeat on the page,  to populate a select for a later section which would be easy except we want it to all appear on the same line. 

               

So we want it to look like “sales/myProduct” in the dropdown option.

 

<xforms:select1 ref="fullString">

            <xforms:itemset nodeset="instance(‘instance')/project">

                  <xforms:label ref="????"/>

                  <xforms:value ref="???"/>

            </xforms:itemset>

      </xforms:select1>

 

What do I need to do in the ??? sections to make that happen? 

 

Thanks!

Stephanie



--
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: Concatenating instance data

Alessandro  Vernet
Administrator
Stephanie,


On Thu, Nov 12, 2009 at 2:33 PM, Stephanie Hall (TT)
<[hidden email]> wrote:

> I have an instance that looks like the following:
>
> <instance id=”instance”>
>
> <project>
>
>                 <category>sales</category>
>
> <name>myProduct</name>
>
> </project>
>
> </instance>
>
>
>
> And we want to use this instance,  set in an earlier repeat on the page,  to
> populate a select for a later section which would be easy except we want it
> to all appear on the same line.
>
>
>
> So we want it to look like “sales/myProduct” in the dropdown option.
>
>
>
> <xforms:select1 ref="fullString">
>
>             <xforms:itemset nodeset="instance(‘instance')/project">
>
>                   <xforms:label ref="????"/>
>
>                   <xforms:value ref="???"/>
>
>             </xforms:itemset>
>
>       </xforms:select1>
>
>
>
> What do I need to do in the ??? sections to make that happen?
I am not sure to understand the question: I assume you expect to have
multiple projects, so you'll need a container, such as:

<instance id=”instance”>
    <projects>
        <project>
            <category>development</category>
            <name>myProduct</name>
        </project>
        <project>
            <category>sales</category>
            <name>myProduct</name>
        </project>
    </projects>
</instance>

Then the select1 would look like:

<xforms:select1 ref="fullString">
    <xforms:itemset nodeset="instance(‘instance')/projects/project">
        <xforms:label ref="name"/>
        <xforms:value ref="name"/>
    </xforms:itemset>
</xforms:select1>

I am not sure what the ref on the label and value should point to. It
depends what you want to show the user (label) vs. what you want to
store in the instance when the user selects that item (value).

Alex
--
Orbeon Forms - Web forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
My Twitter: http://twitter.com/avernet


--
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: Concatenating instance data

Stephanie Hall (TT)
Hi Alex,

<snip>
> >And we want to use this instance,  set in an earlier repeat on the
> >page,  to populate a select for a later section which would be easy
> >except we want it to all appear on the same line.
>>
>>
>>
> >So we want it to look like "sales/myProduct" in the dropdown option.
>
>I am not sure to understand the question: I assume you expect to have
multiple projects, so you'll need a container, such as:

>
><instance id="instance">
>    <projects>
>        <project>
>            <category>development</category>
>            <name>myProduct</name>
>        </project>
>        <project>
>            <category>sales</category>
>            <name>myProduct</name>
>        </project>
>    </projects>
></instance>
>
>Then the select1 would look like:
>
><xforms:select1 ref="fullString">
>    <xforms:itemset nodeset="instance('instance')/projects/project">
>        <xforms:label ref="name"/>
>        <xforms:value ref="name"/>
>    </xforms:itemset>
></xforms:select1>

>I am not sure what the ref on the label and value should point to. It
depends what you want to show the user (label) vs. what you want to
>store in the instance when the user selects that item (value).

Yes, that is mostly correct and that's what I have so far (just
displaying the name or category), but my issue was that I want to
display the name AND category in the one dropdown list, concatenating
them with a "/" between, as I mentioned.  So using your example
instance, I want to have 2 options in my select, one with
"development/myProduct" and the other with "sales/myProduct" (the
products are different though).

Also, the label and value will match.

Thanks,
Stephanie


--
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: RE: Re: Concatenating instance data

Markku Laine

On 13.11.2009, at 16.38, Stephanie Hall (TT) wrote:

> Hi Alex,
>
> <snip>
>>> And we want to use this instance,  set in an earlier repeat on the
>>> page,  to populate a select for a later section which would be easy
>>> except we want it to all appear on the same line.
>>>
>>>
>>>
>>> So we want it to look like "sales/myProduct" in the dropdown option.
>>
>> I am not sure to understand the question: I assume you expect to have
> multiple projects, so you'll need a container, such as:
>>
>> <instance id="instance">
>>   <projects>
>>       <project>
>>           <category>development</category>
>>           <name>myProduct</name>
>>       </project>
>>       <project>
>>           <category>sales</category>
>>           <name>myProduct</name>
>>       </project>
>>   </projects>
>> </instance>
>>
>> Then the select1 would look like:
>>
>> <xforms:select1 ref="fullString">
>>   <xforms:itemset nodeset="instance('instance')/projects/project">
>>       <xforms:label ref="name"/>
>>       <xforms:value ref="name"/>
>>   </xforms:itemset>
>> </xforms:select1>
>
>> I am not sure what the ref on the label and value should point to. It
> depends what you want to show the user (label) vs. what you want to
>> store in the instance when the user selects that item (value).
>
> Yes, that is mostly correct and that's what I have so far (just
> displaying the name or category), but my issue was that I want to
> display the name AND category in the one dropdown list, concatenating
> them with a "/" between, as I mentioned.  So using your example
> instance, I want to have 2 options in my select, one with
> "development/myProduct" and the other with "sales/myProduct" (the
> products are different though).
>
> Also, the label and value will match.
You can use the concat() function: http://www.w3schools.com/Xpath/xpath_functions.asp#string

For example (haven't tested => might contains errors):
<xforms:instance id="project-instance">
   <project xmlns="" />
</xforms:instance>
...
<xforms:instance id="project-itemset-instance">
   <projects xmlns="">
       <project>
           <category>development</category>
           <name>myProduct</name>
       </project>
       <project>
           <category>sales</category>
           <name>myProduct</name>
       </project>
   </projects>
</xforms:instance>
...
<xforms:select1 ref="instance( 'project-instance' )">
   <xforms:itemset nodeset="instance( 'project-itemset-instance' )/
project">
       <xforms:label value="concat( category, '/', name )" />
       <xforms:value value="concat( category, '/', name )" />
   </xforms:itemset>
</xforms:select1>

Regards


-Markku


--
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: Re: RE: Re: Concatenating instance data

Stephanie Hall (TT)
That works great! Thanks, Markku!  I thought I had read that concat() only took 2 arguments, so that was the cause of my problem.  

-----Original Message-----
From: Markku Laine [mailto:[hidden email]]
Sent: Friday, November 13, 2009 9:52 AM
To: [hidden email]
Subject: [ops-users] Re: RE: Re: Concatenating instance data


On 13.11.2009, at 16.38, Stephanie Hall (TT) wrote:

> Hi Alex,
>
> <snip>
>>> And we want to use this instance,  set in an earlier repeat on the
>>> page,  to populate a select for a later section which would be easy
>>> except we want it to all appear on the same line.
>>>
>>>
>>>
>>> So we want it to look like "sales/myProduct" in the dropdown option.
>>
>> I am not sure to understand the question: I assume you expect to have
> multiple projects, so you'll need a container, such as:
>>
>> <instance id="instance">
>>   <projects>
>>       <project>
>>           <category>development</category>
>>           <name>myProduct</name>
>>       </project>
>>       <project>
>>           <category>sales</category>
>>           <name>myProduct</name>
>>       </project>
>>   </projects>
>> </instance>
>>
>> Then the select1 would look like:
>>
>> <xforms:select1 ref="fullString">
>>   <xforms:itemset nodeset="instance('instance')/projects/project">
>>       <xforms:label ref="name"/>
>>       <xforms:value ref="name"/>
>>   </xforms:itemset>
>> </xforms:select1>
>
>> I am not sure what the ref on the label and value should point to. It
> depends what you want to show the user (label) vs. what you want to
>> store in the instance when the user selects that item (value).
>
> Yes, that is mostly correct and that's what I have so far (just
> displaying the name or category), but my issue was that I want to
> display the name AND category in the one dropdown list, concatenating
> them with a "/" between, as I mentioned.  So using your example
> instance, I want to have 2 options in my select, one with
> "development/myProduct" and the other with "sales/myProduct" (the
> products are different though).
>
> Also, the label and value will match.
You can use the concat() function: http://www.w3schools.com/Xpath/xpath_functions.asp#string

For example (haven't tested => might contains errors):
<xforms:instance id="project-instance">
   <project xmlns="" />
</xforms:instance>
...
<xforms:instance id="project-itemset-instance">
   <projects xmlns="">
       <project>
           <category>development</category>
           <name>myProduct</name>
       </project>
       <project>
           <category>sales</category>
           <name>myProduct</name>
       </project>
   </projects>
</xforms:instance>
...
<xforms:select1 ref="instance( 'project-instance' )">
   <xforms:itemset nodeset="instance( 'project-itemset-instance' )/ project">
       <xforms:label value="concat( category, '/', name )" />
       <xforms:value value="concat( category, '/', name )" />
   </xforms:itemset>
</xforms:select1>

Regards


-Markku


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