Implementation of JSP using Jdom processing database to XML transformation (i)

Source: Internet
Author: User
Tags microsoft sql server sql
dom|js|xml| Data | database | conversion

First, JDOM introduce

We know that the DOM is the official consortium of standards for representing XML documents in a platform-and language-independent way, using the DOM and Sax APIs to parse and process XML documents. The jdom here is a pure Java API based on tree operations, and it provides a set of solutions for parsing, creating, processing, and implementing XML. These APIs are more intuitive than the methods provided by the DOM and Sax APIs, and programmers with Java experience will find jdom very easy to master. Jdom is much easier to process XML than DOM, and its functionality is more powerful than using sax.

Jdom's internal logical structure is essentially the same as Dom's, for example, document node types with documents, Element, comment, each of which must have a document node and the root node of the node tree. The root node can have child nodes or leaf nodes such as comment, text, and so on. Each node type in the Jdom document corresponds to no element in the well-formed XML text. This provides an operational basis for using JDOM to transform the database to XML documents.

Advantages of Jdom:

It is clear from Jdom's documentation that the advantages of applying jdom are obvious. The Jdom document declares the following "Jdom quotes 20/80 principles, even with 20% of the energy to solve the 80% java/xml problem".

Jdom is developed in Java and serviced by Java, which follows the specification and class library of Java code;

In many programming languages, Java is an excellent platform for using XML, and XML is an excellent data representation method for Java applications. The JDOM API is a pure Java API that is easier for Java developers to get started with;

The JDOM API is more intuitive than the methods provided by DOM and simplifies interaction with XML. Faster than using the DOM.

Org.jdom is the JDOM Toolkit for Java API operations.

In Org.jdom, document, Element, Comment, DocType, Attribute, text, and other JAVA classes are provided, which are necessary to access and manipulate jdom documents. We can use these classes to create, traverse, and modify jdom documents.

In Org.jdom.output, Domoutputter and Xmloutputter are provided to handle the DOM tree form of the jdom tree, the output of XML documents, printing, and so on.

Second, the Environment configuration

On my WINDOWS2000 system platform, we use TOMCAT4.1.18 and jdk1.4.0_02 as the development and test platform.

Add the following two environment settings through the advanced attribute of my Computer classpath set to: ".; C:\j2sdk1.4.0_02\lib\dt.jar;c:\j2sdk1.4.0_02\lib\tools.jar; ". Path is set to ".; C:\j2sdk1.4.0_02\bin; ".

SQL SERVER JDBC Driver: Mssqlserver.jar into Tomcat's lib directory.

Iii. acquisition and installation of Jdom

Since Jdom is not currently included in the Sun's JDK (I think jdom will inevitably become part of the Sun JDK in the near future), we must manually download and set up the JDOM environment.

The latest version of Jdom can be downloaded at http://www.jdom.org. Here is the download of Jdom beta8. After downloading the jdom-b8.zip, the Jdom jar file is the file Jdom.jar in the build directory, and copies the above files to the Jre/lib/ext directory under the j2sdk1.4.0_02 directory.

iv. use of Jdom Implementing SQL SERVER database to XML the conversion

1, database, table creation

Here is an example of changing customer information-"customer base information". We put the data in a Microsoft SQL SERVER 2000 database and then dynamically generate XML instance documents using JSP and Jdom technology.

We created a datasheet--custom in advance of Microsoft SQL Server database CUSTOM, and its data structure is shown in the following table:

Field name

Comments

Type

is empty

Name

Name

varchar (12)

Not NULL

Id

Id

Int

Not NULL




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.