• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on PerfectXML

 
Chandra A Sekhar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quiz 2 in perfect xml :
The following XML document is legal:
<!--Document last updated: January 15-->
<?xml version="1.0" ?>
<SalesReport year="2001" month="January">
<NetIncome>25,000</NetIncome>
<Profit>2,000</Profit>
</SalesReport>
True False
The answer it says is false , I couldn't find any thing wrong with this structure , is there anything Iam missing?
Thanks in advance
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it is because the xml PI must come before the comment.
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Additional info.
In Professional XML, page 76 (and, I'd assume the XML spec) it talks about the xml declaration PI as follows: "If this declaration is included, then the string literal "<?xml " must be the very first six characters of the document - no preceding whitespace or embedded comments are allowed."
 
Chandra A Sekhar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey John,
Got it ! Thanks for the explanation and reference.
Chandra
 
Syed AliRaza Zaidi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means u r not allowed to write comments before xml declarative of version am i right john.
Thankyou for making it clear I am giving XML on 23rd can u tell me best way to finalize my concepts as to get 100% perfection which i hope is not un attainable
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Syed,
That's right. No comments, or anything, before <?xml if it is in the doc.
I'm not sure how to advise you on final prep other than to really focus on areas you are weak on and review those areas you are comfortable with. I'd also take the mock exams from witscale, IBM, etc, and use XPath visual checking tools to make sure you have XPath down. Schemas are supposed to be important, too.
Good luck!
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason for this strict rule is due to the fact that the XML parser uses the first five characters (<?xml) to make reasonable guesses about the encoding, such as whether the document uses a single-or multibyte character set. An invisible Unicode byte order mark is the only thing that may precede the XML declaration (XML in a nutshell, page 22).
Cheers,
Dan
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this is quite correct. There is no guessing. I'm pretty sure that the <?xml ...?> is required to be encoded in UTF-8, and the remainder of the document after "?>" will be interpreted in the encoding scheme specified.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
such as whether the document uses a single-or multibyte character set. An invisible Unicode byte order mark is the only thing that may precede the XML declaration (XML in a nutshell, page 22).
Sorry, but I have a hard time beleiving this stmt. :roll:
regds.
- madhav
 
Adrian Ferreira
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reid,
I disagree and can't believe in any restriction such as encoding the first line in UTF-8.
Acording to "XML in a Nutshell" parsers can predict the encoding since they know what the first line must match <?xml versio="1.0"?>
Adrian
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so now I'm curious enough to find out for sure...
I'm looking at the XML 1.0 spec now, and it looks like there are bits where we were both correct, and both incorrect. If the doc isn't in UTF-8 or in UTF-16, then there is an algorithm that will be applied to detect the encoding, because only a fixed set of encodings are allowed. The algorithm operates on the requirement that the first 5 encoded characters represent <?xml
The specifics are in the XML 1.0 spec, appendix F.
[ May 22, 2002: Message edited by: Reid M. Pinchback ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic