xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: why is entity ref expanded in the internal subset (and related questions)?...
Date Sat, 08 Apr 2006 22:09:30 GMT

Still haven't found a good answer my previous question below, but at 
least I have it generally working with the expanded Entity and hack 
to turn "%BigEntity" into "% BigEntity" so that I don't get parse 
error upon reparsing the serialized document.  However, I've got a 
larger issue than any of that, and I think it is my last major issue 
to figure out....

When I add EntityReference nodes to the DOM I'm building up, they 
don't get expanded in the parse tree.  That is, when I print out the 
DOM tree, all I see are the EntityReference nodes, but none of their 
children, even though I iterate recursively over all the child 
nodes.  For instance, for the example listed in my previous question 
(below), here is the parse tree...

Document MIME type: null
Document encoding: UTF-8
DOM hierarchy:
     XercesLinkedDocument:
         DocumentTypeImpl: name=vxml
          internalSubset=
<!ENTITY % BigEntity SYSTEM "BigEntity.ent">
<!ENTITY BigEntity "
                 <prompt>another prompt</prompt>
                 <prompt>another prompt</prompt>
                 <prompt>another prompt</prompt>
                 <prompt>another prompt</prompt>
                 <prompt>another prompt</prompt>
                 <prompt>another prompt</prompt>
                 <prompt>another prompt</prompt>
">

         ElementNSImpl: vxml
             Attributes:
                 AttrImpl: version
                     TextImpl: 1.0
             ElementImpl: form
                 Attributes:
                     AttrImpl: id
                         TextImpl: init
                 ElementImpl: block
                     TextImpl:

                     EntityReferenceImpl: name=BigEntity
                     TextImpl:


Notice that EntityReferenceImpl has no children.  I expected it to 
include child nodes of the EntityReference; that is, nodes 
representing the 7 cases of "<prompt>another prompt</prompt>" defined 
in the Entity "BigEntity".

I shouldn't have to manually populate the children of the 
EntityReference, should I?  I have noticed that I get events on the 
EntityReference contents as I parse the document using XNI, but all I 
should have to do for the DOM is simply do the following, no?...

         EntityReference entityRef = 
fDocument.createEntityReference(entityName);
         fCurrentNode.appendChild(entityRef);

...where "fCurrentNode" is the current parent node to which children 
are being appended.  I've read that EntityReference children might be 
lazily expanded, so that if they aren't accessed no work is 
performed, but I am accessing the EntityReference children in order 
to print the DOM tree.  Why don't they show up???  Shouldn't the DOM 
do this for me?  It clearly has all the information it needs.  What 
am I missing?


thanks,

Jake

At 12:32 AM 4/8/2006, you wrote:
 >
 >I'm having a problem with the following...
 >
 ><?xml version="1.0" encoding="UTF-8"?>
 ><!DOCTYPE vxml SYSTEM "voicexml1-0.dtd" [
 >       <!ENTITY % BigEntity SYSTEM "BigEntity.ent">
 >       %BigEntity;
 >]>
 ><vxml version="1.0">
 >       <form id="init">
 >               <block>
 >                       &BigEntity;
 >               </block>
 >       </form>
 ></vxml>
 >
 >BigEntity.ent looks something like this...
 >
 ><?xml version="1.0" encoding="UTF-8"?>
 ><!ENTITY BigEntity '
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >'>
 >
 >When internalEntityDecl(String name, XMLString text, XMLString
 >nonNormalizedText, Augmentations augs) gets called, both the
 >text.toString() and nonNormalizedText.toString() contain the fully
 >expanded contents of the entity (a bunch of <prompt>another
 >prompt</prompt> entries).  After I build this into a DOM and
 >serialize it, it looks like...
 >
 ><?xml version="1.0" encoding="UTF-8"?>
 ><!DOCTYPE vxml SYSTEM "voicexml1-0.dtd"
 >  [
 ><!ENTITY %BigEntity SYSTEM "BigEntity.ent">
 ><!ENTITY BigEntity "
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >               <prompt>another prompt</prompt>
 >
 >">
 >]>
 ><vxml version="1.0"><form id="init"><block>&BigEntity;</block></form></vxml>
 >
 >Why are the contents expanded?  Why not just give me "%BigEntity;"
 >from the original document?  Is there any recourse?
 >
 >A second problem is that reparsing this file gives me the following
 >parsing error...
 >
 >test9.gen.xml:4: Error: White space is required after "<!ENTITY" in
 >the entity declaration.
 >
 >The parse error seems to be with the external entity declaration
 >"%BigEntity".  If I change that to "% BigEntity", the parse error
 >goes away.  But, the "name" parameter passed to me in the
 >externalEntityDecl() method is exactly "%BigEntity".  If the parser
 >knows it can't deal with that, why doesn't it pass me "%
 >BigEntity"?  Seems odd that I'd be forced to split the "%" apart from
 >the rest of the entiy name manually.
 >
 >
 >thanks,
 >
 >Jake
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
 >For additional commands, e-mail: general-help@xml.apache.org
 >
 >
 > 


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message