Vedi qualcosa da migliorare? Proponi una modifica.
In XForms · pagina 105 di 137
Motivation
You would like to use a library of XML Schema simple types with restrictions to validate your form.
Notice
Most type validation with the exception of the most simple types does not currently work under the FireFox extension.
Sample Program sample.xhtml
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ftype="http://www.example.com/my-file-types">
Validate Postal Codes
type="text/css">
@namespace xf url("http://www.w3.org/2002/xforms");
xf|input {
display: table-row;
line-height: 2em;
}
xf|label {
display: table-cell;
text-align: right;
font-family: Arial, Helvetica, sans-serif;;
font-weight: bold;
padding-right: 5px;
width: 150px;
}
*:required {
background-color: yellow;
}
*:invalid {
background-color: pink;
}
schema="schema.xsd">
src="instance.xml" />
id="zip" required="true()" type="ftype:zipType" nodeset="ftype:zip" />
id="zip2" required="true()" type="ftype:zip2Type" nodeset="ftype:zip2" />
bind="zip" incremental="true">
Zip Code:
Validation is not correctly specified for this field
The 'Zip Code' failed to validate!
bind="zip2" incremental="true">
Zip Code 2:
Validation is correctly specified for this field
value="concat('The "', name(), '" failed to validate!')" />
Example XML Schema File schema.xsd
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ftype="http://www.example.com/my-file-types"
targetNamespace="http://www.example.com/my-file-types"
elementFormDefault="qualified" attributeFormDefault="unqualified">
name="data">
Test XML Schema
name="zip" type="ftype:zipType"/>
name="zipType">
base="xs:string">
value="\d{5}"/>
name="zip2Type">
base="xs:string">
value="^\d{5}$"/>
Sample instance document instance.xml
xmlns="http://www.example.com/my-file-types">
12345
12345
Where this page came from
This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.
Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.
In queste pubblicazioniXForms
Licenza: CC BY-SA 4.0 · Tratto da en.wikibooks.org
1
0
0
0

Commenti






