Question

I need an xml schema code for this xml file ASAP. Thanks <?xml version="1.0" encoding="UTF-8" ?>...

I need an xml schema code for this xml file ASAP. Thanks

<?xml version="1.0" encoding="UTF-8" ?>

<!-- file name: library.xml -->



<library>

<book category="COOKING">

      <title lang="en">My Kitchen Year</title>

      <author>Ruth Reichl</author>

      <year>2015</year>

      <price>35.00</price>

      <pages>352</pages>

</book>

<book category="CHILDREN">

      <title lang="en">Harry Potter</title>

      <author>J. K. Rowling</author>

      <year>2005</year>

      <price cover="soft">29.99</price>

</book>

<book category="XML">

      <title lang="en">XQuery Kick Start</title>

      <author>Brian Benz</author>

      <author> John Durant</author>

      <year>2003</year>

      <price cover="hard">149.99</price>

      <pages>984</pages>

</book>

<book category="XML">

      <title lang="en">XML Primer</title>

      <author> Nicholas Chase</author>

      <year>2002</year>

      <price>39.95</price>

      <pages>1024</pages>

        <description>  I highly recommend this book.  It's a

     <emphasis> good intro book to XML </emphasis>, which

        is what it's intended to be.</description>

</book>

</library>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answers:

The correct schema for this xml file is :

Raw code:

<?xml version="1.0" encoding="utf-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="library"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="book"> <xs:complexType> <xs:sequence> <xs:element name="title"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="lang" type="xs:string" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element maxOccurs="unbounded" name="author" type="xs:string" /> <xs:element name="year" type="xs:unsignedShort" /> <xs:element name="price"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:decimal"> <xs:attribute name="cover" type="xs:string" use="optional" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element minOccurs="0" name="pages" type="xs:unsignedShort" /> <xs:element minOccurs="0" name="description"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="emphasis" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="category" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

Code in the editor:

Please follow the indentation as in editor .

Feel free to comment in the comment section if you have any doubts or queries

Thank you!

Add a comment
Know the answer?
Add Answer to:
I need an xml schema code for this xml file ASAP. Thanks <?xml version="1.0" encoding="UTF-8" ?>...
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
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