Give the power of XML through Eclipse (22)

xiaoxiao2021-03-06  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

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

New Post(0)