Index: src/OFXMLElementBuilder.h ================================================================== --- src/OFXMLElementBuilder.h +++ src/OFXMLElementBuilder.h @@ -13,10 +13,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" +#import "OFXMLParser.h" @class OFMutableArray; @class OFXMLElement; @class OFXMLElementBuilder; @@ -65,10 +66,20 @@ */ - (void)elementBuilder: (OFXMLElementBuilder*)builder didNotExpectCloseTag: (OFString*)name withPrefix: (OFString*)prefix namespace: (OFString*)ns; + +/** + * This callback is called when the XML parser for the element builder found an + * unknown entity. + * + * \param entity The name of the entity + * \return The substitution for the entity + */ +- (OFString*)elementBuilder: (OFXMLElementBuilder*)builder + foundUnknownEntityNamed: (OFString*)entity; @end /** * \brief A class implementing the OFXMLParserDelegate protocol that can build * OFXMLElements from the document parsed by the OFXMLParser. @@ -75,11 +86,11 @@ * * It can also be used to build OFXMLElements from parts of the document by * first parsing stuff using the OFXMLParser with another delegate and then * setting the OFXMLElementBuilder as delegate for the parser. */ -@interface OFXMLElementBuilder: OFObject +@interface OFXMLElementBuilder: OFObject { OFMutableArray *stack; id delegate; } Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -63,10 +63,15 @@ - (void)setDelegate: (id )delegate_ { OF_SETTER(delegate, delegate_, YES, NO) } + +- (void)parser: (OFXMLParser*)parser + foundProcessingInstructions: (OFString*)pi +{ +} - (void)parser: (OFXMLParser*)parser didStartElement: (OFString*)name withPrefix: (OFString*)prefix namespace: (OFString*)ns @@ -167,10 +172,17 @@ else [[stack lastObject] addChild: element]; [pool release]; } + +- (OFString*)parser: (OFXMLParser*)parser + foundUnknownEntityNamed: (OFString*)entity +{ + return [delegate elementBuilder: self + foundUnknownEntityNamed: entity]; +} @end @implementation OFObject (OFXMLElementBuilderDelegate) - (void)elementBuilder: (OFXMLElementBuilder*)builder didBuildElement: (OFXMLElement*)elem @@ -183,6 +195,12 @@ namespace: (OFString*)ns { @throw [OFMalformedXMLException newWithClass: [builder class] parser: nil]; } + +- (OFString*)elementBuilder: (OFXMLElementBuilder*)builder + foundUnknownEntityNamed: (OFString*)entity +{ + return nil; +} @end