I saw this code in xmllint.c (removed conditionals that do not apply): static void streamFile(char *filename) { xmlTextReaderPtr reader; int ret; reader = xmlReaderForFile(filename, NULL, options);
if (reader != NULL) { if (valid) xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); else xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); /* * Process all nodes in sequence */ if ((timing) && (!repeat)) { startTimer(); } ret = xmlTextReaderRead(reader); while (ret == 1) { if ((debug) ) processNode(reader); ret = xmlTextReaderRead(reader); } if ((timing) && (!repeat)) { if (valid) endTimer("Parsing and validating"); else endTimer("Parsing"); } if (valid) { if (xmlTextReaderIsValid(reader) != 1) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); progresult = XMLLINT_ERR_VALID; } } /* * Done, cleanup and status */ xmlFreeTextReader(reader); if (ret != 0) { fprintf(stderr, "%s : failed to parse\n", filename); progresult = XMLLINT_ERR_UNCLASS; } } else { fprintf(stderr, "Unable to open %s\n", filename); progresult = XMLLINT_ERR_UNCLASS; } } I tried using the exact same code but I still get the same validation errors on the first call to xmlTextReaderRead... It is vexing me... Any thoughts? Thank you! Best regards: Zoltán Ördögh On Sat, Apr 6, 2013 at 2:00 AM, Zoltán Ördögh (GMail) <csi...@gmail.com>wrote: > Hi all, > I've been using libxml 2.7.7 in the past with BCB6 and it was working fine. > Now I use libxml 2.9.0 with MSVC 2010 (_MSC_VER = 1600) and I get strange > validation errors when I try to read the file back that I wrote out before. > > I am getting a bit frustrated because I am using the exact same code as I > did in BCB6 and despite all my efforts, it always fails. > When I validate the XML with a third-party tool, it all checks out just > fine. > When I run: "xmllint.exe --valid testme.xml", it simply dumps the XML > back without any validation errors. > For some reason, libxml 2.9.0 on MSVC 2010 won't validate it (even though > it's from the same build as xmllint.exe itself). > > This is the code that opens the file: > > #include "libxml/xmlreader.h" > . > . > . > m_pxmlTextReader=xmlReaderForFile(sXML.c_str(), NULL, XML_PARSE_COMPACT | > XML_PARSE_BIG_LINES | XML_PARSE_DTDVALID); > > if(m_pxmlTextReader) > { > if(xmlTextReaderRead(m_pxmlTextReader)==1 && > xmlTextReaderIsValid(m_pxmlTextReader)==1) > { > // processing > } > ... > > > "// processing" is never reached due to the validation errors. > I attached a simple XML with the DTD that can be used to test it in case > you're willing to give it a go. > I captured the errors I see in output.txt, please find it attached. > As you can see from the output, the DTD is found but for some reason, > libxml can't match it vs. the XML file. > > I don't think it's relevant but this is the libxml config that I use at > the moment: > > Config command: > cscript configure.js iconv=no static=yes debug=yes compiler=msvc > prefix=..\..\..\libxml2 > > Build commands: > call "C:\Program Files (x86)\MSVS10\VC\vcvarsall.bat" > nmake /f Makefile.msvc > nmake /f Makefile.msvc install > > Config output: > Microsoft (R) Windows Script Host Version 5.8 > Copyright (C) Microsoft Corporation. All rights reserved. > > libxml2 version: 2.9.0 > Created Makefile. > Created config.h. > > XML processor configuration > --------------------------- > Trio: no > Thread safety: native > FTP client: yes > HTTP client: yes > HTML processor: yes > C14N support: yes > Catalog support: yes > DocBook support: yes > XPath support: yes > XPointer support: yes > XInclude support: yes > iconv support: no > icu support: no > iso8859x support: no > zlib support: no > lzma support: no > Debugging module: yes > Memory debugging: no > Runtime debugging: no > Regexp support: yes > Module support: yes > Tree support: yes > Reader support: yes > Writer support: yes > Walker support: yes > Pattern support: yes > Push support: yes > Validation support: yes > SAX1 support: yes > Legacy support: yes > Output support: yes > XML Schema support: yes > Schematron support: yes > Python bindings: no > > Win32 build configuration > ------------------------- > Compiler: msvc > C-Runtime option: /MD > Embed Manifest: no > Debug symbols: yes > Static xmllint: yes > Install prefix: ..\..\..\libxml2 > Put tools in: $(PREFIX)\bin > Put headers in: $(PREFIX)\include > Put static libs in: $(PREFIX)\lib > Put shared libs in: $(PREFIX)\bin > Include path: . > Lib path: . > > I guess it must be something I have overlooked. > Thank you! > > Best regards: Zoltán Ördögh > >
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org https://mail.gnome.org/mailman/listinfo/xml