The present invention generally relates to the field of software, and more particularly to a method of application-specific processing of XML files.
Extensible Markup Language (XML) is a widely accepted standard for describing data. XML is a standard that allows an author/programmer and the like to describe and define data (e.g., type and structure) as part of the XML content/document. XML uses syntax tags to identify various types of data in a file. Since XML content may describe data, any application that understands XML regardless of the applications programming language and platform has the ability to process the XML based content.
An XML parser is a software program that reads XML files and makes the information from those files available to applications and programming languages, usually through a known interface. The XML content may optionally reference another document or set of rules that define the structure of an XML document/content. This other document or set of rules is often referred to as a schema. When an XML document references a schema, some parsers may check for validity in which the parser determines if the document follows the rules schema.
The Extensible Markup Language (XML) has become the industry standard for exchanging data across systems because of the language's flexibility and consistent syntax. However, conventional XML parsing (e.g., parsing by use of a general-purpose external parser) is slow in many applications. General-purpose parsers process XML content into general-purpose data structures, then apply run-time analysis to rebind the data to application-specific structures. Extra space is consumed by intermediate data structures (e.g., general purpose data structures) and extra time may be spent creating and analyzing them. Moreover, it is labor intensive to write the conversion code that converts the general-purpose data structures to application-specific data structures required for final processing.
There are three broad types of conventional XML parsers: SAX (Simple API for XML) parsers, DOM (Document Object Model) parsers, and data-binding parsers. Typical commercially available parsers use DOM parsers and SAX parsers together. Each type of XML parser defines a standard for accessing and manipulating XML documents. However, each of these parsers.
A SAX parser uses an event-driven model to process XML content. A SAX parser initiates a series of events as it reads an XML document from beginning to end. The events are passed to event handlers, which provide access to the content in the document. Some of these event handlers check the syntax of the XML document (e.g., syntactic events). In conventional SAX parsers, a developer has to program the event handlers (e.g., developer-written events). In addition, a SAX parser invokes developer-written callback routines to manage the syntactic events. A callback routine is a routine that is executed as part of the operation of some other routine. A limitation of the SAX parser is the requirement for manual programming of the event handlers and callback routines. Further, the conventional SAX parser perform a number of routines such as scanning the XML input multiple times, creating a number of intermediate data structures and the like while facilitating the parsing of the XML document require a great deal of time to perform.
In contrast to a SAX parser, a DOM parser first parses an XML document to build an internal, tree-shaped representation of the XML document. An application programmer interface (API) is then employed to access the contents of the document tree for further analysis. Such configuration results in slow parsing because the state information that is required for analysis was available at parse time resulting in a redundancy. In addition, DOM parsers typically limit parallel processing by building the tree before invoking analysis code.
In addition, a data-binding parser operates by mapping XML elements to element-specific objects. Such parsers are limited for data-binding engines often use high-cost methods such as reflection and run-time rule evaluation.
Therefore, it would be desirable to provide a method and an apparatus for performing XML parsing which is cost-effective and not as labor intensive as conventional parsers.
In a first aspect of the present invention, a method of XML parsing is provided. In an exemplary embodiment, the method may include: parsing an XML document; constructing an XML XPATH which includes at least one XML XPATH tag; constructing a JAR file of Java classes which include at least one package path that matches the at least one XML XPATH tag; accessing the JAR file of Java classes which include the at least one package path that matches the at least one XML XPATH tag; and transferring the at least one XML XPATH tag to the JAR file of Java classes including the at least one package path that matches the at least one XML XPATH tag for processing.
In a further aspect of the present invention, a computer program product, including a computer useable medium with computer usable program code for creating a method for XML parsing is provided. The computer program product may include: computer usable program code for parsing an XML document; computer usable program code for constructing an XML XPATH with at least one XML XPATH tag; computer usable program code for constructing a JAR file of Java classes which include at least one package path that matches the at least one XML XPATH tag; computer usable program code for accessing the JAR file of Java classes which include the at least one package path that matches the at least one XML XPATH tag; and computer usable program code for transferring the at least one XML XPATH tag to the JAR file of Java classes including the at least one package path that matches the at least one XML XPATH tag for processing.
In an additional aspect of the present invention, a method of parsing an XML document is provided. The method may include constructing an interface for at least one XML tag. The method may also include creating a Java class to process the at least one XML tag. For example, the Java class includes code to evaluate at least one attribute of the at least one XML tag. In addition, the method may include parsing of the XML document by processing the at least one attribute of the at least one XML tag.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not necessarily restrictive of the invention as claimed. The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate an embodiment of the invention and together with the general description, serve to explain the principles of the invention.
The numerous advantages of the present invention may be better understood by those skilled in the art by reference to the accompanying figures in which:
Reference will now be made in detail to the presently preferred embodiments of the invention, examples of which are illustrated in the accompanying drawings.
Referring to
In further exemplary embodiments, the method 100 of XML parsing includes constructing a JAR (abbreviation for Java Archive) file of Java classes which include at least one package path that matches the at least one XML XPATH tag 106. A JAR file may be a file used to distribute a set of Java classes or to store compiled Java classes and associated metadata that may constitute a program. In an embodiment, the at least one XML XPATH tag includes a tag attribute XML document file descriptor.
The method 100 may include accessing the JAR file of Java classes which include the at least one package path that matches the at least one XML XPATH tag 108. For example, accessing the JAR file of Java classes 108 is performed by a SAX parser. In such example, the SAX parser accesses the JAR file of Java classes by a class loader.
In addition, the method 100 includes transferring the at least one XML XPATH tag to the JAR file of Java classes including the at least one package path that matches the at least one XML XPATH tag for processing 110. For example, transferring the at least one XML path tag to the JAR file of Java classes includes transferring the tag attribute XML document file descriptor.
Referring to
The method 200 may also include creating a Java class to process the at least one XML tag 204. For example, as illustrated in
In addition, the method 200 may include parsing of the XML document by processing the at least one attribute of the at least one XML tag 206. In an embodiment, parsing of the XML document by processing the at least one attribute of the at least one XML tag 206 is performed by a SAX parser. For instance, the exemplary XML document provided in
It is to be understood that the present invention may be implemented by using compiler technology to automatically generate a fast and small application specific parser. In such embodiment, an XML input file and two or more specifications are provided. Each specification may include two components: (1) an XML schema that specifies syntax, data elements, and data types and (2) semantic actions that include a pairing of an XPath string and an action code. The specifications and the XML input file are used to generate a state machine and state transition sequences that invoke the semantic actions. The state transition sequences are then used to generate the application-specific XML parser.
An exemplary method of generating an XML parser may include receiving an XML input file and specifications each comprising an application specific XML schema and semantic action, where the XML input file is compliant with the XML schema and the semantic action. In an embodiment, the input is in a format of JAR file. The method may also include generating a state machine in response to the specifications and generating state transition sequences in response to specifications and in response to the state machine. An application-specific parser may then be generated in response to the state transition sequences.
It is to be understood that the disclosed invention may be employed in a number of systems including embedded systems such as a Service Management Framework (SMF). Further, the present invention may be utilized by consulting services such as WebSphere Commerce (WCS) and WebSphere Business Integration (WBI). In addition, the invention may be used in performance critical applications such as SMF and web services. It is to be further understood that although the present disclosure presents exemplary embodiments involving Java programming language, any programming language with similar packaging mechanism as Java may be employed.
It is contemplated that the invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment containing both hardware and software elements. In a preferred embodiment, the invention is implemented in software, which includes but is not limited to firmware, resident software, microcode, and the like. Furthermore, the invention may take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or any instruction execution system. For the purposes of this description, a computer-usable or computer readable medium may be any apparatus that may contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
It is further contemplated that the medium may be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium. Examples of a computer-readable medium include a semiconductor or solid state memory, magnetic tape, a removable computer diskette, a random access memory (RAM), a read-only memory (ROM), a rigid magnetic disk and an optical disk. Current examples of optical disks include compact disk—read only memory (CD-ROM), compact disk—read/write (CD-R/W) and DVD.
A data processing system suitable for storing and/or executing program code will include at least one processor coupled directly or indirectly to memory elements through a system bus. The memory elements may include local memory employed during actual execution of the program code, bulk storage, and cache memories which provide temporary storage of at least some program code in order to reduce the number of times code must be retrieved from bulk storage during execution.
Input/output or I/O devices (including but not limited to keyboards, microphone, speakers, displays, pointing devices, and the like) may be coupled to the system either directly or through intervening I/O controllers.
Network adapters may also be coupled to the system to enable the data processing system to become couple to other data processing systems or storage devices through intervening private or public networks. Modems, cable modem and Ethernet cards are just a few of the currently available types of network adapters.
It is understood that the specific order or hierarchy of steps in the foregoing disclosed methods are examples of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the method can be rearranged while remaining within the scope of the present invention. The accompanying method claims present elements of the various steps in a sample order, and are not meant to be limited to the specific order or hierarchy presented.
It is believed that the present invention and many of its attendant advantages is to be understood by the foregoing description, and it is apparent that various changes may be made in the form, construction and arrangement of the components thereof without departing from the scope and spirit of the invention or without sacrificing all of its material advantages. The form herein before described being merely an explanatory embodiment thereof, it is the intention of the following claims to encompass and include such changes.
The present application is a continuation of U.S. application Ser. No. 11/382,280 filed May 9, 2006, which is a continuation-in-part under 35 U.S.C. § 120 of U.S. application Ser. No. 11/214,566 filed on Aug. 30, 2005. Said U.S. application Ser. Nos. 11/382,280 and 11/214,566 are hereby incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | 11382280 | May 2006 | US |
Child | 12057639 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 11214566 | Aug 2005 | US |
Child | 11382280 | US |