Insert attribute in node that has no attributes yet?

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

Insert attribute in node that has no attributes yet?

Roald de Wit-2
Hi list,

Is it possible to add an arbitrary attribute to a node that has no
attributes yet? If possible I'd like to accomplish this without using
any origin=".." types in the xforms:insert.

>From an old topic [1] (March 2007) I read you can do the following to
add an attribute:

<xforms:insert nodeset="@*" position="after" at="1"
origin="instance('my-attribute')/@attr1"/>

Unfortunately:
- this does not work when the node has no attributes at all
- this requires you to create a 'dummy' instance node with all possible
attributes you might want to add

Surely there must be a way to accomplish this?

Regards, Roald

[1] http://mail-archive.ow2.org/ops-users/2007-03/msg00126.html

--
Roald de Wit
Software Engineer
[hidden email]

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/



--
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: Insert attribute in node that has no attributes yet?

fl.schmitt(ops-users)
Hi Roald,

> Is it possible to add an arbitrary attribute to a node that has no
> attributes yet? If possible I'd like to accomplish this without using
> any origin=".." types in the xforms:insert.

i fear that this isn't possible. According to the 1.0 xforms
specification, a xforms:insert action requires a "homogenous collection"
- if that collection is empty, "the insert action has no effect." [1]

Also according to the 1.1 Candidate Recommendation, the insert action is
executed "by cloning one or more existing instance nodes". [2] So, in
any case a "template" node/instance has to be available.

HTH
florian

[1] http://www.w3.org/TR/2007/REC-xforms-20071029/#action-insert
[2] http://www.w3.org/TR/xforms11/#action-insert




--
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: Insert attribute in node that has no attributes yet?

Roald de Wit-2
Hi Florian et al,

On Thu, 2008-06-05 at 17:52 +0930, Florian Schmitt wrote:

> Hi Roald,
>
> > Is it possible to add an arbitrary attribute to a node that has no
> > attributes yet? If possible I'd like to accomplish this without using
> > any origin=".." types in the xforms:insert.
>
> i fear that this isn't possible. According to the 1.0 xforms
> specification, a xforms:insert action requires a "homogenous collection"
> - if that collection is empty, "the insert action has no effect." [1]
>
Thank you for your reply. Not having given up we kept on trying to find
a way and now... The following might break the 1.0 spec, but works, both
in Orbeon and the Mozilla XForms plugin:

          <xforms:trigger>
            <xforms:label>Add</xforms:label>
            <xforms:action ev:event="DOMActivate">
              <xf:insert context="." origin="instance('template-attributes')/@xlink:show"/>
             </xforms:action>
          </xforms:trigger>

And we have a 'dummy' instance now to provide the attribute (still don't
like this much, but it's way better than nothing):

            <xforms:instance id="template-attributes">
              <attributes xmlns=""
                  xlink:href=""
                  xlink:role=""
                  xlink:arcrole=""
                  xlink:title=""
                  xlink:show=""
                  xlink:actuate=""
              />
            </xforms:instance>

So, this is pretty much what the 1.1 recommendation suggests. Thanks for
pointing to these sections, Florian.

Regards, Roald

--
Roald de Wit
Software Engineer
[hidden email]

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/



--
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: Insert attribute in node that has no attributes yet?

Erik Bruchez
Administrator
In reply to this post by Roald de Wit-2
> Is it possible to add an arbitrary attribute to a node that has no
> attributes yet?

Yes.

> If possible I'd like to accomplish this without using
> any origin=".." types in the xforms:insert.

@origin is how you specify what to insert, so that's what you want.

> <xforms:insert nodeset="@*" position="after" at="1"
> origin="instance('my-attribute')/@attr1"/>
>
> Unfortunately:
> - this does not work when the node has no attributes at all

Instead, do:

<xforms:insert context="...element into which to insert..."
                origin="...attribute to insert..."/>

> - this requires you to create a 'dummy' instance node with all  
> possible
> attributes you might want to add

Orbeon Forms has an extension for this:

<xforms:insert context="...element into which to insert..."
                origin="xxforms:attribute('name', 'value')"/>

-Erik

--
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: Insert attribute in node that has no attributes yet?

Roald de Wit-2

On Thu, 2008-06-05 at 18:17 +0930, Erik Bruchez wrote:
> <xforms:insert context="...element into which to insert..."
>                 origin="...attribute to insert..."/>

Thanks Erik. Cross post (see other email): that's exactly how we did it.
Glad to see it's the correct way to do it.

Regards,

Roald
--
Roald de Wit
Software Engineer
[hidden email]

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/



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