# US 2005/0097455 A1 · Method and apparatus for schema-driven XML parsing optimization

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2005/0097455 A1
- Document ID: US20050097455A1
- Status: Published application
- Kind: A1
- Application number: 10/971,539
- Filed: 2004-10-21
- Published: 2005-05-05
- Earliest claimed: 2003-10-30
- Assignees: Ntt Docomo, Inc.
- Inventors: Dong Zhou; Ali Ismael; Yu Song; Nayeem Islam
- Web page: https://patentgrep.com/patent/US20050097455A1

## CPC

- G06F 40/205: Parsing
- G06F 40/143: Markup, e.g. Standard Generalized Markup Language [SGML] or Document Type Definition [DTD]
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Schema-driven XML parsing techniques allow an XML parser to optimize its parsing process by composing parse and to dynamically generate parsing code components based on XML schema definition for the targeted XML document. These techniques reduce the XML parsing time and reduce the memory requirement during parsing process. Further, a reconfigurable parser is provided which is guided during parsing of the XML document by XML element lexicographical information and state transition information extracted from a schema associated with the XML document. Pre-allocated element object pools may be provided based on the schema analysis to reduce the requirements for dynamic memory allocation and de-allocation operations.

## Claims

### Claim 1

A method for parsing an XML document, comprising:
Performing an analysis of the XML document from an XML schema associated with the XML document to extract one or more relationships between XML elements included in the XML document; and
parsing the XML elements of the XML document guided by relationships extracted in the analysis.

### Claim 2 (depends on 1)

A method as in claim 1, wherein the relationships extracted from the analysis comprises a lexicographical distance between XML elements.

### Claim 3 (depends on 1)

A method as in claim 1, wherein the relationships extracted from the analysis comprises state-transition information.

### Claim 4 (depends on 1)

A method as in claim 1, further comprising providing element object pools that are created upon system initialization.

### Claim 5 (depends on 4)

A method as in claim 4, further comprising, upon parsing an XML element:
retrieving a corresponding element object from the element object pools; and
filling the element object with values extracted from the parsed XML element.

### Claim 6 (depends on 5)

A method as in claim 5, further comprising providing the element object as a node in a parse tree.

### Claim 7 (depends on 5)

A method as in claim 5, wherein the element object is returned to the element object pools.

### Claim 8 (depends on 4)

A method as in claim 4, wherein each element object in the element object pools correspond to an expected data structure of an XML element defined in the XML schema.

### Claim 9

A reconfigurable parser for an XML document, comprising:
an analyzer for extracting from an XML schema associated with the XML document relationships between XML elements included in the XML document; and
a parser of the XML elements of the XML document guided by the relationships extracted by the analyzer.

### Claim 10 (depends on 9)

A reconfigurable parser as in claim 9, wherein the relationships extracted by the analyzer comprises a lexicographical distance between XML elements.

### Claim 11 (depends on 9)

A reconfigurable parser as in claim 9, wherein the relationships extracted by the analyzer comprises state-transition information.

### Claim 12 (depends on 9)

A reconfigurable parser as in claim 9, further comprising element object pools that are created upon system initialization.

### Claim 13 (depends on 12)

A reconfigurable parser as in claim 12, further comprising:
a selector for retrieving a corresponding element object from the element object pools, upon successfully parsing an XML element; and
a writer for filling in the element object with values extracted from the parsed XML element.

### Claim 14 (depends on 13)

A reconfigurable parser as in claim 13, further comprising a parse tree constructor which receives the element object as a node in a parse tree.

### Claim 15 (depends on 13)

A reconfigurable parser as in claim 13, wherein the element object is returned to the element object pools.

### Claim 16 (depends on 12)

A reconfigurable parser as in claim 12, wherein each element object in the element object pools correspond to an expected data structure of an XML element defined in the XML schema.

### Claim 17

A method for efficiently parsing an XML document, comprising:
analyzing a schema associated with the XML document to extract data structures of XML elements of the XML document;
generating parse code for each data structure of the XML elements; and
parsing the XML elements using the generated parse code as the XML document is read.

### Claim 18 (depends on 17)

A method as in claim 17, wherein the generated parse code is compiled.

### Claim 19 (depends on 17)

A method as in claim 17, further comprising reading the XML elements from the XML document one element at a time.

### Claim 20 (depends on 19)

A method as in claim 19, wherein the XML elements are read into the parser according to a push model.

### Claim 21 (depends on 19)

A method as in claim 19, wherein the XML elements are read into the parser according to a pull model.

### Claim 22 (depends on 17)

A method as in claim 17, further comprising validating the XML elements against the XML schema.

### Claim 23 (depends on 17)

A method as in claim 17, further comprising providing the parsed XML elements in a parse tree.

### Claim 24 (depends on 17)

A method as in claim 17, further comprising providing the parsed XML elements one at a time in a continuous stream.

### Claim 25

A parser for an XML document, comprising:
a schema analyzer for extracting data structures of XML elements from a schema associated with the XML document;
a parse code generator that generates a parse code for each data structure of the XML elements; and
a parser integrator that invokes a corresponding parse code in respond to each XML element encountered as the XML document is read.

### Claim 26 (depends on 25)

A parser as in claim 25, wherein the generated parse code is compiled.

### Claim 27 (depends on 25)

A parser as in claim 25, further comprising an XML reader that reads the XML elements from the XML document one element at a time.

### Claim 28 (depends on 27)

A parser as in claim 27, wherein the XML elements are read into the parser according to a push model.

### Claim 29 (depends on 27)

A parser as in claim 27, wherein the XML elements are read into the parser according to a pull model.

### Claim 30 (depends on 25)

A parser as in claim 25, wherein the parse code validates the XML elements against the XML schema.

### Claim 31 (depends on 25)

A parser as in claim 25, further comprising an output module that provides the parsed XML elements in a parse tree.

### Claim 32 (depends on 25)

A parser as in claim 25, further comprising an output module that provides the parsed XML elements one at a time in a continuous stream.
