What are the new features in XML4J version 2? Modular architecture XML4J's new architecture means that you only pay for the features that you use. This will allow
you to construct a parser configuration which only includes those features that your application needs, thus reducing the number of class files (or size of the jar file) required. It also means that we will be able to add new
functionality more easily, and that developers will be able to extend the functionality of the parser in new ways. As examples of this extensibility, XML4J version 2 offers:
- Pluggable Validator
This allows the DTD based validator to be replaced with a validator based on some other method, such as the DCD, SOX, or DDML proposals under consideration in the W3C.
- Pluggable DOM implementation
This allows a customized DOM implementation to be supplied. The TX compatiblity classes are implemented using this feature.
- Pluggable Catalog Support
Support for a catalog is modular. In this release, we support provide two catalog modules.
Performance The performance of XML4J has been greatly improved in version 2. This is especially true for SAX. Footprint The main-memory footprint of XML4J has improved in version 2. This is especially true for
SAX. Validating SAX One of the benefits of the new architecture is that we are able to offer a validating parser that uses the SAX API XCatalog In addition to supporting SGML Open catalogs, XML4J version 2 now
supports version 0.2 of the XCatalog specification. Revalidation XML4J version 2 will allow you to invoke the validator on a DOM tree after parsing has completed. This allows you to modify the DOM tree programatically and
then check to make sure that the resulting tree is valid.
What features are not supported in this new release?
- This release does not yet provide the readDTDStream() method on the TX Compatibility parser.
What international encodings are supported by XML4J?
- UTF-8
- UTF-16 Big Endian, UTF-16 Little Endian
- IBM-1208
- ISO Latin-1 (ISO-8859-1)
- ISO Latin-2 (ISO-8859-2) [Bosnian, Croatian, Czech,
Hungarian, Polish, Romanian, Serbian (in Latin transcription),
Serbocroatian, Slovak, Slovenian, Upper and Lower Sorbian]
- ISO Latin-3 (ISO-8859-3) [Maltese, Esperanto]
- ISO Latin-4 (ISO-8859-4)
- ISO Latin Cyrillic (ISO-8859-5)
- ISO Latin Arabic (ISO-8859-6)
- ISO Latin Greek (ISO-8859-7)
- ISO Latin Hebrew (ISO-8859-8)
- ISO Latin-5 (ISO-8859-9) [Turkish]
- Extended Unix Code, packed for Japanese (euc-jp, eucjis)
- Japanese Shift JIS (shift-jis)
- Chinese (big5)
- Chinese for PRC (mixed 1/2 byte) (gb2312)
- Japanese ISO-2022-JP (iso-2022-jp)
- Cyrllic (koi8-r)
- Extended Unix Code, packed for Korean (euc-kr)
- Russian Unix, Cyrillic (koi8-r)
- Windows Thai (cp874)
- Latin 1 Windows (cp1252)
- cp858
- EBCDIC encodings:
- EBCDIC US (ebcdic-cp-us)
- EBCDIC Canada (ebcdic-cp-ca)
- EBCDIC Netherland (ebcdic-cp-nl)
- EBCDIC Denmark (ebcdic-cp-dk)
- EBCDIC Norway (ebcdic-cp-no)
- EBCDIC Finland (ebcdic-cp-fi)
- EBCDIC Sweden (ebcdic-cp-se)
- EBCDIC Italy (ebcdic-cp-it)
- EBCDIC Spain & Latin America (ebcdic-cp-es)
- EBCDIC Great Britain (ebcdic-cp-gb)
- EBCDIC France (ebcdic-cp-fr)
- EBCDIC Hebrew (ebcdic-cp-he)
- EBCDIC Switzerland (ebcdic-cp-ch)
- EBCDIC Roece (ebcdic-cp-roece)
- EBCDIC Yugoslavia (ebcdic-cp-yu)
- EBCDIC Iceland (ebcdic-cp-is)
- EBCDIC Urdu (ebcdic-cp-ar2)
- Latin 0 EBCDIC
- EBCDIC Arabic (ebcdic-cp-ar1)
Which version of Swing is required by XML4J?
This release uses Swing 1.1 (JFC 1.1). Swing is only used by the sample code. It is not required by the parser itself.
How can I recompile all the XML4J source files?
XML4J version 2 comes bundled with Bourne shell script files which can be used to compile all the sources. These scripts can be found in the build directory. To run these scripts you will need a Unix shell (Bourne Shell (sh),
Korn Shell (ksh), Z-Shell (zsh), Bash (bash), etc...). A number of commercial and public domain shells are available. We have tested these scripts using the MKS Toolkit (commercial) and Cygnus Cygwin toolkit version B20 (GNU
General Public License). More details can be found in the ReadmePub.txt file in the build directory. Alternatively, you can include all the source files in any Java Integrate Development Environment project file and build the project.
NOTE: The scripts output the class files in a separate directory.
How can I regenerate the Javadoc API files?
The script makeApiDocs.ksh generates the API documentation. This script can be found in the build directory. More details can be found in the buildReadmePub.txt file.
How can I package my own parser configuration?
XML4J version 2 allows you have a number of parser configurations: validating or non-validating SAX, validating or non-validating DOM, validating or non-validating TXDOM. Not all of these configurations require all the files in the
XML4J version 2 distribution. To reduce disk footprint or download time, you can package just the files that you need for these configurations. To aid you in doing this, we've provided some scripts to help with this process.
In order to create a custom package, you need to extract the contents of the XML4J version 2 jar file to a new directory.
- Create a new directory under the distribution directory (xml4j2_n_n), say configuration.
- Copy the xml4j.jar file into configuration.
- Make configuration your current directory by 'cd'ing there.
- To extract the contents of the jar, type jar xf xml4j.jar. (You need to be sure that the jar program from the Sun JDK is in your path.)
After you have extracted the contents of the jar, you can then run one of the configuration scripts. If you are running Windows, the path to the script is
..\build\config.bat, and if you are running UNIX, the path is ../build/config.sh. The configuration script takes 2 arguments. The first argument specifies which
parser configuration you want to build. The available configurations are:
Command line argument |
Desired Configuration |
SAX |
non-validating SAX |
VSAX |
validating SAX |
DOM |
validating DOM |
NVDOM |
non-validating DOM |
TXDOM |
validating TX-compatibility DOM |
NVTXDOM |
non-validating TX-compatibility DOM |
The second argument specifies which kind of catalog support (if any) you want:
Command line argument |
Desired Catalog Support |
|
no catalog support |
TXCATALOG |
TXCatalog (XML4J v1.X compatible) |
XCATALOG |
XCatalog |
So to create a non validating DOM parser that included XCatalog support, you would type:
..\build\config.bat NVDOM XCATALOG (on Windows)../build/config.sh NVDOM XCATALOG (on UNIX)
The script will create a jar file called custom.jar in the current directory, which is configuration in this example. This jar file contains only the classes that are needed for this parser configuration.
How can I import XML4J into Visual Age for Java?
- Why does VisualAge for Java 2.0 report problems when I import the XML4J parser?
The current version of the XML4J parser uses Swing 1.1, while VisualAge for Java 2.0 comes with Swing 1.0.2. The free update for the
Professional version of VisualAge for Java 2.0 installs Swing 1.0.3. The most important difference between Swing 1.0.2 - 1.0.3 and 1.1 is the Java package was changed from com.sun.java.swing.* to javax.swing.*.
To fix the errors, you must download the Java Foundation Classes 1.1 with Swing 1.1 from Sun's Java home page and import the "swingall.jar" file into VisualAge for Java 2.0. The Swing 1.1 package can be found at
the following URL: http://java.sun.com/products/jfc/index.html
Refer to the VisualAge for Java 2.0 documentation for information about how to import a JAR file into the repository and add that code to your workspace.
- Are there any other tips for importing the XML4J parser into VisualAge for Java 2.0?
The most useful tip applies to *any* updated code that you import into the VisualAge for Java 2.0 product. Before updating code, do the
following: 1. version the old code 2. delete it from your workspace 3. import the new code
Deleting code from your workspace does not actually delete the code permanently -- the versioned code is moved to the repository where it can be retrieved later. Be aware, though, that removing code from your
workspace will cause problems with all of the other classes that use that code. VisualAge for Java 2.0 will flag them as errors but this situation is temporary. When you import the new code, the errors found when
deleting the old code will be fixed.
If you are unsure as to how to perform any of these steps, refer to the VisualAge for Java 2.0 documentation.
Is XML4J version 2 100% Pure Java compliant?
XML4J has not been formally certified to be 100% pure Java compliant. However, it is capable of being certified, as part of your product. Running 'JavaPureCheck' results in a few warnings. As required, the explanations for
these warning are given below.
############# JavaPureCheck Report ################## # # Generated on : February 2, 1999 4:04:26 PM PST
# System Model Version : jdk11 # JavaPureCheck Version : 3.15 # Rule Base Version : 1.92 # # Summary: # # PURE: 281 WARNING: 5 ERROR: 0 #
# Final Result : WARNING # ####################################################
Class: org.xml.sax.helpers.ParserFactory Warning: method reference: java.lang.Class.forName(java.lang.String)
Note: May load impure class Status: WARNING Explanation: The ParserFactory class is part of the SAX distribution and is used to instantiate, by name, classes that
implement the Parser interface. The XML4J parser, version 2, does not use this class except in sample test code. Class: com.ibm.xml.internal.msg.Message
Warning: possible hard-coded path: Character reference, "&//{0};", is out of range. Note: Defines a bad path
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Warning: possible hard-coded path: Character reference, "&//x{0}", is out of range. Note: Defines a bad path
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Warning: possible hard-coded path: Warning: attribute "xml:space" is recommended to be declared as "xml:space (default|preserve) //IMPLIED". Note: Defines a bad path
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Warning: possible hard-coded path: Attribute default declaration expected. ("//REQUIRED", "//IMPLIED", or "//FIXED") Note: Defines a bad path
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Warning: possible hard-coded path: "PCDATA" expected. "//" must be followed by "PCDATA". Note: Defines a bad path
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Warning: possible hard-coded path: Invalid attribute default declaration. "//" must be followed by "REQUIRED", "IMPLIED", or "FIXED". Note: Defines a bad path Status: WARNING
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Class: com.ibm.xml.internal.DefaultEntityHandler Warning: possible hard-coded path: / Note: Defines a bad path Status: WARNING
Explanation: Any string constant in the class file that contains a possible path separator character is flagged as a possible hard-coded path. This string is not a path.
Class: com.ibm.xml.parsers.NonValidatingTXDOMParser Warning: method reference: java.lang.Class.forName(java.lang.String) Note: May load impure class Status: WARNING
Explanation: The only call to Class.forName is used to instantiate the class com.ibm.xml.parser.TXDocument which is shown by the JavaPureCheck program to be pure.
Class: com.ibm.xml.parsers.NonValidatingDOMParser Warning: method reference: java.lang.Class.forName(java.lang.String) Note: May load impure class Status: WARNING
Explanation: The only call to Class.forName is used to instantiate the class com.ibm.domimpl.DocumentImpl which is shown by the JavaPureCheck program to be pure.
Final Result : WARNING
 How do I get XML4J to run on the Macintosh under MRJ?
(This section courtesy of: ronald@pepsan.com) Prerequisites (available from http://developer.apple.com/java/):
- MRJ 2.1 (this is the most recent version of the JVM)
- MRJ SDK 2.1 (this is the most recent version of the Java developer tools)
Instructions (other variations would work also):
- Download the .tar.gz file containing xml4j.
- Use Stuffit Expander(tm), Suntar, or some other Macintosh tool that
supports the .tar.gz format to expand the downloaded file.
- JBindery, part of MRJ SDK 2.1, is used to create a double-clickable Java application with the necessary configuration information built in. It is analogous to writing a .bat or .sh script.
- To run the XJParse example:
- Double click on JBindery to start it up.
- Click on the Classpath panel.
- Click on the "Add .zip File" button and add both the "xml4j.jar" and "xml4jSamples.jar" files.
- Click on the Command panel.
- Enter "XJParse" as the Class name. Enter "data/personal.xml" in the Optional parameters box.
- Click on Save Settings button, pick a name such as "Run XJParse" for the file, and be sure that "Save as Application" is selected (this is the default) and save the file.
- Quit JBindery.
- You can now double click on the file you created in step f to run the XJParse example.
- To run the TreeViewer example:
- Double click on JBindery to start it up.
- Select the File-Open menu item and open the file created in step g, for example "Run XJParse".
- Change the "Class name" to "TreeViewer".
- Click on Save Settings button, pick a name such as "Run TreeViewer".for the file, and be sure that "Save as Application" is selected (this is the default), and save the file.
- Quit JBindery.
- You can now double click on the file you created in step d to run the TreeViewer example.
Why do I get ArrayIndexOutOfBoundsException in the Symantec Visual Cafe debugger? Visual Cafe's debugger is set to trap ArrayIndexOutOfBoundsException's by
default. XML4J uses ArrayIndexOutOfBoundsException internally to signal exceptional, but not erroneous conditions. In order to run XML4J2 inside Visual Cafe's debugger, you will need to turn off the trapping of these
exceptions. To do this:
- Select the "Options" item in the "Project" menu.
- Select the "Debugger" tab in the dialog which appears.
- Select "Exceptions" from the popup menu.
- Remove the check from the checkbox for java.lang.ArrayIndexOutOfBoundsException.
|