• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax.xml.parsers.XmlDocumentParserFactory  RSS feed

 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I was trying to a parse a document and came across the following statement :

DocumentBuilderFactory uses the system property javax.xml.parsers.XmlDocumentParserFactory to find the class to load.


I tried to print this property and it printed "null".

I wonder if the property is null then how all this parsing process works.
or is it just my case that the above property is coming as null.

Another thing is that I printed all the properties using getProperties() but there is no such property exists with this name.

Please advise.
 
ali Dada
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write your sample code here.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No code as such.

I read it on the net.



This is the output :-
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the factory instance created like below or otherwise?

 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pramod talekar wrote:Hello,

I was trying to a parse a document and came across the following statement :

DocumentBuilderFactory uses the system property javax.xml.parsers.XmlDocumentParserFactory to find the class to load.


I tried to print this property and it printed "null".


It is null means that there is no such property, dead simple.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Minh,

It is null means that there is no such property, dead simple.


If it is null, then all this shouldn't work, right ?

Yes, John, that's the way.
 
Minh Nam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pramod talekar wrote:

If it is null, then all this shouldn't work, right ?



Hi pramod,

What shouldn't work? You did not post the code that you are expecting to work, you posted just two System.out.println() statements.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, Here's the code :-



If the said property is coming as null,
then the above lines should give error.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For such doubts, it's best to go through the JRE source code and understand. In this case, the relevant code is

It checks for the property. If it can't find, it falls back to the default Xerces parser bundled with Sun JRE.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pramod talekar wrote:
If the said property is coming as null,
then the above lines should give error.

From the API Docs
Obtain a new instance of a DocumentBuilderFactory. This static method creates a new factory instance. This method uses the following ordered lookup procedure to determine the DocumentBuilderFactory implementation class to load:
  • Use the javax.xml.parsers.DocumentBuilderFactory system property.
  • Use the properties file "lib/jaxp.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to check for its existence. It is not possible to change the value of any property in jaxp.properties after it has been read for the first time.
  • Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.parsers.DocumentBuilderFactory in jars available to the runtime.
  • Platform default DocumentBuilderFactory instance.



  •  
    pramod talekar
    Ranch Hand
    Posts: 367
    Eclipse IDE Java Opera
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you sir.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!