[xml] How to use xmlIOParseDTD ?



Sorry for this dummy question, but I fail to use the xmlIOParseDTD function.
I browse the documentation, the xmlsoft.org site and google since a few
days, and I can't find my answer.

My problem is that I would like to use a DTD from memory, and not from an
external file. Here is the code snipet:

-------------
int some_function(char *envelop,
                  /*OUT*/char **msgname,
                  char **content) {

  static xmlDtdPtr msg_dtd=NULL;
  
  /* initialize the envelop DTD if needed */
  if (!msg_dtd) {
    const char* dtd=
      "<!ELEMENT message ANY><!ATTLIST message name CDATA #REQUIRED>\n";
      
    fprintf(stderr,"XSG: Parse the DTD\n");
    msg_dtd=xmlIOParseDTD(NULL,
               xmlParserInputBufferCreateMem(dtd,sizeof(dtd),
                                             XML_CHAR_ENCODING_ASCII),
                          XML_CHAR_ENCODING_ASCII);
    if (!msg_dtd) {
      fprintf(stderr,
              "XSG: Damnit! Error while parsing message envelop DTD.\n");
      return MSG_FATAL;
    }
  }
  [...]
}
------------

The execution produce the following output:
------------
XSG: Parse the DTD
Entity: line 1: error: Content error in the external subset
<!EL
^
Entity: line 1: error: Extra content at the end of the document
<!EL
^
XSG: Damnit! Error while parsing message envelop DTD.
------------

The dtd seems valid to me, but the function don't like it...


Again, I'm sorry for such a lamer question, but I'm kinda lost here.
Thanks, Mt.

-- 
Si les grands esprits se rencontrent, les petits esprits, eux, se cognent.



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