XML
  Home arrow XML arrow Page 5 - Java and XML Basics, Part 1
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Java and XML Basics, Part 1
By: Liviu Tudor
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 46
    2004-03-08

    Table of Contents:
  • Java and XML Basics, Part 1
  • The javax.xml.parsers Java Package
  • Parsing Using JAXP and the DocumentBuilder
  • Traversing the DOM
  • Appendix: Installing Xerces-J 2.0.0 under JDK 1.4

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

       · good one for beginers....
     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek