Use XML + JSP technology to implement web content dynamic display

zhaozj2021-02-11  202

I. Introduction to XML Technology

XML (Extensible Markup Language - Extensible Markup Language) is an extended source tag language that can define languages ​​in other languages. It is a simplified subset of SGML. This subset is designed for web environment. This is to say that it must handle data processing (rather than publication), and is actually dynamically generated. )information. XML and HTML comparison: l XML syntax strict, data is separated, easy to interact with other programs and retrieve data. l HTML syntax fault tolerance, data and display are together, and the retrieval data is large. l XML and clear DOM objects, you can read and write the XML file to add data. l HTML does not have this clear object to complete the operation. XML overcomes the shortcomings of HTML, standardize the documents transmitted on the network, and gives a certain meaning of the label. XML is quickly supported as a common data exchange format in a network system. The actual benefits of XML are: l Structured - Establish a number of tweet models with any complex level. l Sclectability - Roots need to define new identities. l Verification - Check the correctness of the data in structure. l Independence & Media - Publish content in a variety of ways. l Independent in the supplier and platform - using standard commercial software or even text tools to process any document that meets (XML standards). The XML document can be converted and formatted XML documents by Extensible Style Language XSL (Extensible Style Language XSL). Thereby achieving separation of data and page style.

Second, using JSP technology to implement XML JSP provides a series of features that can be conceived ideally and XML, and the JSP page can contain any type of text data, so JSP can directly generate a document containing XML. Moreover, JSP can use a powerful Java platform to resolve, convert XML information, and documentation. Since JSP is also part of the Java software environment, JSP can also use API objects to process XML data. The powerful features of JSP technology and good flexibility plus XML technical standardized data, which can be perfectly realized with the dynamic display of the web page.

Third, the development environment 1, editing tools now, the tools for developing XML documents are increasingly, from link large-scale XML development environments, to simplify the simple minimal text editor for simplified tag development processes. The latest tools can be learned from http://www.xml.com. Currently, several common development tools are as follows: l UltraEdit is developed by IDM Computer Solution, you can download a limited time to http://www.ibmcomp.com or http://www.ultraedit.com. It is an interface that is similar to the Windows resource manner, with a strong text editing function. l XML SPY ICON Information-Systems's XML SPY is an integrated development environment including XML, including all aspects of XML development, strong function, easy to use. XML SPY is a real complete XML development environment. It contains all the elements required to develop XML in a simple and easy-to-use product. It includes: XML editor and inspection, SCHEMA / DTD editor and inspection, XSL editor and conversion. At the same time, it also includes the latest XML draft, is a non-much good software. l XML Writer This software is developed by Wattle Software-Chris Howard and can be downloaded from http://xmlwriter.net (trial). Used under Windows NT4, there is also a familiar Windows interface, which provides engineering management environments, possibly planing, viewing engineering, project, including files, users can customize toolbars, shortcuts, and You can select the display icon for the command. The XSL style sheet can be converted to the XML file as an HTML file, not only using XSL, but also use XQL, use DTD or XML Schema to check the XML, combined with the CSS directly to XML, provide online help function, and it is The support of Chinese is better. 2, XML server has great development potential due to XML technology, many manufacturers provide their own XML server, including Apache, Microsoft, Sun, etc. 3. Browse XML tools now, most solutions are stored in the database. When the code is required, combine it with the data, use XSL to convert it to HTML, and then send it to the browser. So browse XML generally select IE to Netscape, and the new version is supported to the XML document. Fourth, specific implementation 1. Specification definition The element name in the XML document first defines the XML document header, including XML, code, and annotation, etc. For example: "Version =" 1.0 ", indicating that the XML document follows the XML1.0 program, which is necessary. "Encoding =" GB2312 ", if there is no this statement, you must use unicode to use UTF-8 or UTF-16 as a number. If Chinese uses Chinese in the file, the encoding declaration must be performed. "Standalone =" YES ", the XML declaration can also have Standalone features, which indicates whether the document needs to import files from the registration in this file. If the XML document is completed in a file, the value of the Standalone feature is set to "Yes".

Then, depending on the business needs specification defines the elements you want to display on the page, as well as the element name to define their element name, the element name can be Chinese, so that the data description is more simple, this is HTML unable to implement. The element is the main logic component of the document, defined by the start and end tags, the format is: Element content element Content, you can write directly on the page or you can get from the database. An entity declaration and entity reference can also be included in the document. Simply put, entity is divided into general entities and parameter entities. The parameter entity can only appear in the DTD, and the general entity appears in the primary XML document starting at an element. The entity statement is: . The general entity is quite simple: "& entity name;", reference to the parameter entity is similar to the general entity quoted: "% of the entity name;". The entity is a powerful tool that provides a convenient mechanism for managing a lot of content. After writing, check the XML document to ensure that the format of the document is correct and valid. A format correct XML document is satisfied: l Each element must have start and end labels; l must have one, and only one element called root elements or file elements, and it does not appear in any other element; l It contains one or more elements; l Correct definitions and indicates empty elements; l Start tags and end tags can use uppercase or lowercase, but they must match; l The individual elements that are bounded by start labels and end labels must be correct. Establishing, not allowing cross; l Attribute value must be enclosed using quotation; lively in this file, each of them is formatted correctly; l It meets all other in XML specification Format is correct. 2. Use XSL to display the XML document XSL (Extensible Stylesheet Language) is a language describing the XML document style and is made by W3C. The XSL handler reads the XML document and the XSL style single, which outputs a new XML document based on the command found in the XSL style single. The XSL style sheet is a description file for classes in the XML document, which describes how to use the formatting vocabulary to convert class instances into an XML document. At the same time, the XSL style sheet must also be an organization's good XML. XSL has three modules: XSL PATERN, "XSL" name ("XSL" Namespace), "FO" name ("Fo" namespace). Three main ways to convert XML documents into other formats using XSL style sheets: XML documents and related style orders are used for client (web browser), and then the client program is specified in the format to convert documents in the style sheet. And present it to the user; the server applies the XSL style to the XML document so that this document can be converted into some other format (usually HTML) and send the converted document to the client program (web browser); Use third-party programs to convert the source XML document into other formats (usually HTML), place this document on the server, server and client processes only the converted document. Because most browsers are IE, and IE supports XSL support, the first method is often used.

The XSL conversion language is operated by converting the XML tree structure into another XML tree structure. This language contains an operator that is used to select a specific node from the tree structure, reordering the node and output nodes. The description of the XSL in the XML document is as follows: The XSL style referenced by the XML document is MyStyle.xsl. The content and form isolation make the XML document more than the data itself, not the influence of the sub-branches of the display mode. Moreover, different display appearance can be used to define different styles, and the reusability of XML data can be implemented using the same data. First define the modules that construct part output, or to the data application template from the XML source file. The conversion template is included in the element XSL: Template, the template can define a set of rigid documents to convert the source document to the results tree to determine the node to be processed. Then match the mode, a mode is a string, which is used to match an element in the XML source file. Use the @ match attribute node. Use the elements in XSL to convert the elements in the XML document. With XSL, you can easily implement the same form definitions in HTML. As long as you want to put in the form of the element in the form, the name, the presentation, etc., the properties such as the form, the definition in the HTML are the same as the definition in HTML. The same form, the style, page display style, script, etc. are similar to HTML. In addition, CSS can also be applied to XML documents, but CSS determines the visual appearance of the page without changing the structure of the source document. CSS and XSL are complementary to each other and have a featured. After the XSL conversion, the XML document form is submitted to the JSP page or servlet for processing. This part can be completely and page processing, which can achieve complete independent control logic. 3, the main application of the output XML of XML document data includes switching information, defining document types, explanation information, information in a structured text-based format, can easily transfer, conversion, and interpretation. The processing of data can be made all in the JavaBean or servlet, and is completely separated from the page. Generating an XML document in JSP is simple, and CSS or XSL can be used to convert and display XML. A JSP page with an XML template, which is in an XML document template, add Java code and JSP tag appropriate place. Add <% @ page contentType = "text / xml"%> to explicitly explicitly in XML documentation in the XML document, and put dynamic data into <%%> tag. The generated XML can also be used in format conversion and style definitions using the XSL style. 4, XML and Java Combined XML can create open data that does not depend on platform, language or restriction format, if widely used, XML can become a broad standard for the content and the client object. As a content platform XML enhances Java in many ways. XML will be based on the network information, so that developers and computers are easy to identify. This is necessary because HTML is lacking in the hidden URL, the meaning of an effective method explains the meaning of the content, and the goal of XML adds those meanings for the network, and these once is one of the tasks of Java. Many network developers have concluded that XML and Java are a perfect pair, because each other is very complementary, XML contributes to independent platforms, easy to extract information documents and data. Java helps independent platforms, object-oriented application software solutions, can drive XML broad accepted applications that are difficult to implement in HTML, which can be divided into the following four categories: l Requires network client coordination Application of Various Different Type Databases. l Force to distribute the proportional processing from the server to the client's application. l Require the client to display the same data in different forms to different users.

转载请注明原文地址:https://www.9cbs.com/read-4597.html

New Post(0)