Re: Bug (?) in XML::LibXML when creating XML docs with invalid characters

aitor <[email protected]> Thu, 11 Apr 2013 15:18:52 +0200
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
I've been testing libxml2 and the "xmlNodeAddContent" function. It turns
out that libxml2 does not enforce XML validity and thus you can create
non well-formed XML using it. However, there is a set of functions under
the chvalid.h header whose purpose is precisely to state whether some
character is valid/invalid etc. Thus, in libxml2 you can do the
following:

  char c[2] = { 7, 0 }; // NULL ending string with the U+0007 char

  if (xmlIsChar_ch(c[0])) {
     // only called if character c[0] is valid
     xmlNodeAddContent(elem, &c[0]);
  } else {
     // c[0] is invalid, so die miserably.
     ...
  }

As far as I know there is no way of using the functions of chvalid.h in
XML::LibXML, right ?

best,
                                aitor
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs