OFBiz
  1. OFBiz
  2. OFBIZ-2390

Proof Of Concept: SAX Parsing in Screen Widgets

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Trivial Trivial
    • Resolution: Unresolved
    • Affects Version/s: SVN trunk
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      See the comments for details.

        Activity

        Hide
        Adrian Crum added a comment -

        I had suggested on the developer's mailing list that we look into using SAX XML file parsing in OFBiz instead of the current DOM parsing. The current XML file reading code uses DOM parsing - which results in two parsing passes: one to convert XML into DOM objects, and a second pass to convert the DOM objects into OFBiz objects. Using SAX, the XML elements are converted directly to OFBiz objects - bypassing the DOM tree construction step.

        The responses to my suggestion brought up two points:

        1. The XML files being parsed are relatively small. They are parsed once, then the objects are cached in memory. So, the performance improvement using SAX would be negligible.

        2. SAX parsing code would be more complicated than the current DOM parsing code.

        Point number one is probably right. It was point number two I wanted to explore: How complicated would the SAX parsing code be?

        I found a small public-domain SAX parsing framework, so I started with that. I used the model screen widgets as a test. The conversion was pretty easy, and the SAX parsing code isn't any more complicated than the existing DOM parsing code. The attached patch is the result of my work.

        This Jira issue is here for experimental and educational purposes only. The attached patch is NOT intended to be included in the project.

        Show
        Adrian Crum added a comment - I had suggested on the developer's mailing list that we look into using SAX XML file parsing in OFBiz instead of the current DOM parsing. The current XML file reading code uses DOM parsing - which results in two parsing passes: one to convert XML into DOM objects, and a second pass to convert the DOM objects into OFBiz objects. Using SAX, the XML elements are converted directly to OFBiz objects - bypassing the DOM tree construction step. The responses to my suggestion brought up two points: 1. The XML files being parsed are relatively small. They are parsed once, then the objects are cached in memory. So, the performance improvement using SAX would be negligible. 2. SAX parsing code would be more complicated than the current DOM parsing code. Point number one is probably right. It was point number two I wanted to explore: How complicated would the SAX parsing code be? I found a small public-domain SAX parsing framework, so I started with that. I used the model screen widgets as a test. The conversion was pretty easy, and the SAX parsing code isn't any more complicated than the existing DOM parsing code. The attached patch is the result of my work. This Jira issue is here for experimental and educational purposes only. The attached patch is NOT intended to be included in the project.
        Hide
        Adrian Crum added a comment -

        The attached patch is for trunk revision 769991. It will not be maintained or updated. Please read these comments carefully - I will not answer questions that are already answered here.

        1. This is Proof Of Concept code. It is messy. There are few comments. I'm sure there are many things that could be changed to make it more elegant or more understandable, but that wasn't my goal.
        2. I copied the SAX parsing framework into UtilXml.java. If you want to learn how it works, go here - http://www.javaworld.com/javaworld/jw-03-2002/jw-0329-xmljava2.html?page=1 .
        3. Only the model screen widgets, model screen actions, and model screen conditions were converted to SAX. The rest of the model widgets still use DOM.
        4. SAX parsing is controlled with the widget.parseSAX property in widget.properties. You can switch back and forth between DOM and SAX parsing by changing the property, then clear the caches in Webtools.
        5. This code is not fully tested or debugged. If you encounter an error while using it, then Oh well.

        Show
        Adrian Crum added a comment - The attached patch is for trunk revision 769991. It will not be maintained or updated. Please read these comments carefully - I will not answer questions that are already answered here. 1. This is Proof Of Concept code. It is messy. There are few comments. I'm sure there are many things that could be changed to make it more elegant or more understandable, but that wasn't my goal. 2. I copied the SAX parsing framework into UtilXml.java. If you want to learn how it works, go here - http://www.javaworld.com/javaworld/jw-03-2002/jw-0329-xmljava2.html?page=1 . 3. Only the model screen widgets, model screen actions, and model screen conditions were converted to SAX. The rest of the model widgets still use DOM. 4. SAX parsing is controlled with the widget.parseSAX property in widget.properties. You can switch back and forth between DOM and SAX parsing by changing the property, then clear the caches in Webtools. 5. This code is not fully tested or debugged. If you encounter an error while using it, then Oh well.

          People

          • Assignee:
            Unassigned
            Reporter:
            Adrian Crum
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development