Question

1. Write an XML Schema for the following XML file satisfying the following requirements: a) comment...


1. Write an XML Schema for the following XML file satisfying the following requirements: a) comment element is required; b) publisher element should be of xsd:string type; c) price elements should be of xsd:float type. Validate the xml file against your XML Schema using the online validator: http://tools.decisionsoft.com/schemaValidate/.
<?xml version="1.0"?>
<bib>
​<comment>These books are still relevant </comment>
​<book year="1994">
​​<title>TCP/IP Illustrated</title>
​​<author>
​​​<last>Stevens</last>
​​​<first>Tim</first>
​​</author>
​​<publisher>Addison-Wesley</publisher>
​​<price discount="yes"> 65.95</price>
​</book>
​<book year="2003">
​​<title>Learning XML</title>
​​<author>
​​​<last>Erik</last>
​​​<middle >T</middle >
​​​<first>Ray</first>
​​</author>
​​<publisher>O'Reilly</publisher>
​​<price discount="yes">55.95</price>
​</book>
​<book year="2000">
​​<title>Data on the Web</title>
​​<author>
​​​<last>Abiteboul</last>
​​​<first>Serge</first>
​​</author>
​​<author>
​​​<last>Suciu</last>
​​​<first>Dan</first>
​​</author>
​​<publisher>Morgan Kaufmann</publisher>
​​<price discount="yes"> 39.95</price>
​</book>
</bib>
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi There!!

Please find the XSD below. I have validated the schema from the mentioned website.Also, have made sure comments are mandatory ,element publisher is xsd:string and element price is xsd:float.

book.xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="bib">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element type="xs:string" name="comment" minOccurs="1"/>
<xs:element name="book" maxOccurs="unbounded" minOccurs="0">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element type="xs:string" name="title"/>
<xs:element name="author" maxOccurs="unbounded" minOccurs="0">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element type="xs:string" name="last"/>
<xs:element type="xs:string" name="middle" minOccurs="0"/>
<xs:element type="xs:string" name="first"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element type="xs:string" name="publisher"/>
<xs:element name="price">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:float">
<xs:attribute type="xs:string" name="discount" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:short" name="year" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks!!Cheers!!Happy Chegging!!

Add a comment
Know the answer?
Add Answer to:
1. Write an XML Schema for the following XML file satisfying the following requirements: a) comment...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this xml! 1. Write an XML Schema for the following XML file...

    I need help with this xml! 1. Write an XML Schema for the following XML file and validate the xml file against your XML Schema using the online validator: http://tools.decisionsoft.com/schema Validatel. <?xml version="1.0" KEmployees> ?> <Employee KSSN> 737333999</SSN> Name>Christo Dichev</Name> <DateofBirth>1950-03 03</DateOfBirth> <EmployeeType> FULLTIME</ Employee ype> <Salary>7000</Salary> </Employee> Employee> KSSN> 737333333</SSN> <Name> Paul Fisher</Name> <DateOfBirth>1960-01- 01</DateOfBirth> <EmployeeType> FULLTIME</EmployeeT ype> <Salary> 6000</Salary> </Employee> </Employees>

  • Q.4. Considering the XML Schema shown below, answer the following questions: a) Write an XML document...

    Q.4. Considering the XML Schema shown below, answer the following questions: a) Write an XML document that conforms to the rules of the xml schema given below. Add atleast two book elements.                                  b) Modify the XML schema to add an attribute “id” to the book element which is of the type string and is a mandatory.                                                                c) In the XML schema, change the definition of the element “price” such that value of price cannot be lower than 10...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT