|
List Info
Thread: Re: remove empty content from xml output at xform submission
|
|
| Re: remove empty content from xml
output at xform submission |

|
2007-03-23 10:57:04 |
Yes, indeed. I was a bit too quick there. In my example,
when you start
with both controls having content, you can delete the
content from one
of the controls, but once it is empty, the fact that becomes
non-relevant will make it disabled as per xforms 6.1.4.
Since openoffice.org Writer cannot do actions on submit, you
would need
to resort to scripting in order to purge empty nodes from
the DOM. Not
very nice, especially as this will make the bindings to
those nodes invalid.
Using a check-box in order to switch the relevance of
certain portions
of the instance via a secondary instance might be the best
way to go.
Bests,
Lars
Stephen Green wrote:
> Hi Lars, Bryan,
>
> There is a bit of a problem with this solution I think
(correct me if I'm
> wrong) - if you remove the data from the second element
you can't add
> it back again because it's absence makes relevant
become false and
> therefore input to that bound control impossible.
>
> An XForms workaround (acknowledgements to LK and
Firefox team)
> is to have an extra instance with true/false and
bindings
> something like
>
> <xforms:bind
nodeset="instance('instance1')/e1/*"
>
relevant="not(boolean-from-string(instance('state')/tri
m) and .='')" />
> <xforms:bind
nodeset="instance('instance1')/e2/*"
>
relevant="not(boolean-from-string(instance('state')/tri
m) and .='')" />
>
> and then something like:
>
> <submission...>
> <action ev:event="xforms-submit">
> <setvalue
ref="instance('state')/trim">true</setvalue&
gt;
> </action>
> <action
ev:event="xforms-submit-done">
> <setvalue
ref="instance('state')/trim">false</setvalue
>
> </action>
> <action
ev:event="xforms-submit-error">
> <setvalue
ref="instance('state')/trim">false</setvalue
>
> </action>
> </submission>
>
> The bindings have to, it seems, be each defined at each
level
> in the tree or there is a problem where leaf elements
are trimmed
> but not their containing elements. This means lots of
bindings.
> Maybe a further complication arises when you need to
add other
> constraints to the same nodes.
>
> I've not got this working in OOo2, only in Firefox so
I'll give it a go
> and see if it works but it make take a bit of time.
Plus I didn't get
> it working on lots of elements in a large tree even in
Firefox (lack
> of time and not necessarily a problem). I do have
concerns that
> the order in which the trim actions occur may influence
the results
> though, especially in a complex structure like UBL.
I'll see.
>
> All the best
>
> Stephen Green
>
>
> On 23/03/07, Lars Oppermann <lars.oppermann sun.com> wrote:
>> Hi Bryan,
>>
>> I think this can be done (up to a certain point)
through the
>> xforms:relevant MIP. I have attached a test
document that demonstrates
>> the basic approach:
>>
>> The structure of the instance is like this:
>>
>> <root>
>> <e1>
>> <sub></sub>
>> </e1>
>> <e2>
>> <sub></sub>
>> </e2>
>> </root>
>>
>> There is a binding that binds to every child of the
root-element, that
>> says that the node is only relevant if the text
content of the element's
>> "sub"-child is non-empty:
>>
>> <xf:bind nodeset="/root/*"
relevant="string-length(./sub)>0"/>
>>
>> Now, if only the second "sub"-element has
text content (aaa) the
>> following XML is submitted:
>>
>> [d:]type sub2.xml
>> <?xml version="1.0"?>
>>
<root><e2><sub>aaa</sub></e2>&
lt;/root>
>>
>> Note that e1 is not submitted, because it got
marked with relevant=false.
>>
>> Cheers,
>> Lars
>>
>> bryan rasmussen wrote:
>> > Hi,
>> >
>> > I've asked this before and haven't heard a
response yet. In an Xform
>> > running in Open Office how do I stop output of
elements that are
>> > empty? This should basically stop output of
all elements where none of
>> > the descendant elements have input as well as
stopping the more
>> > prosaic output of empty elements
>> >
>> >
>> > Cheers,
>> > Bryan Rasmussen
>> >
>> >
------------------------------------------------------------
---------
>> > To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
>> > For additional commands, e-mail: dev-help xml.openoffice.org
>> >
>>
>>
>>
------------------------------------------------------------
---------
>> To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
>> For additional commands, e-mail: dev-help xml.openoffice.org
>>
>>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
> For additional commands, e-mail: dev-help xml.openoffice.org
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
For additional commands, e-mail: dev-help xml.openoffice.org
|
|
| Re: remove empty content from xml
output at xform submission |

|
2007-03-23 12:45:18 |
Yes, using a button or checkbox would be a sensible
alternative
Thanks
Steve
On 23/03/07, Lars Oppermann <lars.oppermann sun.com> wrote:
> Yes, indeed. I was a bit too quick there. In my
example, when you start
> with both controls having content, you can delete the
content from one
> of the controls, but once it is empty, the fact that
becomes
> non-relevant will make it disabled as per xforms
6.1.4.
> Since openoffice.org Writer cannot do actions on
submit, you would need
> to resort to scripting in order to purge empty nodes
from the DOM. Not
> very nice, especially as this will make the bindings to
those nodes invalid.
> Using a check-box in order to switch the relevance of
certain portions
> of the instance via a secondary instance might be the
best way to go.
>
> Bests,
> Lars
>
> Stephen Green wrote:
> > Hi Lars, Bryan,
> >
> > There is a bit of a problem with this solution I
think (correct me if I'm
> > wrong) - if you remove the data from the second
element you can't add
> > it back again because it's absence makes relevant
become false and
> > therefore input to that bound control impossible.
> >
> > An XForms workaround (acknowledgements to LK and
Firefox team)
> > is to have an extra instance with true/false and
bindings
> > something like
> >
> > <xforms:bind
nodeset="instance('instance1')/e1/*"
> >
relevant="not(boolean-from-string(instance('state')/tri
m) and .='')" />
> > <xforms:bind
nodeset="instance('instance1')/e2/*"
> >
relevant="not(boolean-from-string(instance('state')/tri
m) and .='')" />
> >
> > and then something like:
> >
> > <submission...>
> > <action
ev:event="xforms-submit">
> > <setvalue
ref="instance('state')/trim">true</setvalue&
gt;
> > </action>
> > <action
ev:event="xforms-submit-done">
> > <setvalue
ref="instance('state')/trim">false</setvalue
>
> > </action>
> > <action
ev:event="xforms-submit-error">
> > <setvalue
ref="instance('state')/trim">false</setvalue
>
> > </action>
> > </submission>
> >
> > The bindings have to, it seems, be each defined at
each level
> > in the tree or there is a problem where leaf
elements are trimmed
> > but not their containing elements. This means lots
of bindings.
> > Maybe a further complication arises when you need
to add other
> > constraints to the same nodes.
> >
> > I've not got this working in OOo2, only in Firefox
so I'll give it a go
> > and see if it works but it make take a bit of
time. Plus I didn't get
> > it working on lots of elements in a large tree
even in Firefox (lack
> > of time and not necessarily a problem). I do have
concerns that
> > the order in which the trim actions occur may
influence the results
> > though, especially in a complex structure like
UBL. I'll see.
> >
> > All the best
> >
> > Stephen Green
> >
> >
> > On 23/03/07, Lars Oppermann <lars.oppermann sun.com> wrote:
> >> Hi Bryan,
> >>
> >> I think this can be done (up to a certain
point) through the
> >> xforms:relevant MIP. I have attached a test
document that demonstrates
> >> the basic approach:
> >>
> >> The structure of the instance is like this:
> >>
> >> <root>
> >> <e1>
> >> <sub></sub>
> >> </e1>
> >> <e2>
> >> <sub></sub>
> >> </e2>
> >> </root>
> >>
> >> There is a binding that binds to every child
of the root-element, that
> >> says that the node is only relevant if the
text content of the element's
> >> "sub"-child is non-empty:
> >>
> >> <xf:bind nodeset="/root/*"
relevant="string-length(./sub)>0"/>
> >>
> >> Now, if only the second
"sub"-element has text content (aaa) the
> >> following XML is submitted:
> >>
> >> [d:]type sub2.xml
> >> <?xml version="1.0"?>
> >>
<root><e2><sub>aaa</sub></e2>&
lt;/root>
> >>
> >> Note that e1 is not submitted, because it got
marked with relevant=false.
> >>
> >> Cheers,
> >> Lars
> >>
> >> bryan rasmussen wrote:
> >> > Hi,
> >> >
> >> > I've asked this before and haven't heard
a response yet. In an Xform
> >> > running in Open Office how do I stop
output of elements that are
> >> > empty? This should basically stop output
of all elements where none of
> >> > the descendant elements have input as
well as stopping the more
> >> > prosaic output of empty elements
> >> >
> >> >
> >> > Cheers,
> >> > Bryan Rasmussen
> >> >
> >> >
------------------------------------------------------------
---------
> >> > To unsubscribe, e-mail:
dev-unsubscribe xml.openoffice.org
> >> > For additional commands, e-mail:
dev-help xml.openoffice.org
> >> >
> >>
> >>
> >>
------------------------------------------------------------
---------
> >> To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
> >> For additional commands, e-mail: dev-help xml.openoffice.org
> >>
> >>
> >
> >
------------------------------------------------------------
---------
> > To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
> > For additional commands, e-mail: dev-help xml.openoffice.org
> >
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
> For additional commands, e-mail: dev-help xml.openoffice.org
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe xml.openoffice.org
For additional commands, e-mail: dev-help xml.openoffice.org
|
|
[1-2]
|
|