xml schemas

Post on 12-May-2015

1.005 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

XML Schemas Lanaguage

TRANSCRIPT

<?xml version=„1.0‟ encoding=“UTF-8”?>

<!-- Human Resource data-->

<HumanResource>

<!-- Information for a person-->

<Person id=„1‟ slary=“500”>

<FirstName>John</FirstName>

<MidName></MidName>

<LastName>Doe</LastName>

<Position>Manager</Position>

</Person>

</HumanResource>

Document Type

<?xml version=”1.0”?>

<name>

<first>

John

</first>

<middle>

Johansen

</middle>

<last>

Doe

</last>

</name>

<?xml version=”1.0”?><schema xmlns=”http://www.w3.org/2001/XMLSchema”

xmlns:target=”http://www.exam.com/name”

targetNamespace=”http://www.exam.com/name”

elementFormDefault=”qualified”>

<element name=”name”>

<complexType>

<sequence>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</sequence>

</complexType>

</element>

</schema>

<rootElement

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=“list of namespace-location pairs”

>

</rootElement>

<rootElement

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”

xsi:noNamespaceSchemaLocation=“location”

>

</rootElement>

<?xml version=”1.0”?>

<name>

<first>

John

</first>

<middle>

Johansen

</middle>

<last>

Doe

</last>

</name>

<?xml version=”1.0”?><schema xmlns=”http://www.w3.org/2001/XMLSchema”

xmlns:target=”http://www.exam.com/name”

targetNamespace=”http://www.exam.com/name”

elementFormDefault=”qualified”>

<element name=”name”>

<complexType>

<sequence>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</sequence>

</complexType>

</element>

</schema>

<schema

targetNamespace=“URI”

attributeFormDefault=“qualified or unqualified”

elementFormDefault=“qualified or unqualified”

version=“version number”>

</schema>

<schema xmlns=”http://www.w3.org/2001/XMLSchema”>

<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>

<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>

<element

name=”name of the element”

type=”global type”

ref=”global element declaration”

form=”qualified or unqualified”

minOccurs=”non negative number”

maxOccurs=”non negative number or „unbounded‟”

default=”default value”

fixed=”fixed value”>

<element

name=”name of the element”

type=”global type”

ref=”global element declaration”

form=”qualified or unqualified”

minOccurs=”non negative number”

maxOccurs=”non negative number or „unbounded‟”

default=”default value”

fixed=”fixed value”>

birthday=“02-10-2011”

<phone>043678002</phone>

<simpleType

name=”name of the simpleType”

final=”#all or list or union or restriction”>

<restriction

base=”name of the simpleType you are deriving from”>

Facet Description

minExclusive Allows you to specify the minimum value for your type that excludes the value you specify

minInclusive Allows you to specify the minimum value for your type that includes the value you specify

maxExclusive Allows you to specify the maximum value for your type that excludes the value you specify

maxInclusive Allows you to specify the maximum value for your type that includes the value you specify

totalDigits Allows you to specify the total number of digits in a numeric type

fractionDigits Allows you to specify the number of fractional digits in a numeric type

length Allows you to specify the number of items in a list type or the number of characters in a string type

minLength Allows you to specify the minimum number of items in a list type or the minimum number of

characters in a string type

maxLength Allows you to specify the maximum number of items in a list type or the maximum number of

characters in a string type

enumeration Allows you to specify an allowable value in an enumerated list

whitespace Allows you to specify how whitespace should be treated within the type

pattern Allows you to restrict string types using regular expressions

<simpleType name="myIntegerType">

<restriction base="integer">

<minInclusive value="10000"/>

<maxInclusive value="99999"/>

</restriction>

</simpleType>

<simpleType

name="stockKeepingUnitType">

<restriction base="string">

<pattern value="\d{3}-[A-Z]{2}"/>

</restriction>

</simpleType>

<simpleType name=“phoneType”>

<restriction base=”string”>

<enumeration value=”Home”/>

<enumeration value=”Work”/>

<enumeration value=”Cell”/>

<enumeration value=”Fax”/>

</restriction>

</simpleType>

<list

itemType=”name of simpleType used for validating items in the list”>

<simpleType name=”phoneListType”>

<list itemType=”exam:phoneType”/>

</simpleType>

<union

memberTypes=”whitespace separated list of types”>

<simpleType name=”UnknownString”>

<restriction base=”string”>

<enumeration value=”Unknown”/>

</restriction>

</simpleType>

<simpleType name=”UnknownOrFloatType”>

<union memberTypes=”float exam:UnknownString”/>

</simpleType>

content model

attribute list

<phone>043678002</phone>

<element name=”name”>

<complexType>

<sequence>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</sequence>

<attribute name=”title” type=”string”/>

</complexType>

</element>

<sequence>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</sequence>

<!ELEMENT name (first, middle, last)>

<choice>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</choice>

<!ELEMENT name (first| middle| last)>

<group name=”NameGroup”>

<sequence>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</sequence>

</group>

<element name=”name”>

<complexType>

<group ref=”target:NameGroup”/>

<attribute name=”title” type=”string”/>

</complexType>

</element>

<complexType name="mixedType" mixed="true">

<choice maxOccurs="unbounded" minOccurs="0">

<element name=“b" type="string"/>

<element name="i" type="string"/>

<element name="u" type="string"/>

</choice>

<attribute ref="class"/>

</complexType>

<!ELEMENT description (#PCDATA | b | i | u)*>

<element name=“br”>

<complexType>

<attribute name=”title” type=”string”/>

<complexType>

</element>

<!ELEMENT br EMPTY>

<all>

<element name=”first” type=”string”/>

<element name=”middle” type=”string”/>

<element name=”last” type=”string”/>

</all>

<attribute

name=”name of the attribute”

type=”global type”

ref=”global attribute declaration”

form=”qualified or unqualified”

use=”optional or prohibited or required”

default=”default value”

fixed=”fixed value”>

<attribute name=”title”>

<simpleType>

<!-- type information -->

</simpleType>

</attribute>

<attribute name=”title” type=”string”/>

<attributeGroup name=”ContactsAttributes”>

<!-- attribute declarations go here -->

</attributeGroup>

attributGroups may not recursively refer to themselves

<attributeGroup name=”AttGroup1”>

<attributeGroup ref=”target:AttGroup1”/>

</attributeGroup >

<attributeGroup name=”AttGroup1”>

<attributeGroup ref=”target:AttGroup2”/>

</attributeGroup >

<attributeGroup name=”AttGroup2”>

<attributeGroup ref=”target:AttGroup1”/>

</attributeGroup >

<import

namespace=””

schemaLocation=””>

<import

namespace=”http://www.example.com/name”

schemaLocation=”name8.xsd”/>

<include

schemaLocation=””>

<include

schemaLocation=”contact_tags.xsd”/>

top related