Resolve class conflict while deploying XMLC in environment containing Xerces implementation such as Tomcat and Ant.
XMLC reloading has been removed in 2.1 release due to its dependency on servlet containers. Richard Kunze has created a new paradigm for reloading based on deferred parsing. This change is independent of the containers.
The word reloading has been a confusing term regarding to XMLC. This note is trying to clearify the subjects.
The document of how to use the taskdef can be found in Java docs for org.enhydra.xml.xmlc.taskdef.XMLC. Thanks to Barracuda team.
Deferred parsing has been extended to load XMLCObject from HTML document without compilation.
XHTML support has been improved.
xpath support is under development. The examples directory has an example of XPath using JAXEN and JXPath.
Page reloading in XMLC has gone through several different revision. The following is trying to clearify how XMLC handling the page loading.
This is the default implementation of XMLC. It compile the *ML files into Java object with concrete codes/methods to build the DOM tree at runtime. New pages have to be recompiled and applications have to be restarted for the new presentation to take effect.
This is a feature specific to Enhydra Application Server. The page from which the Java PO is compiled from are monitor and, up one the update of the page, the system would perform the recompilation and reloading of the PO. This feature has been used in Enhydra Application Server but the feature was removed in XMLC 2.1 Standalone. In 2.2, this feature is replaced by the Deferred parsing reloading described below.
This is the new feature introduced in XMLC 2.2 to support runtime reloading of updated *ML files. Deferred parsing compiles ML files and creates stub PO objects to hold meta info about the documents to be processed. The document is parsed and loaded into system as DOM upon the request for the object. The ML files are monitored and reparsing/reloading is performed when the files are updated.
This is an experimental new feature introduced in XMLC 2.2. This feature allow XMLC runtime to load *ML files without prior compilation of the ML files. Additional note can be found here
This is a step by step instruction to set up the build and deployment environment to utilize reload.
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.
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.
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
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.
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.
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.