1. The code bellow is not a well-formed XML document, as it does not follow the certain XML rules. XML documents must contain a root element, start tag with closing tags, and the attribute value should be enclosed with quotation marks.
<:-/>
2. Well-formed XML documents means that the syntax used within the document is correct, however Valid XML is when XML is validated against a DTD.
3. It is always a good idea to use comments to start of an XML document, as comments are there to aid the reader as well as the programmer. Comments are used in virtually all programming languages, and are a useful tool in helping to understand the code.
Longer Question
1. Bellow is the XML file I have created which also contains the dtd within the document: -
<?xml version="1.0"?>
<!DOCTYPE textbook [
<!ELEMENT textbook (titlepage, title, author, publisher, titlepageverso, publisheraddress, copyrightnotice, isbn, chapter, chaptertitle,section)>
<!ELEMENT titlepage (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (EMPTY)>
<!ELEMENT titlepageverso (#PCDATA)>
<!ELEMENT publisheraddress (EMPTY)>
<!ELEMENT copyrightnotice (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT chapter (#PCDATA)>
<!ELEMENT section (#PCDATA)>
<!ATTLIST sender publisher CDATA #FIXED " Excellent Books Ltd ">
<!ATTLIST sender publisheraddress CDATA #FIXED " Cemetry Lane, SE1 1AA, UK ">
]>
<textbook>
<titlepage>
<title>harry potter</title>
<author>j.k.rowling</author>
<publisher publisher= "Excellent Books Ltd" > </publisher>
</titlepage>
<titlepageverso>
<publishersaddress address="Cemetry Lane, SE1 1AA, UK"> </publishersaddress>
<copyrightnotice>blah rights limited</copyrightnotice>
<isbn>0293092309</isbn>
</titlepageverso>
<chapter>
<chaptertitle title= "beginning" number= "1">
<section title="first paragraph" number="1"></section>
</chaptertitle>
</chapter>
</textbook>
2. The following is an XML document that contains the following information: the name of a London tourist attraction. The name of the district it is in. The type of attraction it is (official building, art gallery, park etc). Whether it is in-doors or out-doors. The year it was built or founded. I chose appropriate tags. Used attributes for the type of attraction and in-doors or out-doors status.
<touristinfo>
<touristattraction>London Bridge</touristattraction>
<district>London</district>
<typeofattraction type=”famous bridge”></typeofattraction>
<premises status= “outdoor”></premises>
<yearitwasbuilt>1927</yearitwasbuilt>
</touristinfo>
Lecture Reflection-WEEK 5 – XML Encoding
During the 1960’s after the emergence of ASCII character set, the conventional computer software used it to represent text found in documents. It was the most widely used character encoding until 2008. ASCII character set used one byte to represent each character of the keyboard and was ideal for English and many European languages as well as having the ability to cope with simple mathematical expressions. However there are many other languages that contain different characters that need to be processed and stored that ASCII cannot process. The solution to this problem is the usage of “character set” such as UNICODE which covered almost every conceivable language. It has been published since 1991 and covers more than 107,000 characters in more than 90 scripts. Another alternative is the UCS character set which covers 4 billion characters when using all possible binary numbers.
Unicode was also designed so that the first 256 characters are identical to iso-8859-1 therefore allowing documents coded in ASCII easily usable with UNICODE.
When declaring the document type while leaving the character encoding section blank, the parser will automatically assume that the character encoding is UTF-8, however bellow is a few examples of how to specify different character sets in an xml declaration.
Encoding Declarations: -
1
<?xml version="1.0" encoding="UTF-16"?>
2
<?xml version="1.0" encoding="EUC-JP"?>
( Japanese character)3
<?xml version="1.0" encoding="iso-8859-11"?>
( Thai character)
http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main
No comments:
Post a Comment