0% found this document useful (0 votes)
68 views7 pages

XML Schema - English

1) XML schemas are used to define and describe the structure and elements of an XML document. Schemas specify elements, attributes, relationships between elements, and data types. 2) Namespaces are used in XML schemas to avoid naming conflicts between elements. Namespaces are declared using prefixes or by setting a default namespace for an element. 3) Restrictions in XML schemas define constraints or patterns for elements, such as limiting values to a certain data type, range of numbers, or format.

Uploaded by

RalphRogoz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views7 pages

XML Schema - English

1) XML schemas are used to define and describe the structure and elements of an XML document. Schemas specify elements, attributes, relationships between elements, and data types. 2) Namespaces are used in XML schemas to avoid naming conflicts between elements. Namespaces are declared using prefixes or by setting a default namespace for an element. 3) Restrictions in XML schemas define constraints or patterns for elements, such as limiting values to a certain data type, range of numbers, or format.

Uploaded by

RalphRogoz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

1.) Allow to avoid disputes for XML element names. 2.

) One can avoid name conflicts using prefixes. <h ta!le" <h tr" <h td"Apples<#h td" <h td"$ananas<#h td" <#h tr" <#h ta!le" <f ta!le" <f name"African %offee &a!le<#f name" <f width"'(<#f width" <f length"12(<#f length" <#f ta!le" ).) *hould !e set namespaces +namespace) for prefixes used !, the xmlns attri!ute. a.) &he child elements that use the same prefix inherit mem!ership in the namespace <root" <h ta!le xmlns h-.http ##www.w).org#&/#html0#." <h tr" <h td"Apples<#h td" <h td"$ananas<#h td" <#h tr" <#h ta!le" <f ta!le xmlns f-.http ##www.w)schools.com#furniture." <f name"African %offee &a!le<#f name" <f width"'(<#f width" <f length"12(<#f length" <#f ta!le" <#root" !.) &he namespace can also !e declared on the root element. <root xmlns h-.http ##www.w).org#&/#html0#. xmlns f-.http ##www.w)schools.com#furniture." <h ta!le" <h tr" <h td"Apples<#h td" <h td"$ananas<#h td" <#h tr" <#h ta!le" <f ta!le" <f name"African %offee &a!le<#f name" <f width"'(<#f width" <f length"12(<#f length" <#f ta!le" <#root"

c.) One can also set a default namespace for an element1 there!, avoiding the use of prefixes. <ta!le xmlns-.http ##www.w).org#&/#html0#. " <tr" <td"Apples<#td" <td"$ananas<#td" <#tr" <#ta!le" <ta!le xmlns-.http ##www.w)schools.com#furniture." <name"African %offee &a!le<#name" <width"'(<#width" <length"12(<#length" <#ta!le" XML Schema XML *chema - XML *chema 2efinition +X*2). &he XML schema descri!es the structure of an XML document1 an alternative to 2&2. *ets 3 &he elements that can appear in a document. 3 &he attri!utes that can appear in a document. 3 4hat are the child elements1 their num!er and order. 3 5f an element is empt, or can include text. 3 2ata t,pes for elements and attri!utes. 3 &he default and fixed values for elements and attri!utes. Advantages of *chemas 3*upport data t,pes 3*upport data t,pes 3Are extensi!le 3 A *chema definition can !e used in other *chemas. 3 6ou can create new data t,pes from standard t,pes. 3 %an !e referenced multiple *chema from the same document. $uilding a *chema 3&he <schema" element is the root element of an, XML *chema <7xml version-.1.(.7" <xs schema xmlns xs-.http ##www.w).org#2((1#XML*chema." ... ... <#xs schema" &he elements and data t,pes used in the schema definition are from the namespace .http ##www.w).org#2((1#XML*chema. and should have the prefix xs.

2efaults and 8ixed 32efault values are assigned when no other values were specified <xs:element name="color" type="xs:string" default="red"/> 34hen a value is declared as fixed1 can not !e declared other values <xs element name-.color. t,pe-.xs string. fixed-.red.#" X*2 attri!utes 3Attri!utes are declared as simple elements. <xs:attribute name="xxx" type="yyy"/> &he code schema can !e a file called note.xsd <7xml version-.1.(.7" <xs schema xmlns xs-.http ##www.w).org#2((1#XML*chema." <xs element name-.note." <xs complex&,pe" <xs se9uence" <xs element name-.to. t,pe-.xs string.#" <xs element name-.from. t,pe-.xs string.#" <xs element name-.heading. t,pe-.xs string.#" <xs element name-.!od,. t,pe-.xs string.#" <#xs se9uence" <#xs complex&,pe" <#xs element" <#xs schema" /estrictions # 8acets X*2 3&he statement of the names and attri!utes of simple elements ma, contain restrictions <xs element name-.age." <xs simple&,pe" <xs restriction !ase-.xs integer." <xs min5nclusive value-.(.#" <xs max5nclusive value-.12(.#" <#xs restriction" <#xs simple&,pe" <#xs element" &he element name .age. is defined as a constraint its value can not !e smaller than ( or greater than 12(.

/estrictions on *et :alues a.) %an onl, !e used a lowercase letter <xs element name-.letter." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.;a3<=.#" <#xs restriction" <#xs simple&,pe" <#xs element" !.) %an onl, !e used three capital letters <xs element name-.initials." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.;A3>=;A3>=;A3>=.#" <#xs restriction" <#xs simple&,pe" <#xs element" c.) %an onl, !e used three lowercase or uppercase <xs element name-.initials." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.;a3<A3>=;a3<A3>=;a3<A3>=.#" <#xs restriction" <#xs simple&,pe" <#xs element" d.) One can use the letter x1 , or < <xs element name-.choice." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.;x,<=.#" <#xs restriction" <#xs simple&,pe" <#xs element" e.) Are onl, accepted ? digits +( through @) followed <xs element name-.prodid." <xs simple&,pe" <xs restriction !ase-.xs integer." <xs pattern value-.;(3@=;(3@=;(3@=;(3@=;(3@=.#" <#xs restriction" <#xs simple&,pe" <#xs element"

f.) Accepted ( or more lowercase letters <xs element name-.letter." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.+;a3<=)A.#" <#xs restriction" <#xs simple&,pe" <#xs element" g.) Are accepted one or more pairs of letters in each pair !egin with a lowercase letter and end with an uppercase <xs element name-.letter." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.+;a3<=;A3>=)B.#" <#xs restriction" <#xs simple&,pe" <#xs element" h.) Accepted values are .male. or .female. <xs element name-.letter." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.maleCfemale.#" <#xs restriction" <#xs simple&,pe" <#xs element" i.) Accepted exactl, ' characters1 which can !e lowercase1 uppercase1 or digits !etween ( and @ <xs element name-.letter." <xs simple&,pe" <xs restriction !ase-.xs string." <xs pattern value-.;a3<A3>(3@=D'E.#" <#xs restriction" <#xs simple&,pe" <#xs element"

/estrictions on 4hite *paces a.) &he XML processor must not remove the white space characters <xs element name-.address." <xs simple&,pe" <xs restriction !ase-.xs string." <xs white*pace value-.preserve.#" <#xs restriction" <#xs simple&,pe" <#xs element" !.) &he XML processor will replace all white space characters +enter1 spaces1 ta!s1 .line feeds.) !, spaces <xs element name-.address." <xs simple&,pe" <xs restriction !ase-.xs string." <xs white*pace value-.replace.#" <#xs restriction" <#xs simple&,pe" <#xs element" /estrictions for 2ata &,pes %onstraint Fnumeration fraction2igits length maxFxclusive max5nclusive maxLength minFxclusive min5nclusive minLength pattern total2igits white*pace 2escription 2efines a list of accepta!le values *pecifies the maximum num!er of decimal places allowed. Must !e e9ual to or greater than <ero *pecifies the exact num!er of characters or list items allowed. Must !e e9ual to or greater than <ero *pecifies the upper !ounds for numeric values +the value must !e less than this value) *pecifies the upper !ounds for numeric values +the value must !e less than or e9ual to this value) *pecifies the maximum num!er of characters or list items allowed. Must !e e9ual to or greater than <ero *pecifies the lower !ounds for numeric values +the value must !e greater than this value) *pecifies the lower !ounds for numeric values +the value must !e greater than or e9ual to this value) *pecifies the minimum num!er of characters or list items allowed. Must !e e9ual to or greater than <ero 2efines the exact se9uence of characters that are accepta!le *pecifies the exact num!er of digits allowed. Must !e greater than <ero1 *pecifies how white space +line feeds1 ta!s1 spaces1 and carriage returns) is handled

)0

You might also like