How do I set maxLength of a string on an xforms template

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 06:21 PM
Simple question: how do I set a limit on the lenth of an input string?
I found an example somewhere that showed how to use an xs:restriction but this does not appear to work:
Looks simple enough. Why doesn't it work?
I found an example somewhere that showed how to use an xs:restriction but this does not appear to work:
<xs:simpleType name="string25"> <xs:restriction base="xs:normalizedString"> <xs:maxLength value="25"/> </xs:restriction></xs:simpleType><xs:element name="content_idx" type="string25" default="" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:appinfo> <alf:alert>Content ID is required</alf:alert> <alf:label>Content ID</alf:label> <alf:appearance>minimal</alf:appearance> </xs:appinfo> </xs:annotation></xs:element>
Looks simple enough. Why doesn't it work?
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 01:45 PM
i'll take a look at this - but the xforms processor should be validating the user entered string length against the schema and reporting it invalid if it's not valid. are you looking for more of a ui side change? do you want the textfield itself to be x chars long - because that's not implemented yet.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 02:45 PM
i don't really care, yet, about the size of the field on the form but i'm deploying the value to a database field VARCHAR(25) so I want to limit the input size of the field to 25 chars. How do I do that?
Thanks,
Thanks,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 03:07 PM
hmmm…. it looks like my xforms processor is not validating schema simple types rigorously. i'll see if there's a switch that needs turning on - but it's possible that all these restrictions need to be turned into xforms constraints in order to get this to work which would be rather annoying.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 03:57 PM
So am I doing the right thing by "subclassing" the xs:normalizedString this way? Is this a best practice? I'm having trouble finding good docs/tutorials on xsd, xforms to know. I just stumbled upon this solution.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 07:48 PM
maxLength or length restrictions are the way to go. in the next version these restrictions will be enforced by textfields at a minimum - and hopefully by the xforms processor if i can figure out how to get it to properly validate schema types consistently.
