Reload different version of instance

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

Reload different version of instance

musang
Hi All,

I'm trying to reload a saved XML (instance), unfortunately the structure of the instance has changed since the last time the XML was saved. I'll need to at least reload whatever that has not changed.
I use replace="instance" but this causes old instance structure replaced the new one and it mess out the form behavior.

I'm thinking of copying just the data+attributes of the unchanged part from the old XML to the new one, but I don't know how to do it in XForm.

This happen to all my forms, so, having a generic data copy method from old to new XML and retaining the new XML structure would be ideal.

Does anyone has solution for this ?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Re load different version of instance

Hank Ratzesberger

If your instance was in its own model, would the
reset action work?

There are some hints on copying using the 1.1 spec:


http://www.nabble.com/Copy-data-from-to18314623.html#a18655315

--Hank



On Nov 24, 2008, at 3:57 PM, musang wrote:

>
> Hi All,
>
> I'm trying to reload a saved XML (instance), unfortunately the  
> structure of
> the instance has changed since the last time the XML was saved.  
> I'll need to
> at least reload whatever that has not changed.
> I use replace="instance" but this causes old instance structure  
> replaced the
> new one and it mess out the form behavior.
>
> I'm thinking of copying just the data+attributes of the unchanged  
> part from
> the old XML to the new one, but I don't know how to do it in XForm.
>
> This happen to all my forms, so, having a generic data copy method  
> from old
> to new XML and retaining the new XML structure would be ideal.
>
> Does anyone has solution for this ?
>
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/Reload- 
> different-version-of-instance-tp20672632p20672632.html
> Sent from the ObjectWeb 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
Institute for Crustal Studies,
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: Re load different version of instance

Erik Bruchez
Administrator
In reply to this post by musang
I would:

* Use replace="instance" + instance="another-instance".
* Responding to xforms-submit-done, use xforms:setvalue and  
xforms:insert to update the first instance with parts of the second one.

-Erik

On Nov 24, 2008, at 3:57 PM, musang wrote:

>
> Hi All,
>
> I'm trying to reload a saved XML (instance), unfortunately the  
> structure of
> the instance has changed since the last time the XML was saved. I'll  
> need to
> at least reload whatever that has not changed.
> I use replace="instance" but this causes old instance structure  
> replaced the
> new one and it mess out the form behavior.
>
> I'm thinking of copying just the data+attributes of the unchanged  
> part from
> the old XML to the new one, but I don't know how to do it in XForm.
>
> This happen to all my forms, so, having a generic data copy method  
> from old
> to new XML and retaining the new XML structure would be ideal.
>
> Does anyone has solution for this ?
>
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/Reload-different-version-of-instance-tp20672632p20672632.html
> Sent from the ObjectWeb 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
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.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
Reply | Threaded
Open this post in threaded view
|

Re: Re load different version of instance

musang
Thanks Eric and Hank for the reply.

Eric's suggestion would work and what I need now is to find a way to retrieve node names dynamically I guess.

What I'm trying to do is to create some kind of generic code that I can reuse to copy data which has the same path between two instances and I can generate this code within my jsp to use different instance name when I generate the XForms code.

Attached is an example XForms from my unsuccessful attempt.

a.xhtml

Not sure if I can explain it clear enough :

  <xforms:instance id="source-instance">
        <instance xmlns="">
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <z>ddddddd</z>
        </instance>
  </xforms:instance>

  <xforms:instance id="dest-instance">
        <instance xmlns="">
                <x/>
                <y/>
                <s/>
        </instance>
  </xforms:instance>

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">
        <xforms:setvalue ref="." value="instance('source-instance')[/context()/name()]"/>
</xforms:action>

This code doesn't work, it returned all the content of a,b and d because "/context()/name()" is refering to the <instance> node of souce-instance I guess. I don't know how to replace this "/context()/name()" with something that will return instance('dest-instance')/Current Iterate Node full path.

The end result that I am aiming is :

  <xforms:instance id="dest-instance">
        <instance>
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <s/>
        </instance>
  </xforms:instance>


Anybody has any better way to do this ? or is this something possible to do in XForms at all ?

Thanks again.



Erik Bruchez wrote
I would:

* Use replace="instance" + instance="another-instance".
* Responding to xforms-submit-done, use xforms:setvalue and  
xforms:insert to update the first instance with parts of the second one.

-Erik

On Nov 24, 2008, at 3:57 PM, musang wrote:

>
> Hi All,
>
> I'm trying to reload a saved XML (instance), unfortunately the  
> structure of
> the instance has changed since the last time the XML was saved. I'll  
> need to
> at least reload whatever that has not changed.
> I use replace="instance" but this causes old instance structure  
> replaced the
> new one and it mess out the form behavior.
>
> I'm thinking of copying just the data+attributes of the unchanged  
> part from
> the old XML to the new one, but I don't know how to do it in XForm.
>
> This happen to all my forms, so, having a generic data copy method  
> from old
> to new XML and retaining the new XML structure would be ideal.
>
> Does anyone has solution for this ?
>
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/Reload-different-version-of-instance-tp20672632p20672632.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> You receive this message as a subscriber of the ops-users@ow2.org  
> mailing list.
> To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
> For general help: mailto:sympa@ow2.org?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



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

Re: Re load different version of instance

musang
I've got the full path with the code below but I don't know how to use it to get the other source node

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">

          <xforms:setvalue ref="instance('temp-instance')/temp" value="''"/>

          <xforms:action ev:event="xforms-ready" xxforms:iterate="ancestor-or-self::*">
                <xforms:setvalue ref="instance('temp-instance')/temp" value="concat(instance('temp-instance')/temp,'/',context()/name())" if="../name() != ''"/>
         </xforms:action>

        <xforms:setvalue ref="." value="instance('source-instance')[instance('temp-instance')/temp]"/>
</xforms:action>




musang wrote
Thanks Eric and Hank for the reply.

Eric's suggestion would work and what I need now is to find a way to retrieve node names dynamically I guess.

What I'm trying to do is to create some kind of generic code that I can reuse to copy data which has the same path between two instances and I can generate this code within my jsp to use different instance name when I generate the XForms code.

Attached is an example XForms from my unsuccessful attempt.

a.xhtml

Not sure if I can explain it clear enough :

  <xforms:instance id="source-instance">
        <instance xmlns="">
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <z>ddddddd</z>
        </instance>
  </xforms:instance>

  <xforms:instance id="dest-instance">
        <instance xmlns="">
                <x/>
                <y/>
                <s/>
        </instance>
  </xforms:instance>

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">
        <xforms:setvalue ref="." value="instance('source-instance')[/context()/name()]"/>
</xforms:action>

This code doesn't work, it returned all the content of a,b and d because "/context()/name()" is refering to the <instance> node of souce-instance I guess. I don't know how to replace this "/context()/name()" with something that will return instance('dest-instance')/Current Iterate Node full path.

The end result that I am aiming is :

  <xforms:instance id="dest-instance">
        <instance>
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <s/>
        </instance>
  </xforms:instance>


Anybody has any better way to do this ? or is this something possible to do in XForms at all ?

Thanks again.



Erik Bruchez wrote
I would:

* Use replace="instance" + instance="another-instance".
* Responding to xforms-submit-done, use xforms:setvalue and  
xforms:insert to update the first instance with parts of the second one.

-Erik

On Nov 24, 2008, at 3:57 PM, musang wrote:

>
> Hi All,
>
> I'm trying to reload a saved XML (instance), unfortunately the  
> structure of
> the instance has changed since the last time the XML was saved. I'll  
> need to
> at least reload whatever that has not changed.
> I use replace="instance" but this causes old instance structure  
> replaced the
> new one and it mess out the form behavior.
>
> I'm thinking of copying just the data+attributes of the unchanged  
> part from
> the old XML to the new one, but I don't know how to do it in XForm.
>
> This happen to all my forms, so, having a generic data copy method  
> from old
> to new XML and retaining the new XML structure would be ideal.
>
> Does anyone has solution for this ?
>
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/Reload-different-version-of-instance-tp20672632p20672632.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> You receive this message as a subscriber of the ops-users@ow2.org  
> mailing list.
> To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
> For general help: mailto:sympa@ow2.org?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



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

Re: Re load different version of instance

musang
Hmm, I guess this is not possible. I'm giving up


musang wrote
I've got the full path with the code below but I don't know how to use it to get the other source node

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">

          <xforms:setvalue ref="instance('temp-instance')/temp" value="''"/>

          <xforms:action ev:event="xforms-ready" xxforms:iterate="ancestor-or-self::*">
                <xforms:setvalue ref="instance('temp-instance')/temp" value="concat(instance('temp-instance')/temp,'/',context()/name())" if="../name() != ''"/>
         </xforms:action>

        <xforms:setvalue ref="." value="instance('source-instance')[instance('temp-instance')/temp]"/>
</xforms:action>




musang wrote
Thanks Eric and Hank for the reply.

Eric's suggestion would work and what I need now is to find a way to retrieve node names dynamically I guess.

What I'm trying to do is to create some kind of generic code that I can reuse to copy data which has the same path between two instances and I can generate this code within my jsp to use different instance name when I generate the XForms code.

Attached is an example XForms from my unsuccessful attempt.

a.xhtml

Not sure if I can explain it clear enough :

  <xforms:instance id="source-instance">
        <instance xmlns="">
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <z>ddddddd</z>
        </instance>
  </xforms:instance>

  <xforms:instance id="dest-instance">
        <instance xmlns="">
                <x/>
                <y/>
                <s/>
        </instance>
  </xforms:instance>

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">
        <xforms:setvalue ref="." value="instance('source-instance')[/context()/name()]"/>
</xforms:action>

This code doesn't work, it returned all the content of a,b and d because "/context()/name()" is refering to the <instance> node of souce-instance I guess. I don't know how to replace this "/context()/name()" with something that will return instance('dest-instance')/Current Iterate Node full path.

The end result that I am aiming is :

  <xforms:instance id="dest-instance">
        <instance>
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <s/>
        </instance>
  </xforms:instance>


Anybody has any better way to do this ? or is this something possible to do in XForms at all ?

Thanks again.



Erik Bruchez wrote
I would:

* Use replace="instance" + instance="another-instance".
* Responding to xforms-submit-done, use xforms:setvalue and  
xforms:insert to update the first instance with parts of the second one.

-Erik

On Nov 24, 2008, at 3:57 PM, musang wrote:

>
> Hi All,
>
> I'm trying to reload a saved XML (instance), unfortunately the  
> structure of
> the instance has changed since the last time the XML was saved. I'll  
> need to
> at least reload whatever that has not changed.
> I use replace="instance" but this causes old instance structure  
> replaced the
> new one and it mess out the form behavior.
>
> I'm thinking of copying just the data+attributes of the unchanged  
> part from
> the old XML to the new one, but I don't know how to do it in XForm.
>
> This happen to all my forms, so, having a generic data copy method  
> from old
> to new XML and retaining the new XML structure would be ideal.
>
> Does anyone has solution for this ?
>
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/Reload-different-version-of-instance-tp20672632p20672632.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> You receive this message as a subscriber of the ops-users@ow2.org  
> mailing list.
> To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
> For general help: mailto:sympa@ow2.org?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



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

Re: Re load different version of instance

musang
I wish the AVTs is supported in xforms:setvalue value. That will solve my problem right away.
Anyone know if there is plan to add AVTs in xforms:setvalue ?

http://www.orbeon.com/ops/doc/reference-xforms-2#avts-xforms

musang wrote
Hmm, I guess this is not possible. I'm giving up


musang wrote
I've got the full path with the code below but I don't know how to use it to get the other source node

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">

          <xforms:setvalue ref="instance('temp-instance')/temp" value="''"/>

          <xforms:action ev:event="xforms-ready" xxforms:iterate="ancestor-or-self::*">
                <xforms:setvalue ref="instance('temp-instance')/temp" value="concat(instance('temp-instance')/temp,'/',context()/name())" if="../name() != ''"/>
         </xforms:action>

        <xforms:setvalue ref="." value="instance('source-instance')[instance('temp-instance')/temp]"/>
</xforms:action>




musang wrote
Thanks Eric and Hank for the reply.

Eric's suggestion would work and what I need now is to find a way to retrieve node names dynamically I guess.

What I'm trying to do is to create some kind of generic code that I can reuse to copy data which has the same path between two instances and I can generate this code within my jsp to use different instance name when I generate the XForms code.

Attached is an example XForms from my unsuccessful attempt.

a.xhtml

Not sure if I can explain it clear enough :

  <xforms:instance id="source-instance">
        <instance xmlns="">
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <z>ddddddd</z>
        </instance>
  </xforms:instance>

  <xforms:instance id="dest-instance">
        <instance xmlns="">
                <x/>
                <y/>
                <s/>
        </instance>
  </xforms:instance>

<xforms:action ev:event="xforms-ready" xxforms:iterate="instance('dest-instance')//*" id="node-iterate">
        <xforms:setvalue ref="." value="instance('source-instance')[/context()/name()]"/>
</xforms:action>

This code doesn't work, it returned all the content of a,b and d because "/context()/name()" is refering to the <instance> node of souce-instance I guess. I don't know how to replace this "/context()/name()" with something that will return instance('dest-instance')/Current Iterate Node full path.

The end result that I am aiming is :

  <xforms:instance id="dest-instance">
        <instance>
                <x>aaaaaaa</x>
                <y>bbbbbbb</y>
                <s/>
        </instance>
  </xforms:instance>


Anybody has any better way to do this ? or is this something possible to do in XForms at all ?

Thanks again.



Erik Bruchez wrote
I would:

* Use replace="instance" + instance="another-instance".
* Responding to xforms-submit-done, use xforms:setvalue and  
xforms:insert to update the first instance with parts of the second one.

-Erik

On Nov 24, 2008, at 3:57 PM, musang wrote:

>
> Hi All,
>
> I'm trying to reload a saved XML (instance), unfortunately the  
> structure of
> the instance has changed since the last time the XML was saved. I'll  
> need to
> at least reload whatever that has not changed.
> I use replace="instance" but this causes old instance structure  
> replaced the
> new one and it mess out the form behavior.
>
> I'm thinking of copying just the data+attributes of the unchanged  
> part from
> the old XML to the new one, but I don't know how to do it in XForm.
>
> This happen to all my forms, so, having a generic data copy method  
> from old
> to new XML and retaining the new XML structure would be ideal.
>
> Does anyone has solution for this ?
>
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/Reload-different-version-of-instance-tp20672632p20672632.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> You receive this message as a subscriber of the ops-users@ow2.org  
> mailing list.
> To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
> For general help: mailto:sympa@ow2.org?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



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