Academic Tutorials



English | French | Portugese | Dutch | Italian
Google

em linha

Home Códigos de fonte E-Livros Downloads Contatar-nos Sobre nós

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


Limitações/Facets de XSD
Previous Next




As limitações são usadas definir o valor aceitável para elementos ou atributos de XML. As limitações em elementos de XML são chamadas facets.



Limitações em valores

O seguinte exemplo define um elemento chamado “idade” com uma limitação. O valor da idade não pode ser mais grande de 120 ou abaixar do que 0:

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




Limitações em um jogo dos valores

Para limitar o índice de elementos de XML a um jogo de valores aceitáveis, nós usaríamos o confinamente da enumeração.

O exemplo abaixo define um elemento chamado “carro” com uma limitação. Os únicos valores aceitáveis são: Audi, Golf, BMW:

<xs:element name="car">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

O exemplo acima poderia também ter sido escrito dentro como este:

<xs:element name="car" type="carType"/>
<xs:simpleType name="carType">
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>

Nota: No exemplo acima do tipo o “carType” pode ser usado por outros elementos porque não é uma parte do elemento do “carro”.

Limitações em uma série dos valores

Para limitar o índice de um elemento de XML para definir uma série das letras ou dos números que podem ser usados, nós usaríamos o confinamente do teste padrão.

O exemplo abaixo define um elemento chamado “letra” com uma limitação. O único valor aceitável é UMA da letra LOWERCASE de a a z:

<xs:element name="letter">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

O exemplo seguinte define um elemento chamado “iniciais” com uma limitação. O único valor aceitável é TRÊS da letra CAIXA de a a z:

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

O exemplo seguinte define também um elemento chamado “iniciais” com uma limitação. O único valor aceitável é TRÊS da letra LOWERCASE OU CAIXA de a a 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>

O exemplo seguinte define um elemento chamado “escolha” com uma limitação. O único valor aceitável é UMA da seguinte letra: x, y, OU z:

<xs:element name="choice">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[xyz]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

O exemplo seguinte define um elemento chamado “prodid” com uma limitação. O único valor aceitável é CINCO dígitos em uma seqüência, e cada dígito deve estar na escala de 0 a 9:

<xs:element name="prodid">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9][0-9][0-9][0-9][0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Limitações em caráteres de Whitespace

Para especificar como os caráteres do whitespace devem ser segurados, nós usaríamos os confinamentes do whiteSpace.

Este exemplo define um elemento chamado “endereço” com uma limitação. O confinamente do whiteSpace é ajustado ao “preserve”, que significa que o processador de XML não removerá nenhum caráter de espaço branco

<xs:element name="address">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Este exemplo define também um elemento chamado “endereço” com uma limitação. O confinamente do whiteSpace é ajustado a “substitui”, que significam que o processador de XML SUBSTITUIRÁ todos os caráteres de espaço brancos (LINE FEED, abas, espaços, e retornos do carro) com os espaços:

<xs:element name="address">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="replace"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Este exemplo define também um elemento chamado “endereço” com uma limitação. O confinamente do whiteSpace é ajustado ao “colapso”, que significa que o processador de XML REMOVERÁ todo o caráter de espaço branco (LINE FEED, abas, espaços, os retornos do carro são substituídos com os espaços, os espaços conduzindo e arrastando são removidos, e os espaços múltiplos são reduzidos ao único espaço):

<xs:element name="address">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Limitações no comprimento

Para limitar dentro o comprimento de um valor a um elemento, nós usaríamos o comprimento, o maxLength, e os confinamentes do minLength.

Este exemplo define um elemento chamado “senha” com uma limitação. O valor deve ser exatamente oito caráteres:

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

Este exemplo define um outro elemento chamado “senha” com uma limitação. O valor deve ser oito caráteres máximos e caráteres do mínimo cinco:

<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>
Limitações para Datatypes
Constraint Description
enumeration Defines a list of acceptable values
fractionDigits Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero
length Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero
maxExclusive Specifies the upper bounds for numeric values (the value must be less than this value)
maxInclusive Specifies the upper bounds for numeric values (the value must be less than or equal to this value)
maxLength Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero
minExclusive Specifies the lower bounds for numeric values (the value must be greater than this value)
minInclusive Specifies the lower bounds for numeric values (the value must be greater than or equal to this value)
minLength Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero
pattern Defines the exact sequence of characters that are acceptable
totalDigits Specifies the exact number of digits allowed. Must be greater than zero
whiteSpace Specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled




Previous Next

Keywords: XSD restrictions/facets,web service xsd,xsd tutorial,xsd xml,xsd examples,xsd dtd,xsd validator,xslt xsd,sample xsd


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.