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
|