COM 3360 Fall 99 Term Project
Part 1
XML To CD Conversion
Submitted by : Vibhas & Prakash.
Faculty : Prof Karl Lieberherr.
Index
Conversion of XML to Class Dictionary
*Summary
*XML Basics
*Benefits Of The Project
*Our Approach
*Tools Used.
*Terminal Buffer Rule
*LL(1) Grammar
*Test Cases.
*Source Files
*Verifying Results:
*Online Resources
*Conclusion
*Future Work
*
Conversion of XML to Class Dictionary
In this part of the project we have attempted to create a tool which will convert an XML schema into a CD (class dictionary) file that can be fed into Demeter Java. We made use of Sun ‘s Java-2 platform and their APIs for XML. The intent was to create fully conformant class dictionary (which satisfies rules like TBR, LL1 etc) that could utilize the established powerful visitor-style traversals of Demeter Java for XML document processing.
A brief intro to XML :- W3C states that "The Extensible Markup Language (XML) is the universal format for structured documents and data on the Web. It essentially is a set of rules, guidelines, or conventions, for designing text formats in a way that produces files that are easy to generate and read (by a computer), that are unambiguous, and that avoid common pitfalls, such as lack of extensibility, lack of support for internationalization/localization, and platform-dependency. "
Even though it seems like a simple extension of HTML, the difference is that in addition to providing freedom for naming the tags, XML tags specify the semantics of data ("what" the data means) as against HTML tags that specify "how" the data is to be displayed on a browser. And for those who are familiar with authoring software and publication systems, XML is a scaled down version of SGML that is suited particularly well for the web.
XML is a family of rapidly emerging technologies that are platform/vendor independent and very well supported. Some important ones are
The project will create an interface for the XML world to Demeter Java. This will allow systems to make use of the established powerful techniques of Demeter Java (most notably visitor style traversals) for XML systems resulting in flexible XML applications that are easy to develop and maintain. Since various traversal strategies (like Xpath) are still emerging and not well supported as yet, applications that need to query XML documents can benefit immensely from the proven Demeter Java tool.
Our approach was to minimize coding and make use of available APIs to process XML schemas. The intent was also to design a tool that would run on multiple platforms. The obvious choice for the platform was : Java 2. We also decided on making use of Sun ‘s APIs for XML (termed as Java-Project-X) that provides APIs for processing XML schemas.
The tool is designed to ensure that the generated class dictionary does not violate the Terminal Buffer Rule.
The tool is designed to ensure that the grammar in the generated class dictionary is LL(1).
We tested the tool on the following XML schema:
<?xml version="1.0"?>
<INVOICE_COLLECTION>
<INVOICE>
<CUSTOMER>
<NAME> Wile E. Coyote </NAME>
<ADDRESS>Death Valley, CA </ADDRESS>
</CUSTOMER>
<ANNOTATION>
Customer asked that we guarantee return rights if
these items should fail in desert conditions. This
was approved by Marty Melliore, general manager.
</ANNOTATION>
<ENTRIES N="2">
<ENTRY QUANTITY="2" TOTAL_PRICE="134.00">
<PRODUCT MAKER="ACME" PROD_NAME="screwdriver" PRICE="80.00"/>
</ENTRY>
<ENTRY QUANTITY="1" TOTAL_PRICE="20.00">
<PRODUCT MAKER="ACME" PROD_NAME="power wrench" PRICE="20.00"/>
</ENTRY>
</ENTRIES>
</INVOICE>
<INVOICE>
<CUSTOMER>
<NAME>Camp Mertz </NAME>
<ADDRESS> San MAteo, CA </ADDRESS>
</CUSTOMER>
<ENTRIES N="2">
<ENTRY QUANTITY="2" TOTAL_PRICE="32.00">
<PRODUCT MAKER="BSA" PROD_NAME="smoke shifter" PRICE="16.00"/>
</ENTRY>
<ENTRY QUANTITY="1" TOTAL_PRICE="13.00">
<PRODUCT MAKER="BSA" PROD_NAME="snipe call" PRICE="13.00"/>
</ENTRY>
</ENTRIES>
</INVOICE>
</INVOICE_COLLECTION>
This is the CD which is generated corresponding to the above input
List(S) ~ {S}.
INVOICE_COLLECTION = "INVOICE_COLLECTION" List(INVOICE).
INVOICE = "CUSTOMER" <CUSTOMER> CUSTOMER.
= "ANNOTATION" <ANNOTATION> ANNOTATION.
= "ENTRIES" <ENTRIES> ENTRIES.
CUSTOMER = "NAME" <NAME> NAME.
= "ADDRESS" <ADDRESS> ADDRESS.
ENTRIES = "N" <N> N.
= "ENTRY" List(ENTRY).
ENTRY = "QUANTITY" <QUANTITY> QUANTITY.
= "TOTAL_PRICE" <TOTAL_PRICE> TOTAL_PRICE.
= "PRODUCT" <PRODUCT> PRODUCT.
PRODUCT = "MAKER" <MAKER> MAKER.
= "PROD_NAME" <PROD_NAME> PROD_NAME.
= "PRICE" <PRICE> PRICE.
ADDRESS = <A> Ident.
N = <N> Ident.
ENTRY = <E> Ident.
QUANTITY = <Q> Ident.
TOTAL_PRICE = <T> Ident.
PRODUCT = <P> Ident.
MAKER = <M> Ident.
PROD_NAME = <P> Ident.
PRICE = <P> Ident.
Main = .
Can be found on CCS machines at ~vibhasp/com3360/project
Tool Source –
main.javaRun instructions :
java main input.xml output.cdWe are currently in the process of verifying different variations on schema.
Conversion from XML to CD is pretty straightforward because everything is of the form of constructor calls and there are no inheritance edges. The things to watch out for was to make sure that the terminal buffer rule is maintained and that the grammar was LL(1).
To extensively validate all possible generated CDs by running them through Demeter Java. Also the other piece to this process: generation of corresponding behavior files for XML documents will need to be done.