Ante XWiki Home » Tests » Basic XML

Basic XML

Last modified by Administrator on 2011/06/06 17:24

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):
  1. Recovers silently from the error and tries to continue document processing
  2. Uses application-specific method to report the error, tries to recover and continue processing
  3. XML processor should always fail and report the first location (line, column) of the syntax error
  4. XML processor can fail and stop immediately, or it can try to recover - but only to report more errors

Question: [XMLSpecification Goal] The purpose of creating specification of XML in 1998 was to:
  1. Replace the existing HTML language with a new, improved markup
  2. Make SGML documents easier to serve, process and access in the Web
  3. Provide general methods for the visual representation of data
  4. Represent objects from object-oriented languages and their relationships in a human-readable format

Question: [Single Quote Excape] How do you represent a singe-quote (') in an XML document?
  1. <
  2. "
  3. '
  4. &squote;

Question: [Diacritics Escape] How can you insert a letter "Ž" (capital letter "Z" with caron) in an "ISO-8859-1"-encoded XML document?
  1. Write it as "Ž" in a Unicode-enabled text editor
  2. Ж
  3. Ž
  4. Ž

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;amp;<root>

  1. &
  2. &amp;
  3. amp;amp;
  4. 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?
  1. <!ELEMENT lunch (soup, maincourse, desert)>
  2. <!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;)>
  3. <!ENTITY % seq "(soup|maincourse|desert)">
    <!ELEMENT lunch (%seq;, %seq;, %seq;)>
  4. <!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 &lt;package&gt; tomorrow!</body>
  1. Change encoding to "UTF-8"
  2. Remove the DTD declaration (lines 2-7)
  3. Document is correct as it is now
  4. 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.
  1. <![DOCTYPE book [
    <!ENTITY Copyright "This is the copyright">
    ]>
    <book bestsections="1,2">
      <section>
        <chapter>&Copyright;</chapter>
      </section>
      <section/>
    </book>
  2. <![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>
  3. <![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)
  4. <![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>

Tags:
Created by Administrator on 2007/10/29 20:34

This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 3.0.36132 - Documentation