XMLC 2.2 Release Note

New features in 2.2

Note on Setting up Deferred Parsing

This is a step by step instruction to set up the build and deployment environment to utilize reload.

  1. Compile the pages with '-for-deferred-parsing' argument for XMLC.

    For those who's using XMLC taskdef, use the <arg> in the xmlc task.

    <xmlc ...>
       <arg value="-for-deferred-parsing"/>
    </xmlc>

    In addition to the class/java file for the document, XMLC will also generate a '.xmlc' files for per file meta files. If xmlc in command lines to compile the document, the file is generated to the same location as the class files. Otherwise, it's generated to the same directory as the generated source files.

  2. Replace org.enhydra.xml.xmlc.XMLCStdFactory

    The deferred parsing is performed by the new factory class org.enhydra.xml.xmlc.deferredparsing.XMLCDeferredParsingFactory. XMLCDeferredParsingFactory extends XMLCStdFactory and should be a drop in replacement in the existing codes.

    It should be noted that XMLCStdFactory object only serves as a document class loader and document object initializer while XMLCDeferredParsingFactory perform additional caching operation on the parsed html pages. If the program creates a new Factory object to load documents every time, it should be changed to share Factory to avoid performance penalty while using reloading.

  3. Deploying HTML pages.

    The new Factory requires locating the HTML pages used to generate the XMLC document class. This would probably be the most confusing part for the reloading.

    The following is the search argorithm of the html pages

    1. Load from classpath by default

      it's using the original file name in the package directory of the class. For example, foo.html is compiled to com.foo.bar.testHTML. By default, the Factory is looking for the class in the com/foo/bar/test.html in class path.

    2. Additional configuration

      • addPackagePrefix(String pkg)

        this add package prefix to be stripped while searching for html files. This has the reverse effect as the packagedir in the XMLC taskdef. It takes out the prefix from the path of the html file.

        For example, if com.foo is added as a package prefix, the Factory willl search for com/foo/bar/test.html as well as bar/test.html.

      • addResourceDir(String dir)

        Add additional directory to search for the html files.

Note on Setting up Deferred Parsing

A new method createFromFile(String path) has been added to the XMLCDeferredParsingFactory. This method lets the program to load xml/html pages into the system as org.w3c.dom.Document/org.w3c.dom.html.HTMLDocument wihtout having to pre-compile them using XMLC. For example factory.createFromFile("bar/test.html") will try to load the document from the class path as well as resource directories.

Dynamic loading of new page requires a meta file to be spcified using the setMetaDataFile(String path) of the factory. Searching for the meta file follows the same rule as the xml/html files.