Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with a practice question

 
C Wong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following would raise an error if the empID attribute's data type were defined as type ID in the DTD?
a. <name empID="17563">Joe Smith</name>
b. <name empID="ft:17563">Joe Smith</name>
c. <name empID="a17563">Joe Smith</name>
d. <name empID="">Joe Smith</name> Multiple
Select - Please select all of the correct answers (this question has 2 correct choices). Ans: a, d. - please explain.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attributes that are declared to be of type ID must be legal XML name tokens.
Please check out the following discussion about the same topic:
http://www.coderanch.com/t/146982/po/certification/Type-ID-DTD
 
carey eng
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the empID attribute's data type were defined as type ID in the DTD, the first character of this attribute may only be a letter, underscore or a colon.
 
C Wong
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the prompted response. I got it now.
 
Daniel Washington
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i test all the four choices in the xmlspy,i found the b is also wrong,prefix "ft" is not allowed,and the string behind the prefix is not start with a letter!
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel,
<name empID="ft:17563">Joe Smith</name>
ft:17563 has nothing to do with prefix, namespace or some such.
ft:17563 is the content of the text node of the attribute.
All characters of "ft:17563" are allowed to qualify as legal xml name tokens.
[ March 18, 2003: Message edited by: Axel Janssen ]
 
Daniel Washington
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to Axel:
the ":" in the string is not allowed,i test in xmlspy,she said:invalid value.when i del the ":",it's ok!
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the exam purpose, you should consider the XML recommendation as the absolute authoritative reference and not implementing tools like XMLSpy.
In the recommendation, it is stated in 3.3.1 Attribute Types that "Values of type ID must match the Name production." and the Name (and NameChar) productions are specified as
Name ::= (Letter | '_' | ':') (NameChar)*
NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
As you can see, the : character is perfectly admissible in attribute values. XMLSpy must have skipped that part
[ March 18, 2003: Message edited by: Valentin Crettaz ]
 
Daniel Washington
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
really thank you very much.&bow
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic