You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Michael Glavassevich <mr...@ca.ibm.com> on 2006/04/10 07:10:57 UTC
Re: why is entity ref expanded in the internal subset (and related
questions)?...
Hi Jacob,
Jacob Kjome <ho...@visi.com> wrote on 04/08/2006 06:09:30 PM:
> 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?
An EntityReference created with Document.createEntityReference() will only
have children if there's a corresponding Entity node and the replacement
text for the Entity is available. Strictly using the DOM interfaces you
cannot create Entity nodes or modify them since they're read-only.
EntityReference nodes and their children are also read-only. If you're
wondering how Xerces builds these things take a look at AbstractDOMParser
[2] and EntityReferenceImpl [3] (particularly synchronizeChildren()).
> thanks,
>
> Jake
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-392B75AE
[2]
http://svn.apache.org/viewcvs.cgi/xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java
[3]
http://svn.apache.org/viewcvs.cgi/xerces/java/trunk/src/org/apache/xerces/dom/EntityReferenceImpl.java
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org