XML streaming parsing with DOM instances
AssigneeInternational Business Machines Corporation
InventorsDhandapani Shanmugam, Michael Gilfix
Life of this patent
Estimating the term…
Abstract
An apparatus, method, and program product are provided for parsing a document. A match point tuple is passed to a parser instance. The match point tuple comprises a match point. The parser instance stream parses an XML stream. In response to a match point statement in the XML stream matching the match point expression in the match point tuple, the parser instance constructs a DOM instance comprising XML content matching the match point. In a sample embodiment, the match point tuple further comprises a filter, and the parser instance adds XML statements that pass the filter to the DOM instance and discards statements that do not pass the filter.
Claims21
A method of parsing a document, the method comprising:
- constructing a parser instance that is configured to:
- stream parse a plurality of XML documents as an XML stream, wherein each of the plurality of XML documents include one or more nodes, wherein each node within the plurality of XML documents is parsed as it is encountered in the XML stream;
- during the stream parsing, detect XML match statements within the plurality of XML documents of the XML stream that match a match point, wherein the match point identifies a location or address within the plurality of XML documents that a desired node of data may be found;
- in response to detecting at least one XML match statement in the XML stream that matches the match point, construct a document object model (DOM) instance, wherein the DOM instance includes:
- the at least one XML match statement in the XML stream that matches the match point;
- and
- a XML content within a node that corresponds to the at least one XML match statement;
- in response to detecting one or more statements in the XML stream that do not match the match point, discard the one or more statements in the XML stream that do not match the match point, wherein the one or more statements in the XML stream that do not match the match point are discarded and garbage collected as they are read;
- inputting the XML stream to the parser instance;
- passing the match point to the parser instance;
- and
- receiving, from the parser instance, the DOM instance.
A method of parsing an XML document by a computer, the method comprising:
- receiving, at a parser instance:
- an XML stream comprising a plurality of XML documents, wherein each of the plurality of XML documents include one or more nodes;
- and
- a match point, wherein a match point identifies a location or address within the plurality of XML documents that a desired node of data may be found;
- the parser instance stream parsing the XML stream, wherein each node within the plurality of XML documents is parsed as it is encountered in the XML stream;
- during the stream parsing, detecting XML match statements within the plurality of XML documents of the XML stream that match the match point;
- in response to detecting at least one XML match statement in the XML stream that matches the match point, the parser instance constructing a document object model (DOM) instance including:
- the at least one XML match statement that matches the match point;
- and
- a XML content within a node corresponding to the at least one XML match statement in the XML stream;
- and
- in response to detecting one or more statements in the XML stream that do not match the match point, discarding the one or more statements in the XML stream that do not match the match point, wherein the one or more statements in the XML stream that do not match the match point are discarded and garbage collected as they are read.
An apparatus for parsing a document, comprising:
- a processor;
- a memory interconnected with the processor;
- and
- a parser instance stored on the memory the parser instance executable by the processor, the parser instance configured to:
- receive an XML stream comprising a plurality of XML documents, wherein each of the plurality of XML documents include one or more nodes;
- receive a match point, wherein the match point identifies a location or address within the plurality of XML documents that a desired node of data may be found and wherein the match point comprises more than one statement;
- stream parse the XML stream, wherein each node within the plurality of XML documents is parsed as it is encountered in the XML stream;
- during the stream parsing, detect XML match statements within the plurality of XML documents of the XML stream that match the match point;
- in response to detecting at least one XML match statement in the XML stream that matches the match point, construct a document object model (DOM) instance including:
- the at least one XML match statement that matches the match point;
- and
- a XML content within a node corresponding to the at least one XML match statement in the XML stream;
- in response to an end statement matching the match point, signal an application with the DOM instance;
- and
- in response to detecting one or more statements in the XML stream that do not match the match point, discard the one or more statements in the XML stream that do not match the match point, wherein the one or more statements in the XML stream that do not match the match point are discarded and garbage collected as they are read.
An apparatus for parsing a document, comprising:
- a processor;
- and
- a memory interconnected with the processor having stored thereon a program of instructions executable by the processor to:
- construct a parser instance that is configured to:
- receive an XML stream comprising a plurality of XML documents, wherein each of the plurality of XML documents include one or more nodes;
- receive a match point, wherein the match point identifies a location or address within the plurality of XML documents that a desired node of data may be found;
- stream parse the XML stream, wherein each node within the plurality of XML documents is parsed as it is encountered in the XML stream;
- during the stream parsing, detect XML match statements within the plurality of XML documents of the XML stream that match the match point;
- in response to detecting at least one XML match statement in the XML stream that matches the match point, construct a document object model (DOM) instance including:
- the at least one XML match statement that matches the match point;
- and
- a XML content within a node corresponding to the at least one XML match statement in the XML stream;
- in response to an end statement matching the match point, signal the program of instruction with the DOM instance;
- and
- in response to detecting one or more statements in the XML stream that do not match the match point, discard the one or more statements in the XML stream that do not match the match point, wherein the one or more statements in the XML stream that do not match the match point are discarded and garbage collected as they are read.
A program product comprising a computer readable device having stored thereon computer executable instructions for:
- constructing a parser instance that is configured to:
- stream parse a plurality of XML documents as an XML stream, wherein each of the plurality of XML documents include one or more nodes, wherein each node within the plurality of XML documents is parsed as it is encountered in the XML stream;
- during the stream parsing, detect XML match statements within the plurality of XML documents of the XML stream that match a match point, wherein the match point identifies a location or address within the plurality of XML documents that a desired node of data may be found;
- in response to detecting an XML match statement in an XML stream that matches a match point, construct a document object model (DOM) instance, wherein the DOM instance includes:
- the XML match statement in the XML stream that matches the match point;
- and
- a XML content within a node that corresponds to the XML match statement;
- in response to detecting one or more statements in the XML stream that do not match the match point, discard the one or more statements in the XML stream that do not match the match point, wherein the one or more statements in the XML stream that do not match the match point are discarded and garbage collected as they are read;
- inputting the XML stream to the parser instance;
- passing the match point to the parser instance;
- and
- receiving, from the parser instance, the DOM instance.
Dependencies are inferred from the claim text.