1、 Reference number ISO/IEC 22537:2006(E) ISO/IEC 2006INTERNATIONAL STANDARD ISO/IEC 22537 First edition 2006-02-15Information technology ECMAScript for XML (E4X) specification Technologies de linformation ECMAScript pour spcification XML (E4X) ISO/IEC 22537:2006(E) PDF disclaimer This PDF file may co
2、ntain embedded typefaces. In accordance with Adobes licensing policy, this file may be printed or viewed but shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this file, parties accept therein the responsi
3、bility of not infringing Adobes licensing policy. The ISO Central Secretariat accepts no liability in this area. Adobe is a trademark of Adobe Systems Incorporated. Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation p
4、arameters were optimized for printing. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below. ISO/IEC 2006 All rights reserved. Unless
5、otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISOs member body in the country of the requester. ISO copy
6、right office Case postale 56 CH-1211 Geneva 20 Tel. + 41 22 749 01 11 Fax + 41 22 749 09 47 E-mail copyrightiso.org Web www.iso.org Published in Switzerland ii ISO/IEC 2006 All rights reservedISO/IEC 22537:2006(E) ISO 2006 All rights reserved iiiContents Foreword. v Introduction . vi 1 Scope 1 2 Ref
7、erences1 2.1 Normative References.1 2.2 Informative References .1 3 Definitions 2 4 Conformance3 5 Motivation.3 5.1 The Rise of XML Processing 3 5.2 Current XML Processing Approaches.3 5.3 The E4X Approach.4 6 Design Principles.4 7 Notational Conventions 5 7.1 Algorithm Conventions .5 8 Lexical Conv
8、entions9 8.1 Context Keywords .10 8.2 Punctuators 10 8.3 XML Initialiser Input Elements11 9 Types.12 9.1 The XML Type.12 9.2 The XMLList Type 22 9.3 The AttributeName Type .29 9.4 The AnyName Type30 10 Type Conversion30 10.1 ToString 30 10.2 ToXMLString (input argument, AncestorNamespaces, IndentLev
9、el)32 10.3 ToXML.35 10.4 ToXMLList.39 10.5 ToAttributeName40 10.6 ToXMLName .41 11 Expressions42 11.1 Primary Expressions .42 11.2 Left-Hand-Side Expressions.48 11.3 Unary Operators.55 11.4 Additive Operators.56 11.5 Equality Operators.57 11.6 Assignment Operators 58 12 Statements62 12.1 The default
10、 xml namespace Statement .62 12.2 The for-in Statement63 12.3 The for-each-in Statement 65 13 Native E4X Objects 67 13.1 The Global Object 67 13.2 Namespace Objects.68 ISO/IEC 22537:2006(E) iv ISO/IEC 2006 All rights reserved13.3 QName Objects . 70 13.4 XML Objects. 74 13.5 XMLList Objects 92 14 Err
11、ors 100 Annex A (normative) Optional Features. 101 ISO/IEC 22537:2006(E) ISO 2006 All rights reserved vForeword ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies
12、that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other inte
13、rnational organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1. International Standards are drafted in accordance with the rules given
14、 in the ISO/IEC Directives, Part 2. The main task of the joint technical committee is to prepare International Standards. Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an International Standard requires approval by
15、 at least 75 % of the national bodies casting a vote. Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. ISO/IEC 22537 was prepared by Joint Tec
16、hnical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 22, Programming languages, their environments and system software interfaces, and was adopted (as Ecma-357), under a special “fast-track procedure”, by Joint Technical Committee ISO/IEC JTC 1, Information technology, in parallel
17、 with its approval by national bodies of ISO and IEC. ISO/IEC 22537:2006(E) vi ISO/IEC 2006 All rights reservedIntroduction On 13 June 2002, a group of companies led by BEA Systems proposed a set of programming language extensions adding native XML support to ECMAScript (ISO/IEC 16262). The programm
18、ing language extensions were designed to provide a simple, familiar, general purpose XML programming model that flattens the XML learning curve by leveraging the existing skills and knowledge of one of the largest developer communities worldwide. The benefits of this XML programming model include re
19、duced code complexity, tighter revision cycles, faster time to market, decreased XML footprint requirements and looser coupling between code and XML data. The ECMAScript group (Ecma TC39-TG1) unanimously agreed to the proposal and established a sub-group to standardize the syntax and semantics of a
20、general purpose, cross platform, vendor neutral set of programming language extensions called ECMAScript for XML (E4X). The development of this International Standard started on 8 August 2002. This Standard was developed as an extension to ECMAScript Edition 3, but may be applied to other versions o
21、f ECMAScript as well. This International Standard adds native XML datatypes to the ECMAScript language, extends the semantics of familiar ECMAScript operators for manipulating XML data and adds a small set of new operators for common XML operations, such as searching and filtering. It also adds supp
22、ort for XML literals, namespaces, qualified names and other mechanisms to facilitate XML processing. This International Standard will be integrated into future editions of ISO/IEC 16262 (ECMAScript). The ECMAScript group is working on significant enhancements for future editions of the ECMAScript la
23、nguage, including mechanisms for defining XML types using the XML Schema language and support for classes. INTERNATIONAL STANDARD ISO/IEC 22537:2006(E) ISO/IEC 2006 All rights reserved 1Information technology ECMAScript for XML (E4X) specification 1 Scope This International Standard defines the synt
24、ax and semantics of ECMAScript for XML (E4X), a set of programming language extensions adding native XML support to ECMAScript. 2 References 2.1 Normative References The following referenced documents are indispensable for the application of this document. For dated references, only the edition cite
25、d applies. For undated references, the latest edition of the referenced document (including any amendments) applies. ISO/IEC 10646:2003, Information Technology Universal Multiple-Octet Coded Character Set (UCS). ISO/IEC 16262:2001, ECMAScript Language Specification 2 ndedition. Document Object Model
26、 (DOM) Level 2 Specifications, W3C Recommendation, 13 November 2000. Extensible Markup Language 1.0 (Second Edition), W3C Recommendation 6 October 2000. Namespaces in XML, W3C Recommendation, 14 January 1999. Unicode Inc. (1996), The Unicode Standard TM , Version 2.0. ISBN: 0-201-48345-9, Addison-We
27、sley Publishing Co., Menlo Park, California. Unicode Inc. (1998), Unicode Technical Report #8: The Unicode Standard TM , Version 2.1. Unicode Inc. (1998), Unicode Technical Report #15: Unicode Normalization Forms. XML Information Set, W3C Recommendation 24 October 2001. XML Path Language (XPath) Ver
28、sion 1.0, W3C Recommendation 16 November 1999. XML Schema Part 1: Structures, W3C Recommendation, 2 May 2001. XML Schema Part 2: Datatypes, W3C Recommendation, 2 May 2001. 2.2 Informative References The following are non-normative references XSL Transformations (XSLT), W3C Recommendation 16 November
29、 1999. ISO/IEC 22537:2006(E) 2 ISO/IEC 2006 All rights reserved3 Definitions XML the Extensible Markup Language (XML) is an information encoding standard endorsed by the World Wide Web Consortium (W3C) for sending, receiving, and processing data across the World Wide Web. XML comprises a series of c
30、haracters that contains not only substantive information, called character data, but also meta-information about the structure and layout of the character data, called markup. markup one of the two basic constituents of XML data (the other is character data). Markup is a series of characters that pr
31、ovides information about the structure or layout of character data. Common forms of markup are start-tags, end-tags, empty-element tags, comments, CDATA tag delimiters, and processing instructions. character data one of the two basic constituents of XML data (the other is markup). Character data is
32、a series of characters that represents substantive data encapsulated by XML markup. Character data is defined as any series of characters that are not markup. tag a single markup entity that acts as a delimiter for character data. A tag can be a start-tag, an end-tag, or an empty-element tag. Start-
33、tags begin with a less than () character. End-tags begin with a pairing of the less than and slash characters () character. Empty-element begin with a less than () characters. element a data construct comprising two tags (a start-tag and an end-tag) that delimit character data or nested elements. If
34、 neither character data nor nested elements exist for a given element, then the element can be defined by a single empty-element tag. Every well-formed XML document contains at least one element, called the root or document element. attribute an optional name-value pair, separated by an equal sign (
35、=), that can appear inside a tag. Attributes can store information about an element or actual data that would otherwise be stored as character data. namespace a group of identifiers for elements and attributes that are collectively bound to a Uniform Resource Identifier (URI) such that their use wil
36、l not cause naming conflicts when used with identically named identifiers that are in a different namespace. processing-instruction a markup entity that contains instructions or information for the application that is processing the XML. Processing-instruction tags begin with a combination of the le
37、ss than (). type a set of data values. ISO/IEC 22537:2006(E) ISO/IEC 2006 All rights reserve 34 Conformance A conforming implementation of E4X shall provide and support all the mandatory types, values, objects, properties, functions, and program syntax and semantics described in this specification.
38、A conforming implementation of this Standard shall conform to the ECMAScript Language Specfication, ISO/IEC 16262:2001. A conforming implementation of this Standard shall interpret characters in conformance with the Unicode Standard, Version 2.1 or later, and ISO/IEC 10646-1 with either UCS-2 or UTF
39、-16 as the adopted encoding form, implementation level 3. If the adopted ISO/IEC 10646-1 subset is not otherwise specified, it is presumed to be the BMP subset, collection 300. If the adopted encoding form is not otherwise specified, it presumed to be the UTF-16 encoding form. A conforming implement
40、ation of E4X may provide additional types, values, objects, properties, and functions beyond those described in this specification. In particular, a conforming implementation of E4X may provide properties not described in this specification, and values for those properties, for objects that are desc
41、ribed in this specification. A conforming implementation of E4X shall not provide methods for XML.prototype and XMLList.prototype other than those described in this specification. 5 Motivation This section contains a non-normative overview of the motivation behind ECMAScript for XML. 5.1 The Rise of
42、 XML Processing Developing software to create, navigate and manipulate XML data is a significant part of every developers job. Developers are inundated with data encoded in the eXtensible Markup Language (XML). Web pages are increasingly encoded using XML vocabularies, including XHTML and Scalable V
43、ector Graphics (SVG). On mobile devices, data is encoded using the Wireless Markup Language (WML). Web services interact using the Simple Object Access Protocol (SOAP) and are described using the Web Service Description Language (WSDL). Deployment descriptors, project make files and configuration fi
44、les and now encoded in XML, not to mention an endless list of custom XML vocabularies designed for vertical industries. XML data itself is even described and processed using XML in the form of XML Schemas and XSL Stylesheets. 5.2 Current XML Processing Approaches Current XML processing techniques re
45、quire ECMAScript programmers to learn and master a complex array of new concepts and programming techniques. The XML programming models often seem heavyweight, complex and unfamiliar for ECMAScript programmers. This section provides a brief overview of the more popular XML processing techniques. 5.2
46、.1 The Document Object Model (DOM) One of the most common approaches to processing XML is to use a software package that implements the interfaces defined by the W3C XML DOM (Document Object Model). The XML DOM represents XML data using a general purpose tree abstraction and provides a tree-based AP
47、I for navigating and manipulating the data (e.g., getParentNode(), getChildNodes(), removeChild(), etc.). This method of accessing and manipulating data structures is very different from the methods used to access and manipulate native ECMAScript data structures. ECMAScript programmers must learn to
48、 write tree navigation algorithms instead of object navigation algorithms. In addition, they have to learn a relatively complex interface hierarchy for interacting with the XML DOM. The resulting XML DOM code is generally harder to read, write, and maintain than code that manipulates native ECMAScri
49、pt data structures. It is more verbose and often obscures the developers intent with lengthy tree navigation logic. Consequently, XML DOM programs require more time, knowledge and resources to develop. ISO/IEC 22537:2006(E) 4 ISO/IEC 2006 All rights reserved5.2.2 The eXtensible Stylesheet Language (XSLT) XSLT is a language for transforming XML documents into other XML documents. Like the XML DOM, it represents XML data using a tree-based abstraction, but also provides an expression language called XPath designed f