SVGKParserExtension.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. SVGParserExtension.h
  3. A protocol that lets us split "parsing an SVG" into lots of smaller parsing classes
  4. PARSING
  5. ---
  6. Actual parsing of an SVG is split into three places:
  7. 1. High level, XML parsing: SVGParser
  8. 2. ALL THE REST, this class: parsing the structure of a document, and special XML tags: any class that extends "SVGParserExtension"
  9. */
  10. #import <Foundation/Foundation.h>
  11. #import "SVGKSource.h"
  12. @class SVGKParseResult;
  13. #import "SVGKParseResult.h"
  14. #import "Node.h"
  15. /*! Experimental: allow SVGKit parser-extensions to insert custom data into an SVGKParseResult */
  16. #define ENABLE_PARSER_EXTENSIONS_CUSTOM_DATA 0
  17. @protocol SVGKParserExtension <NSObject>
  18. /*! Array of URI's as NSString's, one string for each XMLnamespace that this parser-extension can parse
  19. *
  20. * e.g. the main parser returns "[NSArray arrayWithObjects:@"http://www.w3.org/2000/svg", nil];"
  21. */
  22. -(NSArray*) supportedNamespaces;
  23. /*! Array of NSString's, one string for each XML tag (within a supported namespace!) that this parser-extension can parse
  24. *
  25. * e.g. the main parser returns "[NSArray arrayWithObjects:@"svg", @"title", @"defs", @"path", @"line", @"circle", ...etc... , nil];"
  26. */
  27. -(NSArray*) supportedTags;
  28. /*!
  29. Because SVG-DOM uses DOM, custom parsers can return any object they like - so long as its some kind of
  30. subclass of DOM's Node class
  31. */
  32. - (Node*)handleStartElement:(NSString *)name document:(SVGKSource*) document namePrefix:(NSString*)prefix namespaceURI:(NSString*) XMLNSURI attributes:(NSMutableDictionary *)attributes parseResult:(SVGKParseResult*) parseResult parentNode:(Node*) parentNode;
  33. /**
  34. Primarily used by the few nodes - <TEXT> and <TSPAN> - that need to post-process their text-content.
  35. In SVG, almost all data is stored in the attributes instead
  36. */
  37. -(void)handleEndElement:(Node *)newNode document:(SVGKSource *)document parseResult:(SVGKParseResult *)parseResult;
  38. @end