Patent ID: 6990632

Claim:
A method for inferring a schema from an electronic document containing hierarchical data comprising: in an application program, receiving the electronic document containing the hierarchical data, wherein the hierarchical data includes a plurality of nodes; (a) parsing the hierarchical data in the electronic document to discover one of the plurality of nodes; (b) saving a plurality of content associated with the discovered node to a memory location; (c) repeating tasks (a)–(b) until the plurality of content for each discovered node has been saved to the memory location; and generating the schema based on the plurality of content saved for each discovered node, wherein generating the schema based on the plurality of content saved for each discovered node comprises: retrieving the plurality of content for each discovered node in the plurality of discovered nodes from the memory location in the memory; and generating schema elements for each discovered node in the plurality of discovered nodes based on the retrieved plurality of content, wherein the schema elements are generated starting from a root node and continuing to one or more child nodes in the plurality of discovered nodes, and wherein the schema elements represent the schema for the hierarchical data, wherein generating schema elements for each discovered node based on the retrieved plurality of content comprises: determining whether each discovered node is a repeating node; if any of the discovered nodes is repeating, determining if the repeating nodes are repeating out of sequence; if the repeating nodes are repeating out of sequence, specifying the occurrences of the repeating nodes as unbounded; determining whether any of the discovered repeating nodes has any child nodes; if any of the discovered repeating nodes have any child nodes, determining if any of the child nodes are repeating; if none of the child nodes node are repeating nodes, annotating the discovered child nodes with an all compositor; if any of the child nodes are repeating nodes, determining whether any of the repeating child nodes are repeating out of sequence; if any of the child nodes are repeating out of sequence, annotating the child nodes with a sequence compositor; and if any of the child nodes are repeating in sequence, annotating the child nodes with a sequence unbounded compositor; wherein the hierarchical data is XML data, and wherein the application program is a spreadsheet application program.