Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.xml.parsers.SAXParserFactory.

 
Saif Ali
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saif Ali
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Saif Ali
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajith & Map,
Please clarify my confusion regarding
setting of system properties as explained
in my last mail.
------------------
max
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic