Home arrow XML arrow Page 5 - Java and XML Basics, Part 1
XML

Java and XML Basics, Part 1


In a previous article (XML Basics Part One);we had a brief look at XML. However, as stated in the article, XML itself is worth nothing without the set of APIs that are generated-it would simply be just another fancy form of CSV, that is, a proprietary data format! My aim in this set of articles is not to actually reveal XML in its every detail, but rather have a look at the implications of XML in today’s technologies. That’s why the previous article only sheds a little light into the insights of XML, which included some terms and technologies you will be confronted with the moment you step in the XML arena.

Author Info:
By: Liviu Tudor
Rating: 5 stars5 stars5 stars5 stars5 stars / 48
March 08, 2004
TABLE OF CONTENTS:
  1. · Java and XML Basics, Part 1
  2. · The javax.xml.parsers Java Package
  3. · Parsing Using JAXP and the DocumentBuilder
  4. · Traversing the DOM
  5. · Appendix: Installing Xerces-J 2.0.0 under JDK 1.4

print this article
SEARCH DEVARTICLES

Java and XML Basics, Part 1 - Appendix: Installing Xerces-J 2.0.0 under JDK 1.4
(Page 5 of 5 )

As stated above, just by loading XercesJ into the class path doesn't solve the problem, as both Crimson and XercesJ are JAXP compliant, and the javax.xml.parsers factories, when loaded, will load the first JAXP provider found which is always Crimson (as this is included in the rt.jar runtime jar). In order to allow XercesJ to "override" Crimson, you’ll have to use the Java Endorsed API mechanism--this means creating a directory (the recommended method is to create it in your <JAVA_HOME>\lib directory and call it "endorsed"--therefore the full path would be <JAVA_HOME>\lib\endorsed) and in the command line that starts the Java interpreter add the following option:

-Djava.endorsed.dirs=<JAVA_HOME>\lib\endorsed

(Or the path to the directory where you have placed the XercesJ jars.) If you have more than one directory, you can separate them with “;” on Windows or “:” or UNIX. This will allow the Java interpreter, when starting up, to load the JAXP API providers form this directory first, and therefore the XercesJ classes will be loaded rather than Crimson. One easy way to test it is with the following code:


import javax.xml.parsers.*;
....
   
/*** Checkout the parser ***/
   DocumentBuilderFactory dbf 
DocumentBuilderFactory.newInstance();
   System
.out.println"Factory: " dbf );
   DocumentBuilder   db 
dbf.newDocumentBuilder();
   System
.out.println"Builder: " db );
   
/***/
....

If the output shows a class name in the package org.apache.xerces.jaxp... then Xerces is loaded, otherwise, you should check your class path, endorsed API path and make sure that it's all set correctly for XercesJ to load.

Finally, you can download the support files here.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials