AlainCouthures / xsltforms

XForms to XHTML+Javascript (AJAX) conversion based on a unique XSL transformation. Suitable server-side (PHP) or client-side (Google Chrome, Edge, Internet Explorer, Mozilla FireFox, Opera, Safari) browser treatment where an XSLT 1.0 engine is available
37 stars 17 forks source link

Why in code are removeAttribute maxLength and size? #4

Open rysi3k opened 9 years ago

rysi3k commented 9 years ago

Hello, I trying parsing forms generated in other software but I have some problems with some custom attributes. I have that code:

<xf:input
_bind="ID11"
ref="wnio:ID11" xxforms:size="10">
<xf:label>
<span/>
</xf:label>
</xf:input>

or

<xf:textarea
_bind="ID27"
ref="wnio:ID27"
xxforms:cols="107" xxforms:rows="3">
<xf:label>
<span/>
</xf:label>
</xf:textarea>

and namespace:

 <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">

And attributes with xxforms:size xxforms:cols or xxforms:rows are not parsed, so fields havent proper size. How to do it right way? Currently i have removed "xxforms" namespaces so in textarea case it works like a charm, but for input[type=text] attribue "size" was removed by JavaScript. There are lines

var max = type.getMaxLength();
if (max) {
   input.maxLength = max;
} else {
   input.removeAttribute("maxLength");
}

var length = type.getDisplayLength();
if (length) {
   input.size = length;
} else {
   input.removeAttribute("size");
}

Why do you remove that attributes? Why not only set size/maxlength when necessary?

Greetings

AlainCouthures commented 9 years ago

Hello, With XSLTForms, XForms controls are driven by data types which can be defined by a schema or binds. This allows a versatile approach where the same input can be rendered very differently depending on current data type.

Orbeon has its own extensions which can be set using the xxforms namespace. I'm afraid that allowing formatting attributes directly at control level is a pragmatic approach but not a restrictive one...