Briefly introduce Java about XML API, so everyone knows what is done. 1, JAXP (Java API for XML Parsing)
2, JAXB (Java API for XML Binding)
3, JAXM (Java API for XML Messaging)
4, JAX-RPC (Java API for XML-RPC)
1. JAXP defines the universal interfaces of DOM, SAX, XSLT in Java. This way in your program you only need to use these universal interfaces, and do not need to modify the code when you need to change the specific implementation. For example, the XSLT processor you use is too slow, you want to change one, you don't need to modify your previous code, just modify the JAXP-related configuration. (In the following, I will introduce it in detail) as a common interface, JAXP also has a so-called "minimum blend mother" effect, which means that it supports things very limited. JAXP1.0 supports XML1.0, XMLNamespace1.0, SAX1.0, and Dom Level 1. JAXP1.1 has added support for SAX2.0, DOM Level2, and XSLT1.0. Obviously if you want to use Xalan's XPath related interface, JAXP does not support, you can only bind the code to a specific Xalan's API.
Here is a JDOM, although it does not implement JAXP, but because of its simplicity, it is also very popular, and has become a JCP officially recommended API. It is also a tree-shaped structure showing XML, which is more easy to use in the use of W3C's DOM standard. The latest version of JDOM has started using JAXP API, which will use JAXP API as possible? 绻 褪 米 米 米 哪 蝈 ML parser Xerces, XSLT processor Xalan.
2, JAXB defines a two-way mapping relationship between Java data objects and XML structures. This way you can easily store a Java object as an XML document, or instantiate a Java object from an XML document. Its structure is like this: first there must be XML DTD and BindingsChema (this is not XML schema, but a definition of Java objects and XML structures XML documentation), through these two file JAXBs can be generated The XML document structure is consistent with the Java source file, which can easily get the Java class that is consistent with the XML structure after compiling (those classifications that are generated) unmarshalling, which is also possible.
Its shortcomings are also obvious. Once the structure of XML has changed, it is necessary to rewrite Bindng Schema and regenerate compilation Java classes.
Sun's actions always slowly slowly, there are some frameworks for XML Data Binding before the JAXB introduced, let's take a look at the same way to do XML Database but do not implement JAXB framework:
First, CASTOR
CASTOR not only supports the binding of XML, but also supports the LDAP object, mapping the SQL query into objects with OQL, and support for JDO. Unlike JAXB, it is only an XML schema. By XML's Schema generates the corresponding Java source code, you can Marshalling and Unmarshalling after compiling.
Second, Zeus
Compared to Castor and Jaxb, Zeus has more steps in Class Generation, so it can support multiple constraints, including support for DTD, XML Schema, and Trex. However, the project seems to have not been done. Third, Quick
Quick is also a very flexible framework, and the detailed situation can google.
3, JAXM
JAXM is an API that provides access methods and transport mechanics for SOAP communication. It is currently supporting SOAP 1.1 specification and synchronous and asynchronous communication. JAXM defines a large number of services, and JAXM's implementation products will provide these services that make developers do not have to face complex communication systems. Two important components are included in the JAXM architecture: JAXMCLIENT and PROVIDER. Client is usually part of the J2EE Web or EJB container to provide the ability you have written to access JAXM services. And Provider can be implemented in different ways, mainly responsible for sending and receiving SOAP messages. This way you can directly send and receive SOAP messages directly using JAXM API.
4, JAX-RPC
JAX-RPC is a Java API called by XML. It is based on SOAP technology, using SOAP as the underlying protocol. In this way, for developers, only methods, parameters, return values are visible, while the bottom SOAP communication is hidden, and developers don't need to be dealt with.
JAXM and JAX-RPC have a very important role in Web Services.
Supplement: JAXP framework finds the steps of specific implementation
JDK1.4 comes with JAXP reference implementation: Crimson's DOM, SAX parser, Xalan's XSLT processor.
If you want to replace them with other implementations, you must understand the specific steps of the JAXP framework implementation:
1. First, the algorithm will locate the specific implementation class through a system attribute such as Javax.xml.Transform.TranForFactory. You can specify directly in the command line:
Java -djavax.xml.transform.transformerFactory = com.foo.concreteTransformeryourapp
ConcreteTransformer is a subclass of TransformerFactory. If you use Ant, you can also specify in the build file.
In the same way, javax.xml.parsers.Document. UilderFactory and javax.xml.parsers.saxbuilderFactory properties.
2, then, if the system properties are not specified, JAXP will find the lib / jaxp.properties property file in the JRE directory, which is composed of Name = Value like a general Properties file, assuming one line:
Javax.xml.Transform.TransformerFactory = com.foo.concreteTransformer
Then JAXP will use the corresponding TransformerFactory implementation.
In the Java program, you can get the directory where JRE is located through the following code:
String JavaHomedir = System.getProperty ("java.home");
However, pay attention, if you are using it in some IDE, IDE will change this java.home value, such as JBuilder.
3. If jaxp.properties does not exist or there is no corresponding value, JAXP will use the service providing system of the JAR file to locate the correct subclass. Simply put, you can create a file named Javax.xml.Transform.Transforx.xml.Transform.Transfor Uml.Transform.Transfor's Meta-INF / Services directory, this file is only one line: com.foo.concreteTransformer is OK. 4, finally, if there is no specific implementation, JAXP will use the default implementation: Crimson and Xalan. Supplement two (DW excerpts):
Saaj (SOAP API with Attachments for Java) Saaj is divided from JAXM 1.0, and the original JAXM1.0 is divided into JAXM1.1 and SAAJ1.1. Saaj contains an API that creates and reads the SOAP1.1 specification and the SOAP message with attachments, and also includes SOAP messages that send and receive request / response models. SAAJ can be used by JAX-RPC, but also by Web service technology such as JAXM. It is a set of universal, processed the API of the SOAP message.
JAXR (Java API for XML registries) JAXR is a service registration, publishing a relevant standard API. Since the current Web service registration provider is more, if you want to use these registration services in the J2EE platform, develop a separate API for each registration service, obviously unrealistic, Jaxr has multi-layer abstraction for the registration service, making Operating today or future Web service registration centers in the J2EE platform is possible. JAXR supports three registration service types: Jaxr Pluggable Provider, Registry-Specific Jaxr Provider, Jaxr Bridge Provider (support UDDI Registry, and EBXML REGISTRY / Repository, etc.). The JAXR specification defines two levels of support for JAXR, namely: Level0: Used to support UDDI registration; Level1: Used to support EBXML registration.
These APIs can be obtained in Java (TM) Web Services Developer Pack. They are also the foundation of the J2EE1.4 Web service architecture.
Reference: http://www-900.ibm.com/developerWorks/cn/webservices/ws-j2ee14/