I'm using XSLTForms with Bootstrap, and trying to make the panel collapsible.
I assign an "id" to a "div" tag inside the repeat loop by using a combination of a string prefix (ins-id-), item position (position()) and one of the data value (name in this case, and map all the blanks to '_').
The attributes in the "a" tag works fine, but the 'id' attribute of the "div" tag only works for the first item inside the repeat loop, the rest of them have a null value "div id="" ..."
Is there a work around for this? The following is a portion of the code:
Thank you for your prompt response. We are using it for the configuration screen for one of the components and planning to release it in a couple of weeks. It is not a show stopper but it will be different to view the whole configuration since we can't collapse it by section.
I'm wondering, if I want to modify the code to added an attribute to bypass the id cloning for a tag, like:
<div id='...' cloneid='no'>
can you give me some pointers on which files/functions I should look into?
Thanks for your help.
Regards,
Richard Hung
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The are mutliple processes inside each instance and have mutliple classpaths inside each process.
The instance "div" id template is like ins-id-{position()}-{translate(@name,' ','')}
The process is prc-id-{position()}-{translate(@name,' ','')} and the classpath is
cp-id-{position()}-{translate(@name,' ','')}
The first "div" id for the instance at the outer loop are all correct. The very first "div" tag id of the process and classpath are correct, but the rest of them are like ins-id-{position()}-{translate(@name,' ','')}, using the instance prefix instead of the process (prc-) and classpath (cp-) prefix.
Is it possible to have a quick fix for this?
Thanks again for your help.
Regards,
Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm using XSLTForms with Bootstrap, and trying to make the panel collapsible.
I assign an "id" to a "div" tag inside the repeat loop by using a combination of a string prefix (ins-id-), item position (position()) and one of the data value (name in this case, and map all the blanks to '_').
The attributes in the "a" tag works fine, but the 'id' attribute of the "div" tag only works for the first item inside the repeat loop, the rest of them have a null value "div id="" ..."
Is there a work around for this? The following is a portion of the code:
Any help is greatly appreciated.
Regards,
Richard Hung
Last edit: Richard Hung 2016-01-29
Hello Richard,
AVT is new in XForms (https://www.w3.org/community/xformsusers/wiki/XForms_2.0#Attribute_Value_Templates) while id management within repeats has been implemented since XForms 1.0.
Currently, XForms implementors have decided not to allow AVT on id attribute.
The id attribute is heavily used in XForms and XSLTForms has its own manager to automatically add and change calculated ids when necessary.
To detect whether AVT is used in id attribute and disable default mechanism of cloning ids in repeats sounds possible in XSLTForms.
Are you in a hurry about that? I am now quite busy about XSLTForms v2...
Kind regards,
Alain Couthures
Hi Alain,
Thank you for your prompt response. We are using it for the configuration screen for one of the components and planning to release it in a couple of weeks. It is not a show stopper but it will be different to view the whole configuration since we can't collapse it by section.
I'm wondering, if I want to modify the code to added an attribute to bypass the id cloning for a tag, like:
can you give me some pointers on which files/functions I should look into?
Thanks for your help.
Regards,
Richard Hung
Hi Richard,
I have just been looking more deeply at your request and I think that I have found a way to support AVT in id within repeat.
Here is the corresponding patch:
function XsltForms_avt(subform, id, attrname, binding) {
this.init(subform, id);
this.attrname = attrname;
this.binding = binding;
this.hasBinding = true;
this.isOutput = true;
if (attrname.toLowerCase() === "id") {
this.element.setAttribute("id", "_");
} else if (this.binding && this.binding.type) {
this.element.setAttribute(this.attrname, "");
}
}
It is just initializing the id with a not empty value because the repeat cloning process just ignores elements without an id.
Please tell me if it works for you!
Regards,
Alain
Hello Alain,
Thanks a lot for looking into this! We are half way there!
It works perfectly for the loops without nested loops inside.
Our XML structures follows:
The are mutliple processes inside each instance and have mutliple classpaths inside each process.
The instance "div" id template is like ins-id-{position()}-{translate(@name,' ','')}
The process is prc-id-{position()}-{translate(@name,' ','')} and the classpath is
cp-id-{position()}-{translate(@name,' ','')}
The first "div" id for the instance at the outer loop are all correct. The very first "div" tag id of the process and classpath are correct, but the rest of them are like ins-id-{position()}-{translate(@name,' ','')}, using the instance prefix instead of the process (prc-) and classpath (cp-) prefix.
Is it possible to have a quick fix for this?
Thanks again for your help.
Regards,
Richard