You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Radu Coravu (JIRA)" <xe...@xml.apache.org> on 2015/03/27 07:44:52 UTC

[jira] [Comment Edited] (XERCESJ-1205) Entity resolution does not work with DTD grammar caching resolved

    [ https://issues.apache.org/jira/browse/XERCESJ-1205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12921279#comment-12921279 ] 

Radu Coravu edited comment on XERCESJ-1205 at 3/27/15 6:44 AM:
---------------------------------------------------------------

Also, if you want to reuse the DTD Grammar when parsing XML files with different internal subsets, then the internal entites should not be copied from the DTDGrammar to the XMLEntityManager when XMLEntityManager.initFromDTD () gets called.
So the code would be something like:
{code}
    public void initFromDTD(DTDGrammar grammar)
    {
        final XMLEntityDecl entityDecl = new XMLEntityDecl();
        int index = 0;
     
        while(grammar.getEntityDecl(index++, entityDecl)) {
          fInExternalSubset = entityDecl.inExternal;
          if(entityDecl.inExternal) {
            if(entityDecl.publicId != null
                || entityDecl.systemId != null) {
                try {
                    addExternalEntity(entityDecl.name, entityDecl.publicId, entityDecl.systemId, entityDecl.baseSystemId);
                }
                catch(IOException e) {
                }
            } else {
                addInternalEntity(entityDecl.name, entityDecl.value);
            }
          }
        }
        fInExternalSubset = false;
    }
{code}


was (Author: radu_coravu):
Also, if you want to reuse the DTD Grammar when parsing XML files with different internal subsets, then the internal entites should not be copied from the DTDGrammar to the XMLEntityManager when XMLEntityManager.initFromDTD () gets called.
So the code would be something like:

    public void initFromDTD(DTDGrammar grammar)
    {
        final XMLEntityDecl entityDecl = new XMLEntityDecl();
        int index = 0;
     
        while(grammar.getEntityDecl(index++, entityDecl)) {
          fInExternalSubset = entityDecl.inExternal;
          if(entityDecl.inExternal) {
            if(entityDecl.publicId != null
                || entityDecl.systemId != null) {
                try {
                    addExternalEntity(entityDecl.name, entityDecl.publicId, entityDecl.systemId, entityDecl.baseSystemId);
                }
                catch(IOException e) {
                }
            } else {
                addInternalEntity(entityDecl.name, entityDecl.value);
            }
          }
        }
        fInExternalSubset = false;
    }

> Entity resolution does not work with DTD grammar caching resolved
> -----------------------------------------------------------------
>
>                 Key: XERCESJ-1205
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1205
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DTD
>    Affects Versions: 2.8.1
>         Environment: JDK1.5. The issue appears on various machines, Windows, Linux, Mac OSX. I don't believe it is platform specific.
>            Reporter: Tin Pavlinic
>            Assignee: Michael Glavassevich
>         Attachments: XERCESJ-1465.patch, bug.zip
>
>
> We have a DTD which defines some entities. We are parsing multiple documents against this DTD. If grammar caching is enabled, the entities are unresolved when the grammar is loaded from the cache, instead of the DTD. 
> It seems that they are cleared every time a document is parsed and are only loaded when a DTD is loaded and not from the cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org