http://www.w3.org/TR/SVG11/images/coords/PreserveAspectRatio.svg
它抱怨道:
Error Domain=1 Code=27 "Entity 'Smile' not defined
UserInfo=0x7655730
{
lineNumber=26,
NSLocalizedDescription=Entity 'Smile' not defined,
bonusInfo1=Smile,
columnNumber=25
}
...并为每个实体返回WARNING级别错误。似乎没有办法强迫它执行文档所暗示的操作(默认情况下解析实体)。这里有一个神秘的伪解释(http://www.xmlsoft.org/entities.html),说它非常困难,没有人应该自己做...但libxml似乎也没有这样做:(
这是setup结构,用于确认我没有为实体解析提供任何覆盖:
static xmlSAXHandler SAXHandler = {
NULL, /* internalSubset */
NULL, /* isStandalone */
NULL, /* hasInternalSubset */
NULL, /* hasExternalSubset */
NULL, /* resolveEntity */
NULL, /* getEntity */
NULL, /* entityDecl */
NULL, /* notationDecl */
NULL, /* attributeDecl */
NULL, /* elementDecl */
NULL, /* unparsedEntityDecl */
NULL, /* setDocumentLocator */
NULL, /* startDocument */
NULL, /* endDocument */
NULL, /* startElement*/
NULL, /* endElement */
NULL, /* reference */
charactersFoundSAX, /* characters */
NULL, /* ignorableWhitespace */
NULL, /* processingInstruction */
NULL, /* comment */
NULL, /* warning */
errorEncounteredSAX, /* error */
NULL, /* fatalError //: unused error() get all the errors */
NULL, /* getParameterEntity */
cDataFoundSAX, /* cdataBlock */
NULL, /* externalSubset */
XML_SAX2_MAGIC,
NULL,
startElementSAX, /* startElementNs */
endElementSAX, /* endElementNs */
structuredError, /* serror */
};
答案 0 :(得分:1)
这是libxml中的一个巨大的错误,它似乎已经存在了 - 似乎 - 有时候。
文档(http://www.xmlsoft.org/html/libxml-parser.html#xmlCreatePushParserCtxt)说:
xmlParserCtxtPtr xmlCreatePushParserCtxt (xmlSAXHandlerPtr sax,
void * user_data,
const char * chunk,
int size,
const char * filename)
sax: a SAX handler
user_data: The user data returned on SAX callbacks
但他们应该说的是:
sax: a SAX handler
user_data: YOU MUST NOT USE THIS BECAUSE LIBXML IS BADLY
BROKEN INTERNALLY. NEVER PASS ANYTHING EXCEPT NULL TO
THIS PARAMETER. ENTITIES WILL NEVER WORK IF YOU PASS
ANYTHING EXCEPT NULL.
即。您不能使用“userdata”指针,而是必须编写自己的静态变量(某处)并使用它们来跟踪状态,因为libxml不允许您自己跟踪状态。
(我最终在邮件列表中找到了一个引用,其中有人问为什么会这样,并要求更新文档并发出警告)
顺便说一句,这解释了我在其他使用libxml的iOS项目中看到的一些与实体相关的问题。很多天浪费在这个单一的bug /坏文档上:(。叹息。