XML application technology using JSP technology to implement XML

Source: Internet
Author: User
Tags ultraedit

Development Environment

1. editing tool

Now, there are more and more tools for developing XML documents, from the enterprise-level XML development environment linking large company databases to a simple small text editor that simplifies the markup development process. The latest tools are available in http://www.xml.com. Currently, several commonly used development tools are described as follows:

Developed by IDM Computer Solution, UltraEdit is available for http://www.ibmcomp.com or http://www.ultraedit.com free download with a limited version. It is similar to the Windows Resource Manager interface and has a strong text editing function.

XML Spy Icon Information-Systems XML Spy is an integrated development environment for XML, including various aspects of XML development. It has powerful functions and is easy to use. XML Spy is a truly complete XML development environment. It includes all the elements required for XML Development in a simple and easy-to-use product. It includes: XML editor and validation, Schema/DTD editor and validation, XSL editor and conversion. It also contains the latest XML draft, which is a rare good software.

The XML Writer Software was developed by Wattle Software-Chris Howard and can be downloaded from the http://XMLwriter.net for trial use ). It is used in Windows 95/98/2000 and Windows NT4 and has a Windows interface that everyone is familiar with. It provides a project management environment, which may be used to create and view projects. The project contains files, you can customize toolbar and shortcut keys, and select the display icon for the command. You can use an XSL style sheet to convert an XML file into an HTML file. You can use not only XSL, but also XQL and DTD or XML Schema to test the XML file, CSS is directly integrated into XML in XML format, providing online help and better support for Chinese characters.

2. XML server

Due to the great development potential of XML technology, many vendors provide their own XML servers, including Apache, Microsoft, and Sun.

3. XML browser Tools

Currently, most solutions are to store XML in a database. When necessary, extract the code, combine it with the data, convert it to HTML using XSL, and then send it to the browser. Therefore, you can use IE to browse XML files. The newer version, the better support for XML documents.

Implementation

1. Standardize the definition of element names in XML documents

First, define the XML document header, including the specifications, encoding methods, and annotations followed by XML. For example:

< ?xml version=”1.0” encoding=”gb2312” standalone=”yes”?> 

"Version =" 1.0 "indicates that the XML document follows the XML1.0 scheme. This comedy statement is required.

"Encoding =" gb2312 ", without this declaration, Unicode must be used, either in UTF-8 or UTF-16 as the numbering method. If the file uses Chinese characters, you must declare the encoding.

"Standalone =" yes ". The XML declaration can also have the standalone feature, which indicates whether the document needs to import files from the local directory in this file. If the XML document is completed in a file, set the value of the standalone feature to "yes ".

Then, define the elements to be displayed on the page according to business needs and define their element names. The element names can be Chinese, which makes the data description simpler and clearer, this is not implemented by HTML. An element is the main logical component of a document. It is defined by the start and end tags in the following format:

<Element name attribute name 1 = "attribute value 1" attribute name 2 = "attribute value 2">

Element Content

</Element name>

Element content can be directly written on the page or obtained from the database.

The Object Description and object reference can also be included in the document. In short, entities are classified into common entities and parameter entities. The parameter object can only appear in the DTD. Generally, the object appears in the main XML document starting with an element. Object declaration format :. The reference of a common object is very simple: "& Object Name;". the reference of a parameter object is similar to that of a general object: "% Object Name ;". Entity is a powerful tool that provides a convenient mechanism for managing large volumes of content.

Check the XML document to ensure that the document format is correct and valid. A correctly formatted XML document meets the following requirements:

◆ Each element must have a start and end annotation;

◆ One element is required, and only one element is called the root element or file element, and it cannot appear in the content of any other element;

◆ It contains one or more elements;

◆ Correctly define and represent empty elements;

◆ The end mark can be in upper or lower case, but they must match;

◆ Elements bounded by the start tag and end tag must be correctly nested and cross-cutting is not allowed;

◆ Attribute values must be enclosed in quotation marks;

◆ The correct format is applicable to each of the analysis instances directly or indirectly referenced in this file;

◆ It meets all other format correctness constraints defined in the XML specification.

2. Use XSL to display XML documents

XSLeXtensible stylesheet language) is a language used to describe XML document styles. It is developed by W3C. The XSL handler reads XML documents and XSL style sheets, and outputs New XML documents based on the commands found in the XSL style sheet by the handler. An XSL style sheet is a class description file in an XML document. The description file describes how to convert a class instance to an XML document using formatting words. At the same time, the XSL style sheet must also be well-organized XML.

XSL consists of three modules: XSL pattern (XSL Patern), "XSL" XSL "XSL" Namespace), and "fo" fo "fo" Namespace ). There are three main methods to convert an XML document to another format using the XSL style sheet: XML documents and related style sheets are used in the client Web browser, the client then specifies the format conversion document according to the style sheet and presents it to the user. The server applies the XSL style sheet to the XML document, so that this document can be converted to HTML in another format), and the converted document is sent to the client Web browser ); A third-party program is used to convert the source XML document to another format, which is usually HTML). This document is placed on the server, and the server and client program only process the converted document. Because most browsers use IE and IE has good support for XSL, the first method is often used.

The XSL conversion language transforms the XML tree structure into another XML tree structure. This language contains operators, which are used to select specific nodes from the tree structure, re-sort the nodes, and output nodes. The following describes how to reference XSL in the XML document:

 < ?xsl-stylesheet type=”text/xsl” href=”mystyle.xsl”?> 

The XSL style sheet referenced in this XML document is mystyle. xsl. Separation of content and form makes XML documents more focused on the data itself, without the influence of the details of the display method. In addition, different style sheets can be defined to display different appearances using the same data, so that XML data can be reused.

First, define the module that constructs part of the output, or apply the template to the data from the XML source file. The conversion template is included in the element xsl: template. The template defines a set of rules for converting the source document to the result tree to determine the nodes to be processed. Then match the pattern. A pattern is a string used to match an element in the XML source file. Use @ to match the attribute node. Use the elements in XSL to convert the elements in the XML document. With XSL, you can easily implement the same form definition as in HTML. You only need to add the elements in the form to the defined XSL template. The attributes of the form, such as the form name and definition method, are the same as those defined in HTML. The definitions of the same table range, style, page display style, script, and so on are also similar to those of HTML.

In addition, CSS can be applied to XML documents, but CSS determines the visual appearance of the page and does not change the structure of the source document. CSS and XSL are complementary and distinctive.

After the XSL conversion, the XML document form is submitted to the JSP page or servlet for processing. This part can be completely separated from page processing, and the control logic can be completely independent.

3. XML document data output

The main applications of XML include exchanging information, defining document types, and descriptive information. Information is expressed in a structured text format and can be easily transmitted, converted, and interpreted. Data can be processed in javabean or servlet, which is completely separated from page display.

It is very easy to generate an XML document in JSP. You can still use CSS or XSL to convert and display XML. The essence of a JSP page with an XML template is to add JAVA code and JSP tags in an appropriate place in the XML document template. Add <% @ page contentType = "text/xml" %> to the page to display the JSP page in XML format, dynamic Data is also placed in the <%> mark. For the generated XML, you can also use the XSL style sheet for format conversion and style definition.

4. XML and JAVA Integration

XML can create open data that does not rely on platforms, languages, or restrictive formatting protocols. If widely used, XML can become a broad standard for content and client objects. As a content platform, XML enhances JAVA in many aspects. XML tags network-based information, making it easy for developers and computers to recognize. This is necessary because, in addition to the hidden URLs, HTML lacks an effective method to describe the meaning of the content, so the XML Object adds the meanings to the network objects, these were once one of JAVA's tasks.

Many Web developers come to the conclusion that XML and JAVA are perfect for each other because they complement each other. XML helps independent platforms and easily extract information documents and data. JAVA is an object-oriented application software solution that helps independent platforms and is easy to process. XML-based widely accepted applications are those that are hard to implement under the restrictions of HTML, it can be divided into the following four categories:

◆ Network clients are required to coordinate applications of different types of databases;

◆ Try to distribute a considerable proportion of processing work from the server to the client applications;

◆ The client is required to present the same data to different users in different forms;

◆ Intelligent network proxy should search for custom information applications as required by individual users.

The JAVA platform provides the basis for safe and convenient code propagation on the network, while the XML technology provides the same capabilities for data, this is a clear and platform-independent way to express content. Among many programming languages, JAVA is an excellent platform for using XML, and XML is an excellent Data Representation Method for JAVA applications. XML and JAVA are closely related to the Internet. XML is designed to be an optimized and flexible readable format and can be used directly on the Internet. JAVA supports socket, HTTP, HTML and server. They all support Unicode. Therefore, it is easy to implement local applications. Just as JAVA provides programmers with the ability to express complex data structures and object-oriented models, it is ideal to express complex hierarchical data models with XML.

XML, in combination with JSP technology, has a clear structure, clear structure, and is easy to understand. It is a fast and convenient way to develop dynamic websites.

  1. XML structure and syntax
  2. Combination of XML and HTML
  3. 12 tips for XML configuration in Spring

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.