Re: [xml] Entities defined using other entities



In case somebody else has the same problem,
xmlSubstituteEntitiesDefault() was not helpful but setting
XML_PARSE_NOENT in the third argument of xmlReadFile() did the job.

Thanks,
Christophe

On Wed, 2006-11-22 at 14:29 -0500, christophe barbe wrote:
xmllint with the -noent option does the right thing.
Thanks for the help,
Christophe 

On Wed, 2006-11-22 at 14:15 -0500, christophe barbe wrote:
Thanks Daniel for your answer.

For example if I want to parse:

<?xml version="1.0"?>
<!DOCTYPE EXAMPLE SYSTEM "example.dtd" [
<!ENTITY xml "Extensible Markup Language">
<!ENTITY xml2 "Extensible &xml; Markup Language">
]>
<EXAMPLE attr="()&xml;()" attr2="()&xml2;()">
   &xml;
</EXAMPLE>

xmllint gives me the ouput below. There I can see the 2 entity
declarations. I would expect there the definition of xml2 to refer to
the first entity. 
In my program I tried to set xmlSubstituteEntitiesDefault to 1, but it
does not seem to have any effect. And my output looks like:
    <EXAMPLE 
            attr="()Extensible Markup Language;()"
            attr2="()Extensible &xml; Markup Language()">
                    Extensible Markup Language
    </EXAMPLE>

$ xmllint --debug test.xml
 DOCUMENT
version=1.0
URL=test.xml
standalone=true
  DTD(EXAMPLE), SYSTEM example.dtd
    ENTITYDECL(xml), internal
     content=Extensible Markup Language
      TEXT
        content=Extensible Markup Language
    ENTITYDECL(xml2), internal
     content=Extensible &xml; Markup Language
      TEXT
        content=Extensible
      ENTITY_REF(xml)
        INTERNAL_GENERAL_ENTITY xml
        content=Extensible Markup Language
      TEXT
        content= Markup Language
  ELEMENT EXAMPLE
    ATTRIBUTE attr
      TEXT
        content=()
      ENTITY_REF(xml)
        INTERNAL_GENERAL_ENTITY xml
        content=Extensible Markup Language
      TEXT
        content=()
    ATTRIBUTE attr2
      TEXT
        content=()
      ENTITY_REF(xml2)
        INTERNAL_GENERAL_ENTITY xml2
        content=Extensible &xml; Markup Language
      TEXT
        content=()
    TEXT compact
      content=
    ENTITY_REF(xml)
      INTERNAL_GENERAL_ENTITY xml
      content=Extensible Markup Language
    TEXT compact
      content=



On Wed, 2006-11-22 at 14:04 -0500, Daniel Veillard wrote:
On Wed, Nov 22, 2006 at 12:55:27PM -0500, christophe barbe wrote:
Hi All,

I am trying to parse a document with entities using libxml2:

<?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE schema [
    <!ENTITY ent1 "abc">
    <!ENTITY ent2  "&ent1;def">
...

It looks like libxml does not handle the fact that one entity is defined
in term of another.

Is it a legal use of entities?

  yes

Am I correct in assuming that libxml can not handle this use of
entities?

  no
  
I am not sure if the internal tree could handle it properly.

  I am sure it should be able to handle this properly

The original XML file is a schema included in the following IETF draft:

http://www.ietf.org/internet-drafts/draft-ietf-simple-xml-patch-ops-02.txt

The entities are used, as macros, to define the regular expression for
xpath expressions.

  No idea what your problem is. If you have a problem reproduceable with
xmllint please provide them as attachment and describe the problem.

Daniel

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
-- 
Christophe Barbe - Software Engineer
Objective Systems, Inc.
REAL WORLD ASN.1 AND XML SOLUTIONS
Tel: +1 (484) 875-9841
Fax: +1 (484) 875-9830
Toll-free: (877) 307-6855 (USA only)
http://www.obj-sys.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]