Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, i really need help. I am not understanding XML. . According to the following

ID: 3706809 • Letter: H

Question

Hi, i really need help. I am not understanding XML.

. According to the following DTD, write the valid XML document. How to define that book must appear one or more times in booklist.

<!DOCTYPE booklist [

<!ELEMENT booklist (book)+>

<!ELEMENT book (bookname, author, price)>

<!ELEMENT bookname (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT price (#PCDATA)>

]>


2.

According to the following external DTD,

<!--    file name publish.dtd -->

<!ELEMENT publishInfo (publisher, ISBN, pubDate)>

<!ELEMENT publisher (#PCDATA)>

<!ELEMENT ISBN (#PCDATA)>

<!ELEMENT pubDate (#PCDATA)>

complete the rest of the XML document:

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

<--    file name book.xml   -->

<!DOCTYPE bookCategory SYSTEM “publish.dtd” [

<!ELEMENT bookCategory (book*)>

<!ELEMENT book (title, author, publishInfo, price)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT price (#PCDATA)>

<!ATTLIST price currency CDATA “Dollar”>

]>

3.

Write the corresponding internal and external DTD for this xml document:

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

<bookTitle>

            <title>XML Introduction</title>

            <subtitle section=”1” >next generation web language</subtitle>

</bookTitle>

Explanation / Answer

1). According to the following DTD, write the valid XML document. How to define that book must appear one or more times in booklist.

<!DOCTYPE booklist [

<!ELEMENT booklist (book)+>-->Wrong representation one or more time of book.+ should be inside.

<!ELEMENT book (bookname, author, price)>

<!ELEMENT bookname (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT price (#PCDATA)>

]>

Ans: Here above DTD is internal DTD.

DOCTYPE booklist is the root of the XML.

<!ELEMENT booklist (book+)> --> book must appear one or more times in booklist

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

<booklist>

<book>

<bookname>book1</bookname>

<author>author1</author>

<price>100</price>

</book>

<book>

<bookname>book2</bookname>

<author>author2</author>

<price>120</price>

</book>

</booklist>

-------------------------------------------------------------------------------------------------

2.According to the following external DTD,

Ans:

<!ELEMENT bookCategory (book*)>---> book must appear zero or one times in booklist

<-- file name book.xml -->

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

<bookCategory>

<book>

<title>title1</title>

<author>author1</author>

<publishInfo>

<publisher>publisher1</publisher>

<ISBN>ISBN1</ISBN>

<pubDate>2018-04-13</pubDate>

</publishInfo>

<price>100</price>

</book>

</bookCategory>

<!-- file name publish.dtd -->

<!ELEMENT publishInfo (publisher, ISBN, pubDate)>

<!ELEMENT publisher (#PCDATA)>

<!ELEMENT ISBN (#PCDATA)>

<!ELEMENT pubDate (#PCDATA)>

complete the rest of the XML document:

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

<-- file name book.xml -->

<!DOCTYPE bookCategory SYSTEM “publish.dtd” [

<!ELEMENT bookCategory (book*)>

<!ELEMENT book (title, author, publishInfo, price)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT price (#PCDATA)>

<!ATTLIST price currency CDATA “Dollar”>

]>

-------------------------------------------------------------------------------------------------

3.Answer:

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

<bookTitle>

<title>XML Introduction</title>

<subtitle section="1">next generation web language</subtitle>

</bookTitle>

External DTD:

<!-- file name bookTitle.dtd -->

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

<!ELEMENT bookTitle (title,subtitle)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT subtitle (#PCDATA)>

<!ATTLIST subtitle section CDATA "1">

<!DOCTYPE bookTitle SYSTEM “bookTitle.dtd”>

  

  

--------------------------------

Internal DTD:

<!DOCTYPE bookTitle [

<!ELEMENT bookTitle (title, subtitle)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT subtitle (#PCDATA)>

<!ATTLIST subtitle section CDATA "1">

]>

<!DOCTYPE bookTitle [ -->Represent bookTitle root element of the xml

<!ELEMENT bookTitle (title, subtitle)> -->Elements inside the bookTitle elemnts are title, subtitle

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote