Give the power of XML through Eclipse (22)

zhaozj2021-02-16  50

Verify the XML code and encode its character to use the XML document is to check its internal validity (the logic of document logic). The syntax check is required to understand if all tags and definitions are correct and are called correctly. Only after the syntax check, you can confirm that the XML document format is good and the logical structure of the document can be parsed. The XML document is verified by an XML parser.

All the Eclipse XML plugins described below can perform XML authentication, pointing out warnings and errors in the code. If you try to open an XML document, the XML parser may generate an error. You can retrieve precise error code, error text, even leading to the wrong line. You can verify the XML document when you need it, or automatically verify when saving documents. The verification error task can be cleared as a set. XMLBuddy plugins use a system-wide XML parser, however, keep in mind that the Eclipse platform has one of the best XML parsers: Xerces (XML4J). See Resources for download information. But is not limited to the Xerces or system parser because run => external tools => Configure points to other XML parsers.

Another important XMLBUDDY function is to support different character encodings. This will be useful or later, for example, when needed to use XML transplantable documents written in different languages ​​(such as Polish and English). This is not a simple task because there are three ways to encode polish characters: one is Windows Latin-2 (CP1250) used by Windows 9x / 2000; its second is used in the Internet and by UNIX and class UNIX systems (Such as Linux) ISO LATIN-2 (ISO8859-2); three of them are Macos and Macos X, which uses different character coding standards to Polish.

Typically, XMLBUDDY provides two solutions for character encoding: automatically detects XML document encoding according to file content, or set it to default encoding. The default encoding can be in the range of works and resources can also be specific. To open an XML code preference, select Window => preferences => XML => Encoding.

These problems with these solutions to character encoding are: For XML, a coding (one of the tables) cannot adapt to all situations. XML documents may come from any number of sources around the world. In many cases, users cannot control other people's encoding for documents, and there may be no way to divide work according to coding boundaries. The same code preferences will be difficult to fit (all) Java source files and XML documents. When a set of global preferences cannot meet the needs, XMLBUDDY provides properties for each document. The properties of each file in the specified project are a heavy task. However, when a document to be processed uses an uncommonized encoding (cannot automatically detects the encoding, and is not specified in the document), the attribute is a unique solution. To open the encoded properties of a specific file, right-click on the file and select Properties => XML => Encoding. Figure 4 shows how to set global character encoding.

Figure 4. Global character encoding of XML documents in Eclipse

DTD vs. XML Schemaxml Schema specifies the XML Schema definition language that provides tools that describe the XML 1.0 document structure and limit their content, including those that utilize XML Namespace. The mode language itself is represented by XML 1.0 and uses the namespace, which refutes the ability of XML 1.0 DTD to a certain extent, and expands these capabilities to some extent. Please remember that DTD has many limitations: It is usually difficult to use the content model for complex demand. Namespaces are not supported. Support for modularity and reuse is very limited. Declaration expansion or inheritance is not supported. It is difficult to write, maintain, and read large DTDs and define series related patterns. There is no embedded, Structured Self-documentation (available in ). Content and attribute declarations cannot rely on properties or elements context (many XML languages ​​are used in this, but their DTD must "allow too much"). Only one simple identifier attribute mechanism (in other words, there is no uniqueness).

But XML Schema also has a law:

XML Schema is more complicated; programs that only need to use XML may feel rare. XML Schema cannot request a specific root element (so, even if the simplest document is verified, additional information is required). When the mixed content is described, the character data is not constrained. Content and attribute declarations cannot rely on attributes or elements context (this is also the main problem of DTD). You cannot leave the declaration to specify the default. Element default values ​​can only be character data (not included).

XMLBuddy provides sufficient support for DTD and Schema, but if you need truly excellent XML Schema support, you should use the XSD-XML Infoset Browser For Java plugin (see Resources to get link). It implements the Java reference library of XML Schema Infoset Model as described in the W3C XML Schema specification. It is useful for any check, creating or modifying the code of XML Schema. XML Infoset Browser provides an API that operates an XML Schema component, and an API that is operated in XML SCHEMA (DOM accessible) in a series of XML documents. XML Infoset basically allows two or more programmers to simultaneously use Java and XML, so it provides a standard method for identifying and creating XML-based modes.

Figure 5. XML Schema verification becomes available after installing IBM XML SQC

The necessary additions of XML Infoset Browser are IBM XML Schema Quality Checker, referred to as SQC (see Figure 5 and) to get a link). SQC is a Java program that gets XML schema written in W3C XML mode language as an input, then diagnoses the incorrect use of Schema language. SQC reads SCHEMA that meets the latest XML Schema specification and attempts to determine if they are valid if they are applied to various constraints of Schema. When SQC encounters an element that does not meet the specification, it gives a diagnostic message, which may contain suggestions for how to correct issues. For schema composed of many Schema documents (these documents via , or

Reference

Add the Eclipse platform community and download the platform via Eclipse.org. The Eclipse platform source code is licensed under CommON Public License. In Eclipse.org, you can also find the terms and descriptions of the Eclipse project, as well as technical articles and newsgroups. The Eclipse platform white paper details the main components and functions of Eclipse. Download XMLBuddy website in Bocaloco Software download XMLBuddy and learn more about it. Download the Eclipse platform Plug-in SDK at the Eclipse Project Downloads page. For information on the Apache XML project, including the Xerces parser, see Apache.org. Download XSD-XML Infoset Browser For Java in Eclipse.org. The AlphaWorks site in IBM Download XML Schema Quality Checker. For an introductory article on the Eclipse platform and its working principle, see the developerWorks article "Working The Eclipse Platform" written by Greg Adams and Marc Erickson. To start using the Eclipse platform development application, see the developerWorks article "Getting Started with the Eclipse Platform" written by David Gallardo. If you are interested in creating your own Eclipse plugin, see the developerWorks article "Developing Eclipse plugins" written by David Gallardo. To understand how developers integrate XM (a simple content management and publishing solution based on XML and XSLT) and Eclipse, see the developerWorks article "Integrating XM and Eclipse" written by Benoit Marchal. Please refer to the rich XML reference resource useful on the W3C Alliance website. Download the Transclipse plugin in SourceForge.net. Get the Eclipse Tidy project in SourceForge.net. Learn about J2H (Java to HTML, Java To HTML) plugins. Browse the Eclipse plugin registry. References for Eclipse users and XML developers are found on developerWorks. About the author Pawel Leszek is the author of Studio B, he is an independent software consultant and writer, good at Linux / Win / Mac OS system architecture and management. He has extensive experience in many operating systems, programming languages, and network protocols (especially Lotus Domino and DB2). Pawel is also the author of the Linuxworld series of articles, and is a Po-columnist writer for Pagux column. Pawel and his wife and lovely little daughter live in Warsaw. You are welcome to ask questions and comments; you can contact Pawel via Pawel.leszek@ipgate.pl.

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

New Post(0)