Open tinchodias opened 2 months ago
For the record, this might be a starting point to evaluate this issue/idea:
BlSvgHandler
as a subclass of SAX2ContentHandler
startElement: aQualifiedName attributes: anAttributeDictionary
with a halt or trace.svgString
variable and run:
parser := SAX2Parser on: svgString.
handler := BlSvgHandler new.
parser contentHandler: handler.
parser parseDocument
In short, the XMLParser project provides tests and examples to read XML without creating a XMLnode instance for each read node. As a reference, see subclasses of
SAX2ElementHandler
in 'XML-Parser-Tests'.Right now, when we want to get
BlElement
s from a SVG string, something like this is the first step:XMLDOMParser parse: '<svg ........ </svg>'
. The parser (in 'XML-Parser' package), outputs aBlElement
that might be in fact a tree of elements. My question is not about the output, but about what happens in the middle to create it: The "dom" that the parser returns is "visited" by the Bloc'sBlSvgFactory
.The factory will execute this method on each SVG's node:
that will send a message according to the name of the svg's element that is being read (e.g. rect, circle, path, g). That method will then read the attributes by querying each XML node like this:
EDIT: As an example, parsing the classical tiger creates a DOM with 1200 nodes.