Dynamically Choose instance

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

Dynamically Choose instance

Josh Joy
Hi All,

Does anyone know how in XForms to dynamically choose
an instance with a
model?

For instance, the bind id="versionChosen" has the
version chose, either
'version1' or 'version2'.

That much works. I can output depending on the option
chosen.

        <form:model>
            <form:instance id="apps"
src="application.xml">
            </form:instance>

            <form:instance id="version1"
src="version1.xml">
            </form:instance>

            <form:instance id="version2"
src="version2.xml">
            </form:instance>

            <form:bind id="versionChosen"
nodeset="instance('apps')//selectedValues/versionSelected"
/>
        </form:model>

I want to be able to do something like this
            <form:group
ref="instance('versionChosen')">
                Version Chosen: <form:output
value="//testvalue" />
            </form:group>

Basically choose a version using the binding
"versionChosen" which will
be dynamically set.

Thanks,
Josh



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Dynamically Choose instance

Ryan Puddephatt
How is the user going to choose that? If they are selecting it on a page,
use an input or select. If it is only entered once, then you could use XSLT
at the start

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Josh Joy [mailto:[hidden email]]
>Sent: 23 March 2006 13:33
>To: [hidden email]
>Subject: [ops-users] Dynamically Choose instance
>
>Hi All,
>
>Does anyone know how in XForms to dynamically choose
>an instance with a
>model?
>
>For instance, the bind id="versionChosen" has the
>version chose, either
>'version1' or 'version2'.
>
>That much works. I can output depending on the option
>chosen.
>
>        <form:model>
>            <form:instance id="apps"
>src="application.xml">
>            </form:instance>
>
>            <form:instance id="version1"
>src="version1.xml">
>            </form:instance>
>
>            <form:instance id="version2"
>src="version2.xml">
>            </form:instance>
>
>            <form:bind id="versionChosen"
>nodeset="instance('apps')//selectedValues/versionSelected"
>/>
>        </form:model>
>
>I want to be able to do something like this
>            <form:group
>ref="instance('versionChosen')">
>                Version Chosen: <form:output
>value="//testvalue" />
>            </form:group>
>
>Basically choose a version using the binding
>"versionChosen" which will
>be dynamically set.
>
>Thanks,
>Josh




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Dynamically Choose instance

Josh Joy
It's chosen by the user. The different values are in the xml. Based on their choice, I want to load a different xml file.
 
*Flow*
 
1 xml file containing values -> based off value chosen, load the corresponding xml file and pull data from this xml file
 
Using the instance function one can dynamically load an xml file, however the file loaded has to be hardcoded which really isn't dynamic. I want the xml file that is used to be dynamically chosen by the user.

Ryan Puddephatt <[hidden email]> wrote:
How is the user going to choose that? If they are selecting it on a page,
use an input or select. If it is only entered once, then you could use XSLT
at the start

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP

* [hidden email]
( 01506 407 110
7 01506 407 108


>-----Original Message-----
>From: Josh Joy [mailto:[hidden email]]
>Sent: 23 March 2006 13:33
>To: [hidden email]
>Subject: [ops-users] Dynamically Choose instance
>
>Hi All,
>
>Does anyone know how in XForms to dynamically choose
>an instance with a
>model?
>
>For instance, the bind id="versionChosen" has the
>version chose, either
>'version1' or 'version2'.
>
>That much works. I can output depending on the option
>chosen.
>
>
> >src="application.xml">
>

>
> >src="version1.xml">
>

>
> >src="version2.xml">
>

>
> >nodeset="instance('apps')//selectedValues/versionSelected"
>/>
>

>
>I want to be able to do something like this
> >ref="instance('versionChosen')">
> Version Chosen: >value="//testvalue" />
>
>
>Basically choose a version using the binding
>"versionChosen" which will
>be dynamically set.
>
>Thanks,
>Josh




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Dynamically Choose instance

Ryan Puddephatt

So your saying you have two buttons on the page lets say one for each version, once this is click it will load the XML and update that same page. Or will it go to an different page?

 

Ryan Puddephatt

Software Engineer

TFX Group - IT UK

1 Michaelson Square

Livingston

West Lothian

Scotand

EH54 7DP

 

* [hidden email]

( 01506 407 110

7  01506 407 108

 


From: Josh Joy [mailto:[hidden email]]
Sent: 23 March 2006 16:56
To: [hidden email]
Subject: RE: [ops-users] Dynamically Choose instance

 

It's chosen by the user. The different values are in the xml. Based on their choice, I want to load a different xml file.

 

*Flow*

 

1 xml file containing values -> based off value chosen, load the corresponding xml file and pull data from this xml file

 

Using the instance function one can dynamically load an xml file, however the file loaded has to be hardcoded which really isn't dynamic. I want the xml file that is used to be dynamically chosen by the user.

Ryan Puddephatt <[hidden email]> wrote:

How is the user going to choose that? If they are selecting it on a page,
use an input or select. If it is only entered once, then you could use XSLT
at the start

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Micha! elson Square
Livingston
West Lothian
Scotand
EH54 7DP

* [hidden email]
( 01506 407 110
7 01506 407 108


>-----Original Message-----
>From: Josh Joy [mailto:[hidden email]]
>Sent: 23 March 2006 13:33
>To: [hidden email]
>Subject: [ops-users] Dynamically Choose instance
>
>Hi All,
>
>Does anyone know how in XForms to dynamically choose
>an instance with a
>model?
>
>For instance, the bind id="versionChosen" has the
>version chose, either
>'version1' or 'version2'.
>
>That much works. I can output depending on the option
>chosen.
>
>
>
>src="application.xml">
>
>
>
>src="version1.xml">
>
>
>
>src="version2.xml">
>
>
>
>nodeset="instance('apps')//selectedValues/versionSelected"
>/>
>
>
>I want to be able to do something like this
> <form:group
>ref="instance('versionChosen')">
> Version Chosen: <form:output
>value="//testvalue" />
> </form:group

>
>Basically choose a version using the binding
>"versionChosen" which will
>be dynamically set.
>
>Thanks,
>Josh




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws


</form:output



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Dynamically Choose instance

Josh Joy
I left my code at home, otherwise I would send it.....
 
I have a select1 tag that reads an external xml file instance. In the xml file there are several version tags
 
data.xml
 
<data>
 <version>1</version>
 <version>2</version>
 <version>3</version>
 <selectedVersion/>
</data>
 
The user can pick 1,2,3.
 
I have 3 other xml files, which are the same XML structure, though different data.
 
version1.xml
<data>
  <method>a</method>
 <method>b</method>
</data>
 
version2.xml
<data>
 <method>ZZZ</method>
 <method>AAA</method>
</data>
 
version3.xml
 
<data>
 <method>123</method>
 <method>321</method>
</data>
 
A itemset XForm tag is used to load the version.xml file. Dependinig on whether the user chose 1,2,3 I use the corresponding xml file and present another select1 box using the xpath //method
 
So, there can be an unlimited amount of versions as the software grows with different method data, however it should be the same structure. I want to re use the business logic that goes on and will resuse the xpath as well, the user is just responsible for choosing the version and the corresponding method. Each version can have different methods. I was thinking the best way would be to dynamically load the xml file using the instance() XForm function. However, I'm not sure how to send a variableto the instance function. The variable I want to send is the user selected version, in this case
//selectedVersion XPath query run on data.xml
 
Thanks,
Josh
 
 


Ryan Puddephatt <[hidden email]> wrote:
So your saying you have two buttons on the page lets say one for each version, once this is click it will load the XML and update that same page. Or will it go to an different page?
 
Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
( 01506 407 110
7  01506 407 108
 

From: Josh Joy [mailto:[hidden email]]
Sent: 23 March 2006 16:56
To: [hidden email]
Subject: RE: [ops-users] Dynamically Choose instance
 
It's chosen by the user. The different values are in the xml. Based on their choice, I want to load a different xml file.
 
*Flow*
 
1 xml file containing values -> based off value chosen, load the corresponding xml file and pull data from this xml file
 
Using the instance function one can dynamically load an xml file, however the file loaded has to be hardcoded which really isn't dynamic. I want the xml file that is used to be dynamically chosen by the user.

Ryan Puddephatt <[hidden email]> wrote:
How is the user going to choose that? If they are selecting it on a page,
use an input or select. If it is only entered once, then you could use XSLT
at the start

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Micha! elson Square
Livingston
West Lothian
Scotand
EH54 7DP

* [hidden email]
( 01506 407 110
7 01506 407 108


>-----Original Message-----
>From: Josh Joy [mailto:[hidden email]]
>Sent: 23 March 2006 13:33
>To: [hidden email]
>Subject: [ops-users] Dynamically Choose instance
>
>Hi All,
>
>Does anyone know how in XForms to dynamically choose
>an instance with a
>model?
>
>For instance, the bind id="versionChosen" has the
>version chose, either
>'version1' or 'version2'.
>
>That much works. I can output depending on the option
>chosen.
>
>
>
>src="application.xml">
>
>
>
>src="version1.xml">
>
>
>
>src="version2.xml">
>
>
>
>nodeset="instance('apps')//selectedValues/versionSelected"
>/>
>
>
>I want to be able to do something like this
> <form:group
>ref="instance('versionChosen')">
> Version Chosen: <form:output
>value="//testvalue" />
> </form:group

>
>Basically choose a version using the binding
>"versionChosen" which will
>be dynamically set.
>
>Thanks,
>Josh




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

</form:output

--
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
ObjectWeb mailing lists service home page: http://www.objectweb.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Dynamically Choose instance

Ryan Puddephatt

Ok, well the use select a version, lets say its held in an instance called ‘main’ and you want your XML file to be loaded in to an instance called ‘version’

 

You need a button to start

 

<xforms:submit submission=”getVersion”>

   <xforms:label>Submit</xforms:label>

</xforms:submit>

 

You then need to create this getVersion submission like so

 

<xforms:submission id=”getVersion” ref=”instance(‘main’)”

   Method=”post” action=”/page/flow/path/to/xpl”

   Replace=”instance” instance=”version”/>

 

Ok the this send the instance ‘main’ for the submission and the data coming back will be put into the version submission! The action need to be put into the page-flow and must be an xpl file.

 

Ok the XPL file should be like the below, but I’m assuming that from your root (resources directory) you have all your version.xml files in an xml folder and they are all named version1.xml version2.xml etc.

 

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"

    xmlns:oxf="http://www.orbeon.com/oxf/processors"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 

   <p:param name=”instance” type=”input”/>

   <p:param name=”data” type=”data”/>

 

   <p:processor name=”oxf:xslt-2.0”>

      <p:input name=”data” href=”#instance”/>

      <p:input name=”config”>

         <xsl:stylesheet version=”2.0”>

            <xsl:template match=”/”>

               <xsl:copy-of select=”doc(concat(‘/xml/version’,/instance/selectedVersion,’.xml’)”/>

            </xsl:template>

         </xsl:stylesheet>

      </p:input>

      <p:output name=”data” ref=”data”/>

   </p:processor>

</p:config>

 

That should do it!     

 

Ryan Puddephatt

Software Engineer

TFX Group - IT UK

1 Michaelson Square

Livingston

West Lothian

Scotand

EH54 7DP

 

* [hidden email]

( 01506 407 110

7  01506 407 108

 


From: Josh Joy [mailto:[hidden email]]
Sent: 23 March 2006 17:12
To: [hidden email]
Subject: RE: [ops-users] Dynamically Choose instance

 

I left my code at home, otherwise I would send it.....

 

I have a select1 tag that reads an external xml file instance. In the xml file there are several version tags

 

data.xml

 

<data>

 <version>1</version>

 <version>2</version>

 <version>3</version>

 <selectedVersion/>

</data>

 

The user can pick 1,2,3.

 

I have 3 other xml files, which are the same XML structure, though different data.

 

version1.xml

<data>

  <method>a</method>

 <method>b</method>

</data>

 

version2.xml

<data>

 <method>ZZZ</method>! ;

 <method>AAA</method>

</data>

 

version3.xml

 

<data>

 <method>123</method>

 <method>321</method>

</data>

 

A itemset XForm tag is used to load the version.xml file. Dependinig on whether the user chose 1,2,3 I use the corresponding xml file and present another select1 box using the xpath //method

 

So, there can be an unlimited amount of versions as the software grows with different method data, however it should be the same structure. I want to re use the business logic that goes on and will resuse the xpath as well, the user is just responsible for choosing the version and the corresponding method. Each version can have different methods. I was thinking the best way would be to dynamically load the xml file using the instance() XForm fun! ction. However, I'm not sure how to send a variableto the instance function. The variable I want to send is the user selected version, in this case

//selectedVersion XPath query run on data.xml

 

Thanks,

Josh

 

 



Ryan Puddephatt <[hidden email]> wrote:

So your saying you have two buttons on the page lets say one for each version, once this is click it will load the XML and update that same page. Or will it go to an different page?

 

Ryan Puddephatt

Software Engineer

TFX Group - IT UK

1 Michaelson Square

Livingston

West Lothian

Scotand

EH54 7DP

 

( 01506 407 110

7  01506 407 108

 


From: Josh Joy [mailto:[hidden email]]
Sent: 23 March 2006 16:56
To: [hidden email]
Subject: RE: [ops-users] Dynamically Choose instance

 

It's chosen by the user. The different values are in the xml. Based on their choice, I want to load a d! ifferent xml file.

 

*Flow*

 

1 xml file containing values -> based off value chosen, load the corresponding xml file and pull data from this xml file

 

Using the instance function one can dynamically load an xml file, however the file loaded has to be hardcoded which really isn't dynamic. I want the xml file that is used to be dynamically chosen by the user.

Ryan Puddephatt <[hidden email]> wrote:

How is the user going to choose that? If they are selecting it on a page,
use an input or select. If it is only entered once, then you could use XSLT
at the start

Ryan Puddephatt
Software Engineer
TFX Group - IT UK
1 Micha! elson Square
Livingston
West Lothian
Scotand
EH54 7DP

* [hidden email]
( 01506 407 110
7 01506 407 108


>-----Original Message-----
>From: Josh Joy [mailto:[hidden email]]
>Sent: 23 March 2006 13:33
>To: [hidden email]
>Subject: [ops-users] Dynamically Choose instance
>
>Hi All,
>
>Does anyone know how in XForms to dynamically choose
>an instance with a
>model?
>
>For instance, the bind id="versionChosen" has the
>version chose, either
>'version1' or 'version2'.
>
>That much works. I can output depending on the option
>chosen.
>
>
>
>src="application.xml">
>
>
>
>src="version1.xml">
>
>
>
>src="version2.xml">
>
>
>
>nodeset="instance('apps')//selectedValues/versionSelected"
>/>
>
>
>I want to be able to do something like this
> <form:group
>ref="instance('versionChosen')">
> Version Chosen: <form:output
>value="//testvalue" />
> </form:group

>
>Basically choose a version using the binding
>"versionChosen" which will
>be dynamically set.
>
>Thanks,
>Josh




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws


</form:output


--
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
ObjectWeb mailing lists service home page: http://www.objectweb.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws