Hub Nexus
著者著者はまだいません引き受ける

改善できるところがありますか?変更を提案しましょう。

支援

マガジン XForms · 137 ページ中 105 ページ目

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.

このページを含むマガジンXForms

言語English

ライセンス: CC BY-SA 4.0 · 出典 en.wikibooks.org

1

0

0

0

Spinner Logo

コメント

Spinner Logo
バージョン: 2CC0 1.0 — public domain
The runaway star that left the Tarantula Nebula
バージョン: 2CC0 1.0 — public domain
The Blackwell School, where segregation had no law behind it
バージョン: 2CC0 1.0 — public domain
The Eagle Nebula, seen in the infrared
バージョン: 2CC0 1.0 — public domain
The house where the Equal Rights Amendment was written
バージョン: 2CC0 1.0 — public domain
The Aleutians, the forgotten front of the Second World War
バージョン: 2CC0 1.0 — public domain
The Cosmic Cliffs are not cliffs