The subject matter, which is regarded as the invention, is particularly pointed out and distinctly claimed in the claims at the conclusion of the specification. The foregoing and other objects, features, and advantages of the invention are apparent from the following detailed description taken in conjunction with the accompanying drawings in which:
One aspect of the exemplary embodiments is a method for integrating validation and parsing processes. Another aspect of the exemplary embodiments is a method for allowing a validation engine to be written in a recursive-descent code-driven manner.
A recursive descent parser is a top-down parser built from a set of mutually-recursive procedures (or a non-recursive equivalent) where each such procedure usually implements one of the production rules of the grammar. Thus the structure of the resulting program closely mirrors that of the grammar it recognizes. Code-driven refers to the design style that is common in some handcrafted programs. In general, there are three styles of code in generated programs. In a program-generation system, the need for understanding and change occurs at the specification level, not the program level. This results in greater flexibility in the design of generated programs. Three styles of generated programs are known. The OO (Object Oriented) approach favors highly structured OO techniques. The code-driven approach favors straightforward code with embedded data. The table-driven approach puts data in a separate data section that is used by the code section. A typical program generator will use some combination of these three techniques. In the exemplary embodiments, a generated code is preferred, which is generated from the DTD or other grammar information for the XML dialect. From the generated code an XML parser that is code-driven or table-driven may be generated. In most cases, most of the code for the parser is static and unchanging, but tables are generated from the DTD. In other words, these current solutions are table-driven because that is the only viable approach. The exemplary embodiments of the present invention allow for a code-driven approach.
Once a class of XML documents is defined, there is a need for a method of navigating through the XML documents. XML cursors are a way to navigate through an XML instance document. Once a user loads an XML document, the user may create a cursor to represent a specific place in the XML document. Because a user may utilize a cursor with or without a schema corresponding to the XML document, cursors are an ideal way to handle XML documents without the schema. With the XML cursor, the user may utilize a token model to move through the XML document in small increments, or in a manner similar to using a DOM-based model.
In the exemplary embodiments of the present application, the validator-driven architecture has a validation engine drive the tokenizer and the tokenizer produces one token at a time, as needed by the validation engine. This enables the validation engine to be written in a recursive-descent code-driven manner. This results in a faster validating parser, without large tables, and with a clear control flow through the whole parsing and validation process. This makes the validation code easier to write, test, maintain, and extend, as well as making the code shorter and faster.
Below is one example of an algorithm containing the validation code written in a recursive-descent code-driven manner. In particular, at any given point in the parse, the parsing engine maintains a pointer in the XML buffer, as well as other states, as appropriate. The validating engine maintains control of the parse, and engages the parsing engine when it requires a next piece of information from the XML instance document, using for example a call function GetNextTag( ). Consider the following DTD fragment:
In
In
In
Processing continues in this manner until the validating engine 10 completes a path through the entire XML document. The validation code is very straightforwardly an implementation of this particular DTD fragment, and thus the validation code could be written in a generic manner to process any DTD, and validate the XML instance document against it.
Referring to
Referring to
The capabilities of the present invention can be implemented in software, firmware, hardware or some combination thereof.
As one example, one or more aspects of the present invention can be included in an article of manufacture (e.g., one or more computer program products) having, for instance, computer usable media. The media has embodied therein, for instance, computer readable program code means for providing and facilitating the capabilities of the present invention. The article of manufacture can be included as a part of a computer system or sold separately.
Additionally, at least one program storage device readable by a machine, tangibly embodying at least one program of instructions executable by the machine to perform the capabilities of the present invention can be provided.
The flow diagrams depicted herein are just examples. There may be many variations to these diagrams or the steps (or operations) described therein without departing from the spirit of the invention. For instance, the steps may be performed in a differing order, or steps may be added, deleted or modified. All of these variations are considered a part of the claimed invention.
While the preferred embodiment to the invention has been described, it will be understood that those skilled in the art, both now and in the future, may make various improvements and enhancements which fall within the scope of the claims which follow. These claims should be construed to maintain the proper protection for the invention first described.