Hi, I'm using JAXP for XML parsing with the default parser provided by SUN. Here is an excerpt from an article which explains how different parser implementations can be used by changing the java system property.
"The implementation of the SAXParserFactory interface to be used can be changed by setting the Java system property javax.xml.parsers.SAXParserFactory. If this property isn't defined, then the default implementation (whatever parser your vendor specified) is returned. The same principle applies for the DocumentBuilderFactory implementation you use. In this case, the javax.xml.parsers.DocumentBuilderFactory system property is queried. " Can anybody please explain how can i change this java system property . One more thing , I've been able to use jclark parser with JAXP by just including it in classpath while copiling but this java system prerty thing is confusing....somebody please explain. ------------------ max
The System class maintains a set of properties, key/value pairs, that define traits or attributes of the current working environment. When the runtime system first starts up, the system properties are initialized to contain information about the runtime environment. including information about the current user, the current version of the Java runtime, and even the character used to separate components of a filename. Checkout Java Tutorial section on System properties for an excellent introduction to how and when the properites can be used. You can use the System properties to tell JAXP to use a specific SAX/DOM parser. You can either tweak the properties file externally or inside your program. Here's an example -
Hope that helps!
------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
posted 18 years ago
Hi Ajith, thanks a lot for ur help. I went thru the sun's tutorial on system properties . Its really excellent. There's one more thing that I would like to ask. The default parser that comes with JAXP is packaged in crimson.jar and I guess the java system property takes its path as default. When I put xerces.jar in classpath while compiling my program , it automatically takes xerces implementation without even setting it explicitly thru setPropery() function. Please explain this behaviour ------------------ max
posted 18 years ago
Hi Ajith & Map, Please clarify my confusion regarding setting of system properties as explained in my last mail. ------------------ max