XSD interview questions
- 1) What is XSD?
- 2) Explain the benifits of using XSD?
- 3) How attribute is different from a element in XSD?
- 4) Enlist different data types avaialable in XSD?
- 5) How do you restrict an element in XSD?
- 6) For What is the XSD file used?
- 7) What is difference between XML and XSD?
- 8) Explain what is DTD?
- 9) What is xsd header?
Below are the list of Best XSD Interview Questions and Answers
XSD (XML Schema Definition) is a language definition that defines how to describe the elements in the Extensible Markup Language (XML). This definition is a recommendation of the World Wide Web Consortium that can be used by the programmers to verify each piece of the content in the XML document. XSD defines a set of instructions to which an XML document must follow in order to be considered a valid document.
XSD is also used for generating XML documents that are treated as programming objects.
The advantages of using XSD over other schema languages are,
- XSD is extensible. That is, You can use XSD to derive new elements from the existing elements.
- XSD doesn’t require intermediate processing by the parser as it is not defined in XML.
- XSD supports default values, and you can specify the default values of the elements using XSD.
- With XSD, you can import more than one XML schema on another XML schema. It supports reference to external XML schemas.
- XSD supports data types, and you can restrict the content of the element using the data types.
Element in XSD is nothing but an XML element such as opening tag, content, closing tag, etc. XSD Elements are the building blocks of your XML document. Elements are defined by their occurrence. An element can have sub-elements inside them. XSD elements can be of simpleType, complexType, or anyType.
The attribute in XSD is extra information about the element. The attribute is always a simpleType and has a fixed or default value. An element cannot have multiple attributes of the same name tag.
//example <test id="5">somevalue</test>
Here, the test is an XSD element and ‘id’ is an attribute of the element.
There are two data types available in XSD.
They are simpleType and complexType.
- simpleType - These are the built-in datatype present in XSD. There are many types available in ti. They are xsd:integer, xsd:float, xsd:double, xsd:decimal, xsd:string, xsd:binary, xsd:date, xsd:datetime, xsd:boolean. The xsd:integer and xsd:string has many different types present like, long, short, byte, unsignedByte, unsignedInt, etc for xsd:integer and token, language, Name, ID, time, normalizesString, etc for xsd:string.
- complexType - This definition contains a set of element declarations, references, and attribute declarations. You have to define the element and the attribute of the complex type. It can either be named type or anonymous type.
The restriction element in the XSD is used to define restrictions on the simpleType, simple content, or complex content definition.
//syntax <xs:restriction base = "element-type"> restrictions </xs:restriction>
Here, the base defines the type of the element on which the restriction is to be applied. The restrictions are the range of conditions that is to be applied to the element.
//example <xs:element name = "marks"> <xs:simpleType> <xs:restriction base = "xs:integer"> <xs:minInclusive value = "0"/> <xs:maxInclusive value = "100"/> </xs:restriction> </xs:simpleType> </xs:element>
Now, we apply the restriction to the marks element. The restriction is that the value of the mark should be between 0 and 100.
XSD file is used to define the elements and the attributes that appear in the XML document. It is used to validate the XML files in a certain format. An XSD file stores contents as a text in XML format. That is, it is written in the W3C XML Schema language.
The Difference between XML and XSD
XML (Extensible Markup Language) is a markup language that is used to create a document that is readable by both the human and the computer. It offers a flexible method to create and share data. It was developed by W3C to easily covert and share data between different incompatible systems.
XSD (XML Schema Definition) is used to define the structure and the content for the XML document. It is used to check and validate the structure and the content of the XML file. It has more advantages over DTD as it is extensible, simple, and provides more control over the structure.
DTD (Document Type Definition) is a set of markup declarations that defines the structure, elements and the attribute of the XML document. DTD provides a standard for interchanging data using XML. It is also used to verify that the XML data is valid or not. A DTD can be declared inline inside the XML document or it can be declared as an outside reference as well.
An XSD Header contains the version of the XML used and the. It is written at the top of every XML document. A schema element can contain additional attributes such as namespace, etc.
//syntax for XSD Header. <?xml version="1.0"?> <xs:schema> ... ... </xs:schema>
Latest Interview Questions
Splunk Interview Questions
Fedora Interview Questions
TestNG Interview Questions
Laravel Interview Questions
Swift Interview Questions
CSS interview questions
React Native Interview questions
Hibernate Interview Questions
MVC interview questions
C++ Interview Questions
Data Warehousing Interview Questions
Terraform Interview Questions
Elixir Interview Questions
UX Designer Interview Questions
Angularjs unit testing interview questions
Cordova Interview Questions
XHTML Interview Questions
XPath Interview Questions
Marionette js Interview Questions
Less.js Interview Questions
Handlebars js Interview Questions
Oracle Interview Questions
Sap lumira Interview Questions
SAP HANA Interview Questions
Backbone js Interview Questions
Ajax Interview Questions
ASP.NET Interview Questions
Appcelerator Interview Questions
Apex Interview Questions
Subscribe Our NewsLetter
Never Miss an Articles from us.