XSD Interview Questions & Answers

5 avg. rating (100% score) - 1 votes

XSD Interview Questions

    1. Question 1. How You Define Attributes In Xml Schema?

      Answer :

      You have to note this in XML Schema all attributes are only declare as simple types element not as complex types. Because yes, Simple Elements has no attributes and attributes are only happen with Complex Elements. But key point is that in XML Schema always attribute declare as simple type itself.

      Syntax:

      <xs: attribute name="abc" type="xyz"/>

    2. Question 2. How You Use Schema Element In Xml Document?

      Answer :

      We can say that <schema> element is an root element in XML Schema.

      Now, I have given you syntax of an XML Schema.

      Syntax:

      <? xml version="1.0"?>

      <xs:schema>

      ....

      ....

      </xs: schema>

      Yes, Schema element can also contain attribute.

      Example:

      <? xml version="1.0"?>

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

      target Namespace="http://www.r4r.co.in"

      xmlns="http://www.r4r.co.in"

      elementFormDefault="qualified">

      ....

      ....

      </xs: schema>

    3. Question 3. How You Define Complex And Simple Type Of Element?

      Answer :

      In an XML Schema element are of two types.

      1. Complex Type Element
      2. Simple Type Element

      Complex Type Element: Complex Type Elements are elements those contain elements.

      Simple Type Element: Simple Type Elements are elements those don’t contain any other elements.

      I explain you complex and simple type of element with an example: 

      <? xml version="1.0"?>

      <note>

      <to>Abhi</to>

      <from>Sudhi</from>

      <heading>Birthday Wish</heading>

      <body>Happy Birthday Dear</body>

      </note>

      In the above example note element called as complex element because it contains elements(to, from, heading, body).And element to, from, heading and body called as Simple Type Element because it doesn't contain any other element.

    4. Question 4. Give An Example Shows Xml Document Has A Reference To An Xml Schema?

      Answer :

      This example show you how XML document has a reference to an XML Schema.

      Example:

      <?xml version="1.0"?>

      <note>

      xmlns="http://www.r4r.co.in"

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

      xsi:schemaLocation="http://www.r4r.co.in note.xsd">

      <to>Abhi</to>

      <from>Sudhi</from>

      <heading>Birthday Wish</heading>

      <body>Happy Birthday Dear</body>

      </note>

    5. Question 5. Why We Use Xml Schemas?

      Answer :

      I have given you some main reasons those made XML Schemas more powerful than DTD.

      1. Using XML Schemas we can describe permissible document content more easily.
      2. Using XML Schemas we can validate the rightness of data easily.
      3. Using XML Schemas we can work with data that comes from database more easily.
      4. Easy to switch data b/w different datatypes.
      5. Easy to define data formats and to made restrictions on data.

    6. Question 6. Explain Why Xml Schemas Are Estensible?

      Answer :

      Have given you some reasons that say XML Schemas are extensible. We can reuse our XML Schemas with in other XML Schemas. Also we can make our own data types which are derived from standard types. We can refer multiple schemas in a same XML document.

    7. Question 7. What Is Xml Schema?

      Answer :

      When we don't want to use DTD than we can use XML Schema as an alternative of DTD.Using XML Schema we can describe the structure of XML document. We can also call XML Schema language as XML Schema Definition.

      Some main of XML Schema are given below:

      1. We can define the child element among the elements.
      2. XML Schema also defines order and number of child element.
      3. Using XML Schema we can define data types, default and fixed values for attributes and elements.

      XML Schema has W3C Recommendation since 02 May 2001.

    8. Question 8. How You Define Elements Of Xml Document In An Xml Schema?

      Answer :

      Simple I give you a example of an XML document. Then I told you define elements of this XML document in an XML Schema.

      Example shows a XML Document.

      <? xml version="1.0"?>

      <note>

      <to>Abhi</to>

      <from>Sudhi</from>

      <heading>Birthday Wish</heading>

      <body>Happy Birthday Dear</body>

      </note>

      Now, I will show you how to define these elements(to, from, heading, body)of XML document(saved with "note.xml")in an XML Schema (saved with "note.xsd").

      <? xml version="1.0"?>

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

      target Namespace="http://www.r4r.co.in"

      xmlns="http://www.r4r.co.in"

      elementFormDefault="qualified">

      <xs:element name="note">

      <xs:complexType>

      <xs:sequence>

      <xs: element name="to" type="xs: string"/>

      <xs: element name="from" type="xs: string"/>

      <xs: element name="heading" type="xs: string"/>

      <xs: element name="body" type="xs: string"/>

      </xs: sequence>

      </xs: complexType>

      </xs: element>

      </xs: schema>

    9. Question 9. How You Set Default And Fixed Values For Attributes?

      Answer :

      Mean of default and fixed value in terms of attributes. 

      Default values are those values that are directly assigned to attribute when this attribute doesn't contain any other defined value.

      Example:

      <xs: attribute name="lang" type="xs: string" default="EN">

      In the above example default value of Lang is "EN".

      Fixed values are those values that are directly assigned to attribute but it doesn't contain any other defined value for this attribute.

      Example:

      <xs: attribute name="lang" type="xs: string" fixed="EN"/>

      In the above example fixed value of Lang is "EN".

    10. Question 10. How We Can Say Xml Schemas Are Successors Of Dtds?

      Answer :

      Because of some reasons we can say that XML Schemas area successors of DTDs.

      Some reasons are given below:

      1. As DTD, XML Schemas also written in XML.
      2. As DTD, XML Schemas also support Data types and namespaces.

      But, XML Schemas is much good as DTDs.Because it is much richer and powerful than DTDs.And it also has some features that are made to solve problems comes in future.

    11. Question 11. What Do You Mean By Simple Element?

      Answer :

      Have already told you XML Schema has defined elements in two types.

      1. Simple Element
      2. Complex Element

      Simple Element: In XML simple elements are that element that has contain only text doesn't contain any other elements or attributes.

      Text may be of any type that define in XML Schema

      Like Boolean, string, date etc.

      Syntax:

      <xs: element name="abc" type="xyz"/>

      Where, ABC is used to define name of element and xyz is used to define data type of element.


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

XSD Tutorial