Core XML |
|
Author: Mapraputa Is
|
|
"Our objective is to equip you with "just enough" XML
to appreciate the aplication scenarios and tool descriptions <...>,
but being over-achievers we may go a little too far"
Charles F. Goldfarb, Paul Prescod, The XML Handbook
Level of difficulty: easier than real exam. The following questions are intended to test basic
syntax rules
and to serve as a self-revision tool after reading a corresponding chapter,before we move to "real exam questions"
|
1. An empty file is a well-formed XML document |
|
a)true
b)false
|
|
Answer : b
XML document must have at least the document element (root).
|
2. XML tags are case sensitive |
|
a)true
b)false
|
|
|
3. Which of the following XML documents are well-formed? |
|
|
|
Answer : a
b is wrong because root tag is missing
c is wrong because tags are nested unproperly
d is wrong because the closing tag is omitted
|
4. Which of the following XML fragments are well-formed? |
|
a) <myElement myAttribute="someValue"/>
b) <myElement myAttribute=someValue/>
c) <myElement myAttribute='someValue'/>
d) <myElement myAttribute="someValue'/>
e) <myElement myAttribute="some'Value"/>
f) <myElement myAttribute='some"Value'/>
|
|
Answers : a c e f
It is illegal to omit quotation marks around attribute values.
|
5. By default the white space in elements is not truncated. |
|
a)true
b)false
|
|
|
6. When processing an output XML, "new line" symbols |
|
a)are copied into output "as is", i.e. "CR+LF" for Windows,
CR for Macintosh, LF for Unix.
b)are converted to single LF symbol
c)are converted to single CR symbol
d)are discarded
|
|
|
7. Which of the following XML fragments are well-formed? |
|
a) <myElement />
b) < myElement />
c) <myElement / >
d) <myElement/ >
|
|
Answer : a
b is wrong because there can't be a space after opening "<" character;
c and d are wrong because there can't be a space between "/" and ">"
|
8. Rules for naming elements, attributes, entity references and processing instructions are the same |
|
a)true
b)false
|
|
|
9. Which of the following strings are a correct XML name? |
|
a) _myElement
b) my Element
c) #myElement
d) 2ndElement
|
|
|
10 Which of the following strings are a correct XML name? |
|
a) xmlExtension
b) xslNewElement
c) XMLElement#123
d) myXMLElement123
|
|
|
11. Which of the following strings are a correct XML name? |
|
a) myElement.myAttribute
b) myElement-myAttribute
c) página
d) n(4)
|
|
|
12. This is a valid definition: |
|
This question is contributed by Dan Chisham.
<!ATTLIST el
att1 ID #REQUIRED
att2 IDREF #REQUIRED
att3 ID #REQUIRED
att4 NMTOKEN #REQUIRED
>
a) true
b) false
|
|
Answer: b
Only one attribute with type ID is permitted for each element.
|
13. Which of the following XML fragments are well-formed? |
|
a)<myElement myAttribute="value1 <= value2"/>
b)<myElement myAttribute="value1 & value2"/>
c)<myElement myAttribute="value1 > value2"/>
d)<myElement myAttribute="value1'value2"/>
|
|
Answers: c d
Well-formed XML document is not allowed to use "<" and "&" characters within an attribute
value
|
14. As their values attributes can have: |
|
a)general entity references
b)parameter entity references
c)unparsed entity names
d)CDATA sections
|
|
|
15. Which of the following XML fragments are well-formed? |
|
a)<!-- This is a comment -- quite useful one -->
b)<!-- This is a comment: <xml:comment > -->
c)<myElement myAttribute="value1 <!-anotherAttribute="value2" --> />
d)<!-- This is a comment <--! This is my old comment--> -->
|
|
Answer: b
a is wrong because the string "--" is not allowed inside comments
c is wrong because comment cannot be placed inside a tag
d is wrong because comments cannot be nested.
|
16. Which of the following XML fragments are well-formed? |
|
a)<![CDATA[ !@#$&%*()_+ ]]>
b)<![cdata[ ]]>
c)<![CDATA[ <!--comment--> ]]>
d)<![CDATA[yet another CDATA section:"<![CDATA[some text goes here]]>" ]]>
|
|
Answers: a c
b is wrong because cdata should be CDATA
d is wrong because symbols "]]>" are the only symbols that are not allowed in a CDATA section are.
|
17. XML declaration is not required for XML document to be well-formed |
|
a)true
b)false
|
|
|
18. Which of the following XML fragments are well-formed? |
|
a)<!-- Author: me, version: 1.01 -->
<?xml version='1.0'?>
b)<?xml version='1.0'?>
<!-- Author: me, version: 1.01 -->
c)all of the above
d)none of the above
|
|
Answer: b
a is wrong because the XML declaration must be right at the beginning of the file
|
19. Which of the following XML fragments are well-formed? |
|
a)<?xml?>
b)<?xml version="1.0"?>
c)<?xml encoding="JIS"?>
d)<?xml encoding="JIS" version="1.0"?>
|
|
Answer: b
a and c are wrong because required attribute version is missing
d is wrong because version, encoding and standalone attributes must be in that order
|
20. Which statement(s) is(are) correct regarding encoding attribute of XML declaration: |
|
a)encoding attribute is required for any XML declaration
b)encoding attribute is required only if actual encoding is different from default
c)if XML document uses only ASCII symbols, encoding attribute can be omitted
d)UTF8/UTF-16 is default encoding
|
|
|
21. Attribute standalone="no" should be included in XML declaration if a document: |
|
a)is linked to an external XSL stylesheet
b)has external general references
c)has processing instructions
d)has an external DTD
e)has namespace declarations
f)has XLink/XPointer elements
|
|
|
22. PI in XML specification stands for: (Warning: tricky question!) |
|
a)3.14
b)priceless instruction
c)processing instruction
d)polymorphic inheritance
|
|
|
|
Your
scores:
|