Re: [xml] Entity with elements inside it?



On Fri, Jul 10, 2009 at 3:44 PM, Daniel Veillard<veillard redhat com> wrote:
On Fri, Jul 10, 2009 at 10:01:06AM +0800, Bo Yang wrote:
MiLu FLUNDER:~/win-dev/XML > xmllint --noent nstoken.xml
<?xml version="1.0"?>
<!DOCTYPE Urmel [
<!ENTITY jaja "<eins><zwei/><drei>drei</drei></eins>">
]>
<Urmel> <eins><zwei/><drei>drei</drei></eins> </Urmel>

The above is not my desired behavior. I want to the parser create a
entity_ref node, and then append the parsed "jaja" to the children of
entity_ref.

 it's the default behaviour !!!
 it's what it does, get a clue, when reserializing obviously it
won't output things twice !!!

paphio:~/XML -> xmllint --debug nstoken.xml
DOCUMENT
version=1.0
URL=nstoken.xml
standalone=true
 DTD(Urmel)
   ENTITYDECL(jaja), internal
    content=<eins><zwei/><drei>drei</drei></eins>
     ELEMENT eins
       ELEMENT zwei
       ELEMENT drei
         TEXT compact
           content=drei
 ELEMENT Urmel
   TEXT compact
     content=
   ENTITY_REF(jaja)
     INTERNAL_GENERAL_ENTITY jaja
     content=<eins><zwei/><drei>drei</drei></eins>
   TEXT compact
     content=
paphio:~/XML ->

 Complete proof:

(gdb) p *doc->children->next->children->next
$5 = {_private = 0x0, type = XML_ENTITY_REF_NODE, name = 0x7a0238
"jaja",
 children = 0x7a3658, last = 0x7a3658, parent = 0x7a0448, next =
0x7a3918,
 prev = 0x7a3798, doc = 0x7a00a8, ns = 0x0,
 content = 0x7a3728 "<eins><zwei/><drei>drei</drei></eins>",
 properties = 0x0, nsDef = 0x0, psvi = 0x0, line = 0, extra = 0}
(gdb) p *doc->children->next->children->next->children
$6 = {_private = 0x0, type = XML_ENTITY_DECL, name = 0x79fc5d "jaja",
 children = 0x7a3c28, last = 0x7a3c28, parent = 0x7a02d8, next = 0x0,
 prev = 0x0, doc = 0x7a00a8, ns = 0x7a0398,
 content = 0x7a3728 "<eins><zwei/><drei>drei</drei></eins>",
 properties = 0x100000025, nsDef = 0x0, psvi = 0x0, line = 0, extra =
0}
(gdb) p *doc->children->next->children->next->children->children
$7 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x79fc6d "eins",
 children = 0x7a3ce8, last = 0x7a3da8, parent = 0x7a3658, next = 0x0,
 prev = 0x0, doc = 0x7a00a8, ns = 0x0, content = 0x0, properties = 0x0,
 nsDef = 0x0, psvi = 0x0, line = 1, extra = 0}
(gdb)

 End of story, now please use the library and explore what it does
that will be more productive !

But what I got is:

(gdb) p *child
$8 = {_private = 0x0, type = XML_ENTITY_REF_NODE, name = 0x9f83d20
"ent4", children = 0x9f7d210, last = 0x9f7d210,
  parent = 0x9f83ad0, next = 0x0, prev = 0x9f83ff0, doc = 0x9f7b450, ns = 0x0,
  content = 0x9f7d260 "<entElement domestic='Yes'>Element
data</entElement><?PItarget PIdata?>", properties = 0x0,
  nsDef = 0x0, psvi = 0x0, line = 0, extra = 0}
(gdb) p *child->children
$9 = {_private = 0x0, type = XML_ENTITY_DECL, name = 0x9f7b086 "ent4",
children = 0x0, last = 0x0, parent = 0x9f7b5a0,
  next = 0x9f7d2b0, prev = 0x9f7b740, doc = 0x9f7b450, ns = 0x9f7d078,
  content = 0x9f7d260 "<entElement domestic='Yes'>Element
data</entElement><?PItarget PIdata?>", properties = 0x47,
  nsDef = 0x1, psvi = 0x0, line = 0, extra = 0}
(gdb)

I use libxml2.6.26 and libxml2.6.31, which version do you use? And my
parser options are:
        ret = xmlCtxtUseOptions(parser->xml_ctx, XML_PARSE_DTDATTR ||
                        XML_PARSE_DTDLOAD || XML_PARSE_DTDVALID);

Thanks!
Regards!
Bo



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