Information AboutXml |
|
Warning to AutoWikiBrowser users do not attempt to Unicodify this page many of the notations are in context and should not be converted to their glyph representations Don't change "Extensible" to "eXtensible"! See http://www.xml.com/axml/notes/TheCorrectTitle.html from the Annotated XML Specification. -->
The Extensible Markup Language ('''XML''') is a general-purpose Markup Language .More precisely, XML is a general-purpose ''specification'' for creating custom markup languages. It is classified as an Extensible Language because it allows its users to define their own Tags . Its primary purpose is to facilitate the sharing of structured data across different information systems, particularly via the Internet .1 It is used both to encode documents and serialize data. In the latter context, it is comparable with other text-based serialization languages such as JSON and YAML .JSON and YAML are among other alternative text-based formats commonly described as lighter-weight and less verbose in comparison to XML. See Critique Of XML in this article. It started as a simplified subset of the Standard Generalized Markup Language (SGML), and is designed to be relatively human-legible. By adding semantic constraints, application languages can be implemented in XML. These include XHTML ,XHTML is an attempt to simplify and improve the consistency of HTML , which was based on SGML. RSS , MathML , GraphML , Scalable Vector Graphics , MusicXML , and thousands of others. Moreover, XML is sometimes used as the Specification Language for such application languages. XML is Recommended by the World Wide Web Consortium . It is a fee-free Open Standard . The W3C recommendation specifies both the Lexical Grammar , and the requirements for Parsing . WELL-FORMED AND VALID XML DOCUMENTS There are two levels of correctness of an XML document:
WELL-FORMED DOCUMENTS: XML SYNTAX As long as only well-formedness is required, XML is a generic framework for storing any amount of text or any data whose structure can be represented as a tree. The only indispensable syntactical requirement is that the document has exactly one root element (alternatively called the '''document element'''). This means that the text must be enclosed between a root opening tag and a corresponding closing tag. The following is a well-formed XML document: The root element can be preceded by an optional XML declaration. This element states what version of XML is in use (normally 1.0); it may also contain information about Character Encoding and external Dependencies . The specification ''requires'' that processors of XML support the pan- Unicode Character Encoding s UTF-8 and UTF-16 ( UTF-32 is not mandatory). The use of more limited encodings, such as those based on ISO/IEC 8859 , is acknowledged and is widely used and supported. Comments can be placed anywhere in the tree, including in the text if the content of the element is text or #PCDATA: In any meaningful application, additional markup is used to structure the contents of the XML document. The text enclosed by the root tags may contain an arbitrary number of XML elements. The basic syntax for one element is: Here, »content« is some text which may again contain XML elements. So, a generic XML document contains a Tree-based Data Structure . In this respect, it is similar to the LISP programming language's S-expression s, which describe tree structures wherein each node may have its own property list. Here is an example of a structured XML document: Attribute values must always be quoted, using single or double quotes, and each attribute name should appear only once in any element. XML requires that elements be properly nested — elements may never overlap. For example, the code below is not well-formed XML, because the '' Em '' and '' Strong '' elements overlap: Normal emphasized strong emphasized strong XML provides special syntax for representing an element with empty content. Instead of writing a start tag followed immediately by an end tag, a document may contain an empty-element tag. An empty-element tag resembles a start tag but contains a slash just before the closing angle bracket. The following three examples are equivalent in XML: An empty-element tag may contain attributes: Entity references XML provides two methods for referring to special characters: Character Entity Reference s and Numeric Character Reference s. An Entity in XML is a named body of data, usually text, such as an unusual character. An entity reference is a Placeholder that represents that entity. It consists of the entity's name preceded by an Ampersand (" &") and followed by a Semicolon (";"). XML has five Predeclared entities:Here is an example using a predeclared XML entity to represent the ampersand in the name "AT&T": If more entities need to be declared, this is done in the document's Document Type Definition (DTD) . A basic example of doing so in a minimal internal DTD follows. Declared entities can describe single characters or pieces of text, and can reference each other. ]> ©right-notice; When viewed in a suitable browser, the XML document above appears as: Copyright © 2006, XYZ Enterprises Numeric character references Numeric character references look like entity references, but instead of a name, they contain the " # " character followed by a number. The number (in decimal or "x"-prefixed Hexadecimal ) represents a Unicode code point. Unlike entity references, they are neither predeclared nor do they need to be declared in the document's DTD. They have typically been used to represent characters that are not easily encodable, such as an Arabic character in a document produced on a European computer. The ampersand in the "AT&T" example could also be Escaped like this (decimal 38 and hexadecimal 26 both represent the Unicode code point for the "&" character):There are many more rules necessary to be sure of writing well-formed XML documents, such as the use of Namespaces and the exact characters allowed in an XML name, but this quick tour provides the basics necessary to read and understand many XML documents. Well-formed documents A well-formed document must conform to the following rules, among others:
Element names are case-sensitive. For example, the following is a well-formed matching pair: : <Step> … </Step>whereas this is not : <Step> … </step>The careful choice of names for XML elements will convey the meaning of the data in the Markup . This increases human readability while retaining the rigor needed for software parsing. Choosing meaningful names implies the Semantics of elements and attributes to a human reader without reference to external documentation. However, this can lead to verbosity, which complicates Authoring and increases File Size . Automatic verification It is relatively simple to verify that a document is well-formed or validated XML, because the rules of well-formedness and validation of XML are designed for portability of tools. The idea is that any tool designed to work with XML files will be able to work with XML files written in any XML language (or XML application). One example of using an independent tool follows:
irb> require "rexml/document" irb> include REXML irb> doc = Document.new(File.new("test.xml")).root VALID DOCUMENTS: XML SEMANTICS By leaving the names, allowable hierarchy, and meanings of the elements and attributes open and definable by a customizable '' Schema or DTD '', XML provides a syntactic foundation for the creation of purpose specific, XML-based markup languages. The general syntax of such languages is rigid — documents must adhere to the general rules of XML, ensuring that all XML-aware software can at least read and understand the relative arrangement of information within them. The schema merely supplements the syntax rules with a set of constraints. Schemas typically restrict element and attribute names and their allowable containment hierarchies, such as only allowing an element named 'birthday' to contain 1 element named 'month' and 1 element named 'day', each of which has to contain only character data. The constraints in a schema may also include Data Type assignments that affect how information is processed; for example, the 'month' element's character data may be defined as being a month according to a particular schema language's conventions, perhaps meaning that it must not only be formatted a certain way, but also must not be processed as if it were some other type of data. An XML document that complies with a particular schema/DTD, in addition to being well-formed, is said to be valid. An XML schema is a description of a type of XML document, typically expressed in terms of Constraints on the structure and content of documents of that type, above and beyond the basic constraints imposed by XML itself. A number of standard and proprietary XML schema languages have emerged for the purpose of formally expressing such schemas, and some of these languages are XML-based, themselves. Before the advent of generalised data description languages such as SGML and XML, software designers had to define special File Format s or small languages to share data between programs. This required writing detailed Specifications and special-purpose parsers and Writer s. XML's regular structure and strict parsing rules allow software designers to leave parsing to standard tools, and since XML provides a general, Data Model -oriented framework for the development of application-specific languages, software designers need only concentrate on the development of rules for their data, at relatively high levels of abstraction. Well-tested tools exist to whether the document conforms to constraints expressed in the schema. Some of these validation tools are included in XML parsers, and some are packaged separately. Other usages of schemas exist: XML editors, for instance, can use schemas to support the editing process (by suggesting valid elements and attributes names, etc). DTD See Also: Document Type Definition The oldest schema format for XML is the Document Type Definition (DTD), inherited from SGML. While DTD support is ubiquitous due to its inclusion in the XML 1.0 standard, it is seen as limited for the following reasons:
XML Schema See Also: XML Schema (W3C) A newer XML Schema language, described by the W3C as the successor of DTDs, is XML Schema , or more informally referred to by the Initialism for XML Schema instances, XSD (XML Schema Definition). XSDs are far more powerful than DTDs in describing XML languages. They use a rich Datatyping system, allow for more detailed constraints on an XML document's Logical Structure , and must be processed in a more Robust validation framework. XSDs also use an XML-based format which makes it possible to use ordinary XML tools to help process them, although XSD implementations require much more than just the ability to read XML. Criticisms of XSD include the following:
RELAX NG See Also: RELAX NG Another popular schema language for XML is framework Plug-in s; a RELAX NG schema author, for example, can require values in an XML document to conform to definitions in XML Schema Datatypes. ISO DSDL and Other Schema Languages The ISO DSDL (Document Schema Description Languages) standard brings together a comprehensive set of small schema languages, each targeted at specific problems. DSDL includes RELAX NG full and compact syntax, Schematron assertion language, and languages for defining datatypes, character repertoire constraints, renaming and entity expansion, and namespace-based Routing of document fragments to different validators. DSDL schema languages do not have the vendor support of XML Schemas yet, and are to some extent a grassroots reaction of industrial publishers to the lack of utility of XML Schemas for Publishing . Some schema languages not only describe the structure of a particular XML format but also offer limited facilities to influence processing of individual XML files that conform to this format. DTDs and XSDs both have this ability; they can for instance provide attribute defaults. RELAX NG and Schematron intentionally do not provide these; for example the Infoset augmentation facility. International use XML supports the direct use of almost any Unicode character (other than the ones that have special symbolic meaning in XML, itself, such as the open corner bracket, "<") in element names, attributes, comments, character data, and processing instructions. Therefore, the following is a well-formed XML document, even though it includes both Chinese and Cyrillic characters: <俄語>Данные俄語> DISPLAYING XML ON THE WEB Because XML is a ''data description'' language, XML documents do not carry information about how to display the data. Without using CSS or XSL , a generic XML document is rendered as raw XML text by most Web Browser s. Some display it with ' Handles ' (e.g. + and - signs in the margin) that allow parts of the structure to be expanded or collapsed with mouse-clicks. In order to style the rendering in a browser with CSS, the XML document must include a reference to the Stylesheet : Note that this is different from specifying such a stylesheet in HTML, which uses the <link> element.Extensible Stylesheet Language (XSL) can be used to alter the format of XML data, either into HTML or other formats that are suitable for a browser to display. To specify Client-side XSL Transformation (XSLT), the following processing instruction is required in the XML: Client-side XSLT is supported by many Web Browser s, but not Opera before version 9.0. An alternative, rather than being dependent on the End-user 's browser capabilities, is to use XSL to convert XML into a displayable format ''on the Server ''. The end-user is not aware of what has gone on 'behind the scenes'; all they see is well-formatted, displayable data. See the XSLT article For An Example Of Server-side XSLT In Action . XML EXTENSIONS
XML files may be served with a variety of . This page discusses further XML And MIME . PROCESSING XML FILES Three traditional techniques for processing XML files are:
More recent and emerging techniques for processing XML files are:
Simple API for XML (SAX) SAX is a Lexical , Event-driven interface in which a document is read serially and its contents are reported as " Callback s" to various Method s on a Handler Object of the user's design. SAX is fast and efficient to implement, but difficult to use for extracting information at random from the XML, since it tends to burden the application author with keeping track of what part of the document is being processed. It is better suited to situations in which certain types of information are always handled the same way, no matter where they occur in the document. DOM DOM is an Interface -oriented API that allows for navigation of the entire document as if it were a tree of " Node " Object s representing the document's contents. A DOM document can be created by a parser, or can be generated manually by users (with limitations). Data types in DOM Nodes are abstract; implementations provide their own Programming language-specific Binding s. DOM implementations tend to be Memory intensive, as they generally require the entire document to be loaded into memory and constructed as a tree of objects before access is allowed. Transformation engines and filters A Filter in the Extensible Stylesheet Language (XSL) family can transform an XML file for Display ing or Print ing.
Push Parsing A form of XML access that has become increasingly popular in recent years is in which the structure of the code performing the parsing mirrors the structure of the XML being parsed, and intermediate parsed results can be used and accessed as local variables within the methods performing the parsing, or passed down (as method parameters) into lower-level methods, or returned (as method return values) to higher-level methods. For instance, in the Java programming language, the StAX framework can be used to create what is essentially an 'iterator' which sequentially visits the various elements, attributes, and data in an XML document. Code which uses this 'iterator' can test the current item (to tell, for example, whether it is a start or end element, or text), and inspect its attributes (local name, namespace, values of XML attributes, value of text, etc.), and can also request that the iterator be moved to the 'next' item. The code can thus extract information from the document as it traverses it. One significant advantage of push-parsing methods is that they typically are much more speed- and memory-efficient than SAX and DOM styles of parsing XML. Another advantage is that the recursive-descent approach tends to lend itself easily to keeping data as typed local variables in the code doing the parsing, while SAX, for instance, typically requires a parser to manually maintain intermediate data within a stack of elements which are parent elements of the element being parsed. This tends to mean that push-parsing code is often much more straightforward to understand and maintain than SAX parsing code. Some potential disadvantages of push parsing are that it is a newer approach which is not as well known among XML programmers (although it is by far the most common method used for writing compilers and interpreters for languages other than XML), and that most existing push parsers cannot yet perform advanced processing such as XML schema validation as they parse a document. Data binding Another form of XML Processing API is ).http://www.cis.strath.ac.uk/research/snaque/ Non-extractive XML Processing API Non-extractive XML Processing API is a new and emerging category of parsers. The most representative is VTD-XML , which abolishes the object-oriented modeling of XML hierarchy and instead uses 64-bit Virtual Token Descriptors (encoding offsets, lengths, depths, and types) of XML tokens. VTD-XML's approach enables a number of interesting features/enhancements, such as high performance, low memory usage http://www.javaworld.com/javaworld/jw-03-2006/jw-0327-simplify.html, ASIC implementation http://www.ximpleware.com/wp_SUN.pdf, incremental update http://www.javaworld.com/javaworld/jw-07-2006/jw-0724-vtdxml.html, and native XML indexing http://vtd-xml.sf.net/persistence.html. Specific XML applications and editors The Native File Format of OpenOffice.org , AbiWord , and Apple 's IWork applications is XML. Some parts of Microsoft Office 2007 are also able to edit XML files with a user-supplied schema (but not a DTD), and Microsoft has released a file format compatibility kit for Office 2003 that allows previous versions of Office to save in the new XML based format. There are dozens of other XML Editor s available. HISTORY The versatility of SGML for dynamic information display was understood by early digital media publishers in the late 1980s prior to the rise of the Internet. 3 4 By the mid-1990s some practitioners of SGML had gained experience with the then-new World Wide Web , and believed that SGML offered solutions to some of the problems the Web was likely to face as it grew. Dan Connolly added SGML to the list of W3C's activities when he joined the staff in 1995; work began in mid-1996 when Jon Bosak developed a charter and recruited collaborators. Bosak was well connected in the small community of people who had experience both in SGML and the Web. He received support in his efforts from Microsoft . XML was compiled by a served as Technical Lead of the Working Group, notably contributing the empty-element " The XML Working Group never met face-to-face; the design was accomplished using a combination of email and weekly teleconferences. The major design decisions were reached in twenty weeks of intense work between July and November of 1996, when the first Working Draft of an XML specification was published.http://www.w3.org/TR/WD-xml-961114.html Further design work continued through 1997 , and XML 1.0 became a W3C Recommendation on February 10 , 1998 . XML 1.0 achieved the Working Group's goals of Internet usability, general-purpose usability, SGML compatibility, facilitation of easy development of processing software, minimization of optional features, legibility, formality, conciseness, and ease of authoring. Like its antecedent SGML, XML allows for some redundant syntactic constructs and includes repetition of element identifiers. In these respects, terseness was not considered essential in its structure. Sources XML is a profile of an ISO standard SGML , and most of XML comes from SGML unchanged. From SGML comes the separation of logical and physical structures (elements and entities), the availability of grammar-based validation (DTDs), the separation of data and metadata (elements and attributes), mixed content, the separation of processing from representation (processing instructions), and the default angle-bracket syntax. Removed were the SGML Declaration (XML has a fixed delimiter set and adopts Unicode as the document Character Set ). Other sources of technology for XML were the notion that metadata accompanied the resource rather than being needed at the declaration of a link; and the Extended Reference Concrete Syntax (ERCS), from which XML 1.0's naming rules were taken, and which had introduced hexadecimal numeric character references and the concept of references to make available all Unicode characters. Ideas that developed during discussion which were novel in XML, were the algorithm for encoding detection and the encoding header, the processing instruction target, the xml:space attribute, and the new close delimiter for empty element tags. Versions |
|
|