Basic XML
Skills:
Unclassified Questions
Question: [
Fatal Errors] An XML processor (a well-behaving software module processing XML documents in some manner), when it encounters syntactically wrong XML (one that does not match the W3C specification):
- Recovers silently from the error and tries to continue document processing
- Uses application-specific method to report the error, tries to recover and continue processing
- XML processor should always fail and report the first location (line, column) of the syntax error
- XML processor can fail and stop immediately, or it can try to recover - but only to report more errors
- Replace the existing HTML language with a new, improved markup
- Make SGML documents easier to serve, process and access in the Web
- Provide general methods for the visual representation of data
- Represent objects from object-oriented languages and their relationships in a human-readable format
- <
- "
- '
- &squote;
Question: [
Diacritics Escape] How can you insert a letter "Ž" (capital letter "Z" with caron) in an "ISO-8859-1"-encoded XML document?
- Write it as "Ž" in a Unicode-enabled text editor
- Ж
- Ž
- Ž
Question: [
Two Amps] What is the string content of "root" element, if the XML source looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>&amp;<root>
- &
- &
- amp;amp;
- Such XML is not well-formed
Question: [
Permutations] You want to express in a DTD grammar that a valid "lunch" element should contain "soup", "maincourse" and "desert" child elements - all 3 should be present, but their order within the lunch can be arbitrary. Which DTD grammar expression for "lunch" represents this rule?
<!ELEMENT lunch (soup, maincourse, desert)>
<!ENTITY % p12 "(soup,maincourse|maincourse,soup)">
<!ENTITY % p13 "(soup,desert|desert,soup)">
<!ENTITY % p23 "(maincourse,desert|desert,maincourse)">
<!ENTITY % r1 "soup,%p23;">
<!ENTITY % r2 "maincourse,%p13;">
<!ENTITY % r3 "desert,%p12;">
<!ELEMENT lunch (%r1;|%r2;|%r3;)>
<!ENTITY % seq "(soup|maincourse|desert)">
<!ELEMENT lunch (%seq;, %seq;, %seq;)>
<!ELEMENT lunch
(soup?,(maincourse,desert),
(desert,maincourse) , soup?>
Question: [
Element Structure] What kind of grammar modification this document needs to become correct:
<?xml version="1.0" encoding="ISO-8859-1"?>
<![DOCTYPE[
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<to>Pekka</to>
<from>Janne</from>
<heading>Reminder</heading>
<body>Please send me the <package> tomorrow!</body>
- Change encoding to "UTF-8"
- Remove the DTD declaration (lines 2-7)
- Document is correct as it is now
- Document is wrong regardless of its DTD grammar
Question: [
Copyright Entity] Assume that you want to use additional entity "&Copyright;" in your document with the value "This is the copyright". Describe the correct way to include it in an existing XML document.
<![DOCTYPE book [
<!ENTITY Copyright "This is the copyright">
]>
<book bestsections="1,2">
<section>
<chapter>&Copyright;</chapter>
</section>
<section/>
</book>
<![DOCTYPE root [
<!ELEMENT book (section*)>
<!ATTLIST book
bestsections IDREFS #IMPLIED>
<!ELEMENT section (chapter*)>
<!ELEMENT chapter (#PCDATA)>
<!ENTITY Copyright "This is the copyright">
]>
<book bestsections="1,2">
<section>
<chapter>&Copyright;</chapter>
</section>
<section/>
</book>
<![DOCTYPE root [
<!ENTITY Copyright SYSTEM "copyright.txt">
]>
<book bestsections="1,2">
<section>
<chapter>&Copyright</chapter>
</section>
<section/>
</book> (Here "copyright.txt" is a file in the same directory)
<![DOCTYPE root [
<!ELEMENT book (section*)>
<!ATTLIST book
bestsections IDREFS #IMPLIED>
<!ELEMENT section (chapter*)>
<!ELEMENT chapter (#PCDATA)>
<!ENTITY Copyright "This is the copyright">
]>
<book bestsections="1,2">
<section>
<chapter>#Copyright;</chapter>
</section>
<section/>
</book>