• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about references to unparsed entities

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am not very clear about the following statement:


Any reference to an unparsed entity would cause fatal XML parser errors.


Could anyone give an example about this? Thanks.
[ September 03, 2002: Message edited by: jim yin ]
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid it should be:
Any reference to an unresolved entity would cause fatal XML parsing errors.
For example, <root>&myentityreference;</root>, if it is not defined in DOCTYPE, then it would cause fatal parsing error. Easy to see, write a one line XML, then try to open it in IE.
[ September 01, 2002: Message edited by: Roseanne Zhang ]
 
jim yin
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roseanne.
The above quote is from Professional XML p168.
And the following is the definition of unparsed entity:


non-XML data (can even be non-text data). All unparsed entities must have an associated notation, which is also identified by name. Unparsed entities are always external entities.


All these entity defitions are extremely confusing. It will cause a fatal error because an unparsed entity does not have an associated natation?
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add to your confusion, read more from here
W3: Extensible Markup Language (XML) 1.0 (Second Edition)
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,
Here are the following two statements you were enquiring about -
1) Any reference to an unparsed entity would cause fatal XML parser errors.
2) non-XML data (can even be non-text data). All unparsed entities must have an associated notation, which is also identified by name. Unparsed entities are always external entities.
============================================
Explanation for point (2)
Consider the scenario wherein we are using an xml document for the GUI layout of an application. When the user clicks on a "sound icon", say, we need to get the music file(song.mp3) and play it for the user. For this we need to know the application that plays the sound file (mp3Player i.e., mp3.exe).
The xml validator should not make an attempt to parse the external entity (which is the sound file song.mp3 in our case). The NDATA keyword used for defining the entity tells the parser that this is an unparsed enternal entity (hence don't try to parse it). The application that is making use of this xml document will know where to get the song and how to play it from the ENTITY declaration as given below. Rest of the things are intuitive here -
<!-- mp3Player is the notation's name -->
<!NOTATION mp3Player SYSTEM "http://www.zzz.com/mp3.exe">
<!-- Entity soundFile is the external unparsed -->
<!-- entity used along with the NDATA keyword -->
<!ENTITY soundFile SYSTEM "http://www.hostingservice.com/song.mp3" NDATA "mp3Player">
<!ATTLIST soundElement soundAttr ENTITY #REQUIRED>
The soundElement in our xml document looks something like below -
<soundElement soundAttr="soundFile"/>
===============================================
I think the first statement
"Any reference to an unparsed entity would cause fatal XML parser errors."
means that if we declare an external unparsed entity with the NDATA keyword, say, that would be a fatal error as shown below -
<!ENTITY imageFile SYSTEM "http://www.aa.com/bb.gif">
If i try to make an entity reference like
<someElement>
&imageFile;
</someElemet>
Though the above is syntatically(xml) well-formed, we are referring to an external unparsed entity and the resulting xml document will be invalid.
Anyone please correct me for any mistakes;
 
jim yin
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Jayadev:
Your explanations make my doubts clearer. Do you mean the following?


means that if we declare an external unparsed entity without the NDATA keyword, say, that would be a fatal error as shown below -


Yes, I think so. NDATA will signal to validating processor that external entities will not be parsed.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim,
sorry for missing out the "without" for the NDATA stuff; I mean it;
Also, i tried the following just a few moments back -
<!ENTITY imageFile SYSTEM "demo.gif">
without the NDATA keyword; When it run the xml document thru the validator, it tried to read the demo.gif (placed by me in the local directory) and complained about its contents ; Then when i changed it as below -
<!NOTATION img SYSTEM "imageViewer">
<!ENTITY imageFile SYSTEM "demo.gif" NDATA img>
it went fine thru the validator; This endorses the relevance of the NDATA keyword for the external unparsed entities;
Please let me know if you have any doubts; I'm also learning a lot of things in the process;
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic