generating unique ids for XForms elements using xxforms:variable and xi:include

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

generating unique ids for XForms elements using xxforms:variable and xi:include

Philip.Cantin
Hi All,

I am trying to create unique ids for an XHTML document that I am importing using an <xi:include> tag.

My approach initially was to use an xxforms:variable for each id in the imported document, and then set it to a different value in-between the xi:includes.

However, for some reason my variable is not recognized....instead, I get a "Duplicate id for XForms element: $citeinforepeat" error.


Is there something I'm not taking into consideration? And if my approach isn't a good one, what is the best way to accomplish this? The files I am using are attached below.

Thanks in advance!!


---Philip


test_uniqueids.xhtml

citeinfo.xhtml
Reply | Threaded
Open this post in threaded view
|

Re: generating unique ids for XForms elements using xxforms:variable and xi:include

Erik Bruchez
Administrator
Philip,

The error is not very clear but what it means is that you have a  
duplicate variable declaration. You cannot override variable this way,  
unfortunately, anymore than you can do it in Java or other languages.

Now I haven't tried this, but what if you were putting an xforms:group  
around each variable, like:

<xforms:group>
   <xxforms:variable name="citeinforepeat">1</xxforms:variable>
   <xi:include href="/apps/xforms-stacy/citeinfo.xhtml" />
</xforms:group>

-Erik

On Jun 8, 2009, at 9:12 AM, Philip.Cantin wrote:

>
> Hi All,
>
> I am trying to create unique ids for an XHTML document that I am  
> importing
> using an <xi:include> tag.
>
> My approach initially was to use an xxforms:variable for each id in  
> the
> imported document, and then set it to a different value in-between the
> xi:includes.
>
> However, for some reason my variable is not recognized....instead, I  
> get a
> "Duplicate id for XForms element: $citeinforepeat" error.
>
>
> Is there something I'm not taking into consideration? And if my  
> approach
> isn't a good one, what is the best way to accomplish this? The files  
> I am
> using are attached below.
>
> Thanks in advance!!
>
>
> ---Philip
>
>
> http://www.nabble.com/file/p23927142/test_uniqueids.xhtml
> test_uniqueids.xhtml
>
> http://www.nabble.com/file/p23927142/citeinfo.xhtml citeinfo.xhtml
> --
> View this message in context: http://www.nabble.com/generating-unique-ids-for-XForms-elements-using-xxforms%3Avariable-and-xi%3Ainclude-tp23927142p23927142.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: generating unique ids for XForms elements using xxforms:variable and xi:include

Philip.Cantin
Erik,

Thanks much for your reply. I tried what you had suggested, but no luck; the same error appears.

It looks to me as if, in citeinfo.xhtml, the $citeinforepeat variable isn't even being recognized within the id attribute of <xf:repeat>. Rather, it's being treated as a string. I tried running the page without the xi:includes (in other words, putting the XHTML markup from citeinfo.xhtml back into test_uniqueids.xhtml), but that doesn't help, either.

Is it even possible to put a variable value within an id attribute?


---Philip


Erik Bruchez wrote
Philip,

The error is not very clear but what it means is that you have a  
duplicate variable declaration. You cannot override variable this way,  
unfortunately, anymore than you can do it in Java or other languages.

Now I haven't tried this, but what if you were putting an xforms:group  
around each variable, like:

<xforms:group>
   <xxforms:variable name="citeinforepeat">1</xxforms:variable>
   <xi:include href="/apps/xforms-stacy/citeinfo.xhtml" />
</xforms:group>

-Erik

On Jun 8, 2009, at 9:12 AM, Philip.Cantin wrote:

>
> Hi All,
>
> I am trying to create unique ids for an XHTML document that I am  
> importing
> using an <xi:include> tag.
>
> My approach initially was to use an xxforms:variable for each id in  
> the
> imported document, and then set it to a different value in-between the
> xi:includes.
>
> However, for some reason my variable is not recognized....instead, I  
> get a
> "Duplicate id for XForms element: $citeinforepeat" error.
>
>
> Is there something I'm not taking into consideration? And if my  
> approach
> isn't a good one, what is the best way to accomplish this? The files  
> I am
> using are attached below.
>
> Thanks in advance!!
>
>
> ---Philip
>
>
> http://www.nabble.com/file/p23927142/test_uniqueids.xhtml
> test_uniqueids.xhtml
>
> http://www.nabble.com/file/p23927142/citeinfo.xhtml citeinfo.xhtml
> --
> View this message in context: http://www.nabble.com/generating-unique-ids-for-XForms-elements-using-xxforms%3Avariable-and-xi%3Ainclude-tp23927142p23927142.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: generating unique ids for XForms elements using xxforms:variable and xi:include

Alessandro Vernet
Administrator
Philip,

Philip.Cantin wrote
It looks to me as if, in citeinfo.xhtml, the $citeinforepeat variable isn't even being recognized within the id attribute of <xf:repeat>. Rather, it's being treated as a string.
This is exactly what happens. If you write <xf:repeat id="$citeinforepeat" nodeset="citeinfo">, the value of the "id" attribute is interpreted as a string, not an XPath expression.

Since you are including a piece of code multiple times in your page, it looks as if you are aiming at creating a reusable component, which is exactly what XBL is for. The XBL engine will solve all those IDs problems for you, so I'd recommend you have a go at writing an XBL component for this. See:

http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide

Alex
Reply | Threaded
Open this post in threaded view
|

Re: generating unique ids for XForms elements using xxforms:variable and xi:include

Philip.Cantin
Alex,

Please excuse the late reply, and I really appreciate you pointing me in the right direction.

I've been trying to learn the ropes of XBL for a few days now, and I'm running into a few problems:


1) Firstly, I'm trying to get the simplest of examples to work in Orbeon; is there something special needed to use XBL bindings in Orbeon? The example I have attached to this message works fine in Firefox 3.0.11, but I get a blank page when running it in Orbeon 3.7.1 (Developer Release).

2) My initial approach to the unique ID problem was to create an XBL binding with a <template> element that would store all of the XForms code associated with the code I am trying to reuse, and have a variable attached to the repeat id (and all other ids in the reused code), which would come from a Javascript function. Is this a good approach, or would xxforms:variable work better here? What is making me lost is figuring out whether XBL alone can make components reusable AND unique, or just reusable (and the uniqueness must be derived through a separate script).

Just for clarification of my use case, the code I want to reuse is <xf:repeat> controls which reference the same element in an instance, just in different places. In other words, if I have an instance like:

<xf:instance id="views">

<A1>
   <B1>
      <C1 />
   </B1>
   <D1>
      <C1 />
  </D1>
</A1>
</xf:instance>

and a body that looks like:

<body>
  <xf:group ref="instance('views')">
         ...
  </xf:group>
</body>

I'd like to be able to insert the reused code within the body so that both <C1> elements in the hierarchy are referenced.


Thanks in advance, and please let me know if I'm not being clear with anything.


---Philip


Alessandro Vernet wrote
Philip,

Philip.Cantin wrote
It looks to me as if, in citeinfo.xhtml, the $citeinforepeat variable isn't even being recognized within the id attribute of <xf:repeat>. Rather, it's being treated as a string.
This is exactly what happens. If you write <xf:repeat id="$citeinforepeat" nodeset="citeinfo">, the value of the "id" attribute is interpreted as a string, not an XPath expression.

Since you are including a piece of code multiple times in your page, it looks as if you are aiming at creating a reusable component, which is exactly what XBL is for. The XBL engine will solve all those IDs problems for you, so I'd recommend you have a go at writing an XBL component for this. See:

http://wiki.orbeon.com/forms/doc/developer-guide/xbl-components-guide

Alex

test_xbl.xhtml

test.xml
Reply | Threaded
Open this post in threaded view
|

Re: generating unique ids for XForms elements using xxforms:variable and xi:include

Alessandro Vernet
Administrator
Philip,

Philip.Cantin wrote
1) Firstly, I'm trying to get the simplest of examples to work in Orbeon; is there something special needed to use XBL bindings in Orbeon? The example I have attached to this message works fine in Firefox 3.0.11, but I get a blank page when running it in Orbeon 3.7.1 (Developer Release).
Quickly looking at the code, there are quite a few things that won't work. For instance the XBL 2 namespace is http://www.w3.org/ns/xbl (instead of http://www.w3.org/ns/xbl). I'd recommend you start from one of the components we have already built. You can see then in the source here:

http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/ops/orbeon/src/resources-packaged/xbl/orbeon/

Maybe a good one to get started is us-phone, which is quite simple.

Then you need to xinclude your XBL in your XForms. For the fr:* components, we defined a convention and they are automatically included for you. But if you write your own component you have to do this manually.

Philip.Cantin wrote
2) My initial approach to the unique ID problem was to create an XBL binding with a <template> element that would store all of the XForms code associated with the code I am trying to reuse, and have a variable attached to the repeat id (and all other ids in the reused code), which would come from a Javascript function. Is this a good approach, or would xxforms:variable work better here? What is making me lost is figuring out whether XBL alone can make components reusable AND unique, or just reusable (and the uniqueness must be derived through a separate script).
The XBL engine will make sure the instances of your component are unique. For instance, say your component has a <xforms:input id="my-input"> and somewhere in the code for the component you have the action <xforms:setfocus control="my-input">. If as a user of the component has multiple instances of that component on the page, you'll have multiple "my-input" inputs, but the XBL engine will sort things out for you.

Alex

Reply | Threaded
Open this post in threaded view
|

Re: generating unique ids for XForms elements using xxforms:variable and xi:include

Philip.Cantin
Alex,

Thank you very much for your help!! This is exactly what I was looking for; using one of the fr:* components in my XBL document allows me to XInclude the XBL document and use the component multiple times in my XHTML document without having to worry about duplicate IDs, just as you said. :)


---Philip


Alessandro Vernet wrote
Philip,

Philip.Cantin wrote
1) Firstly, I'm trying to get the simplest of examples to work in Orbeon; is there something special needed to use XBL bindings in Orbeon? The example I have attached to this message works fine in Firefox 3.0.11, but I get a blank page when running it in Orbeon 3.7.1 (Developer Release).
Quickly looking at the code, there are quite a few things that won't work. For instance the XBL 2 namespace is http://www.w3.org/ns/xbl (instead of http://www.w3.org/ns/xbl). I'd recommend you start from one of the components we have already built. You can see then in the source here:

http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/ops/orbeon/src/resources-packaged/xbl/orbeon/

Maybe a good one to get started is us-phone, which is quite simple.

Then you need to xinclude your XBL in your XForms. For the fr:* components, we defined a convention and they are automatically included for you. But if you write your own component you have to do this manually.

Philip.Cantin wrote
2) My initial approach to the unique ID problem was to create an XBL binding with a <template> element that would store all of the XForms code associated with the code I am trying to reuse, and have a variable attached to the repeat id (and all other ids in the reused code), which would come from a Javascript function. Is this a good approach, or would xxforms:variable work better here? What is making me lost is figuring out whether XBL alone can make components reusable AND unique, or just reusable (and the uniqueness must be derived through a separate script).
The XBL engine will make sure the instances of your component are unique. For instance, say your component has a <xforms:input id="my-input"> and somewhere in the code for the component you have the action <xforms:setfocus control="my-input">. If as a user of the component has multiple instances of that component on the page, you'll have multiple "my-input" inputs, but the XBL engine will sort things out for you.

Alex