Esercitazione XML

XML CASA Introduzione XML XML Come usare Albero XML Sintassi XML Elementi XML Attributi XML Spazi dei nomi XML Visualizzazione XML Richiesta HTTP XML Analizzatore XML XML DOM XPath XML XML XSLT XQuery XML XML XLink Validatore XML DTD XML Schema XML Server XML Esempi XML Quiz XML Certificato XML

XML AJAX

Introduzione AJAX AJAX XMLHttp Richiesta AJAX Risposta dell'AJAX File XML AJAX AJAX PHP AJAX ASP Database AJAX Applicazioni AJAX Esempi AJAX

XML DOM

DOM Introduzione Nodi DOM Accesso DOM Informazioni sul nodo DOM Elenco dei nodi DOM DOM attraversando Navigazione DOM DOM Ottieni valori Nodi di modifica DOM DOM Rimuovere i nodi DOM Sostituisci nodi DOM Crea nodi DOM Aggiungi nodi Clonazione dei nodi DOM Esempi DOM

Esercitazione XPath

Introduzione a XPath Nodi XPath Sintassi XPath Assi XPath Operatori XPath Esempi di XPath

Esercitazione XSLT

Introduzione a XSLT Lingue XSL Trasformazione XSLT XSLT <modello> XSLT <valore-di> XSLT <per-ciascuno> XSLT <ordina> XSLT <se> XSLT <scegli> Applicare XSLT XSLT sul Cliente XSLT sul server XSLT Modifica XML Esempi XSLT

Esercitazione XQuery

Introduzione a XQuery Esempio XQuery XQuery FLWOR XQuery HTML Termini di XQuery Sintassi XQuery Aggiungi XQuery XQuery Seleziona Funzioni XQuery

DTD XML

Introduzione alla DTD Blocchi di costruzione DTD Elementi DTD Attributi DTD Elementi DTD vs Attr Entità DTD Esempi di DTD

Schema XSD

Introduzione all'XSD XSD Come fare per XSD <schema> Elementi XSD Attributi XSD Restrizioni XSD

Complesso XSD

Elementi XSD XSD vuoto Solo elementi XSD Solo testo XSD XSD misto Indicatori XSD XSD <qualsiasi> XSD <qualsiasi attributo> Sostituzione XSD Esempio XSD

Dati XSD

Stringa XSD Data XSD Numerico XSD XSD Varie Riferimento XSD

Servizi Web

Servizi XML XML WSDL SAPONE XML XML RDF RSS XML

Riferimenti

Tipi di nodi DOM Nodo DOM Elenco nodi DOM DOM NamedNodeMap Documento DOM Elemento DOM Attributo DOM Testo DOM DOM CDATA Commento DOM DOM XMLHttpRichiesta Analizzatore DOM Elementi XSLT Funzioni XSLT/XPath

Elemento di restrizione dello schema XML


❮ Riferimento completo allo schema XML

Definizione e utilizzo

L'elemento di restrizione definisce le restrizioni su una definizione simpleType, simpleContent o complexContent.

Informazioni sull'elemento

  • Elementi principali: simpleType, simpleContent, complexContent

Sintassi

<restriction
id=ID
base=QName
any attributes
>

Content for simpleType:
(annotation?,(simpleType?,(minExclusive|minInclusive|
maxExclusive|maxInclusive|totalDigits|fractionDigits|
length|minLength|maxLength|enumeration|whiteSpace|pattern)*))

Content for simpleContent:
(annotation?,(simpleType?,(minExclusive |minInclusive|
maxExclusive|maxInclusive|totalDigits|fractionDigits|
length|minLength|maxLength|enumeration|whiteSpace|pattern)*)?,
((attribute|attributeGroup)*,anyAttribute?))

Content for complexContent:
(annotation?,(group|all|choice|sequence)?,
((attribute|attributeGroup)*,anyAttribute?))

</restriction>

(Il segno ? dichiara che l'elemento può verificarsi zero o una volta all'interno dell'elemento di restrizione)

Attribute Description
id Optional. Specifies a unique ID for the element
base

Required. Specifies the name of a built-in data type, simpleType element, or complexType element defined in this schema or another schema

any attributes Optional. Specifies any other attributes with non-schema namespace

Esempio 1

Questo esempio definisce un elemento chiamato "età" con una restrizione. Il valore dell'età NON può essere inferiore a 0 o maggiore di 100:

<xs:element name="age">
  <xs:simpleType>
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="0"/>
      <xs:maxInclusive value="100"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

Esempio 2

Questo esempio definisce anche un elemento chiamato "initials". L'elemento "initials" è un tipo semplice con una restrizione. L'unico valore accettabile è TRE delle lettere MAIUSCOLE O MAIUSCOLE dalla a alla z:

<xs:element name="initials">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:pattern value="[a-zA-Z][a-zA-Z][a-zA-Z]"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

Esempio 3

Questo esempio definisce un elemento chiamato "password". L'elemento "password" è un tipo semplice con una restrizione. Il valore deve essere minimo cinque caratteri e massimo otto caratteri:

<xs:element name="password">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:minLength value="5"/>
      <xs:maxLength value="8"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

Esempio 4

Questo esempio mostra una definizione di tipo complessa che utilizza la restrizione. Il tipo complesso "Norwegian_customer" deriva da un tipo complesso cliente generale e il relativo elemento paese è fissato a "Norvegia":

<xs:complexType name="customer">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
    <xs:element name="country" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="Norwegian_customer">
  <xs:complexContent>
    <xs:restriction base="customer">
      <xs:sequence>
        <xs:element name="firstname" type="xs:string"/>
        <xs:element name="lastname" type="xs:string"/>
        <xs:element name="country" type="xs:string" fixed="Norway"/>
      </xs:sequence>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>

❮ Riferimento completo allo schema XML