InterviewSolution
| 1. |
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> 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> |
|