XSD Example

A schema can be written in different ways. An XML Document: employee.xml: Jonas Javis IT 22 B Road Banglore India Software Developer Well Experienced 10 10 Team Manager Leader 5 9 Explanation: In the above XML document, the root element, “employee” contains a required attribute called “employeeid”. There are three different child elements: “name”, “department” … Read more

Categories XSD

XSD Numeric Data Types

For the numeric values, the decimal data types are used. XML Schema built-in data types: The most common built-in data types of an XML Schema are: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time Decimal Data Type: To specify a numeric value, we can use the decimal data type. Example: Decimal declaration in a schema: An element … Read more

Categories XSD

XSD Date and Time Data Types

For values containing date and time, the date and time data types are used. Date Data Type: To specify a date, the date data type is used. It is specified in the “YYYY-MM-DD” format and where all components are required. Here, YYYY: Used to indicate the year. MM: Used to indicate the month. DD: Used to indicate the … Read more

Categories XSD

XSD String Data Types

For the values containing the character strings, the string data types are used. XSD Example: String Data Type: The characters, line feeds, carriage returns, and tab characters are included in the string data type. On using the string data type, the XML processor will not modify the value. Example: String declaration in a schema: An … Read more

Categories XSD

XSD Element Substitution

For one element to substitute another element, we can use the XML Schemas. Element Substitution: We can have users from different countries, let’s say, the USA and Italy. Now, to let the user choose either to use the Italian element names or the English element names in the XML document, we could define a substitutionGroup … Read more

Categories XSD

XSD anyAttribute Element

To extend the XML document with attributes not specified by the schema, the <anyAttribute> element is used. The <anyAttribute> Element: To make EXTENSIBLE documents, i.e., to allow documents to contain additional elements that are not declared in the main XML schema, the <any> and <anyAttribute> elements are used. Example: Explanation: In the above example, we … Read more

Categories XSD

XSD any Element

To extend the XML document with elements not specified by the schema, the <any> element is used. The <any> Element: To make EXTENSIBLE documents, i.e., to allow documents to contain additional elements that are not declared in the main XML schema, the <any> and <anyAttribute> elements are used. Example: Explanation: In the above example, we … Read more

Categories XSD

XSD Indicators

The way elements are to be used in documents with indicators can be controlled. Indicators: In XSD, there are seven indicators: Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators: Group name attributeGroup name Order Indicators: To define the order of the elements, the order indicators are used. The default value for maxOccurs … Read more

Categories XSD

XSD Mixed Content

The attributes, elements, and text can be included in a mixed complex type element. Complex Types with Mixed Content: Example: Dear Ms. Vigesa. You ranked 10 in the exam conducted on 2020-06-10. Schema: Explanation: In the above example, we are defining an XML element, “letter”, that contains both text and other elements. We have also … Read more

Categories XSD

XSD Text-Only Elements

Both text and attributes can be included in a complex text-only element. Complex Text-Only Elements: We can add a simpleContent element around the content because the complex text-only element contains only simple content (text and attributes). We need to define an extension or a restriction within the simpleContent element while using simple content. Syntax 1: … Read more

Categories XSD