Download: XML Pocket Reference

,TITLE.15229 Page i Wednesday, September 12, 2001 1:12 PM XML Pocket Reference ,TITLE.15229 Page ii Wednesday, September 12, 2001 1:12 PM ,TITLE.15229 Page iii Wednesday, September 12, 2001 1:12 PM XML Pocket Reference Second Edition Robert Eckstein with Michel Casabianca Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo ,COPYRIGHT.15383 Page iv Wednesday, September 12, 2001 1:12 PM XML Pocket Reference, Second Edition by Robert Eckstein with Michel Casabianca Copyright © 2001, 1999 O’Reilly & Associates, Inc. All rights reserved. Printed in the United States of Americ...
Author: Walton Shared: 7/30/19
Downloads: 947 Views: 4985


,TITLE.15229 Page i Wednesday, September 12, 2001 1:12 PM

XML Pocket Reference

, ,TITLE.15229 Page ii Wednesday, September 12, 2001 1:12 PM, ,TITLE.15229 Page iii Wednesday, September 12, 2001 1:12 PM

XML Pocket Reference Second Edition Robert Eckstein

with Michel Casabianca Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo, ,COPYRIGHT.15383 Page iv Wednesday, September 12, 2001 1:12 PM

XML Pocket Reference, Second Edition

by Robert Eckstein with Michel Casabianca Copyright © 2001, 1999 O’Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472. Editor: Ellen Siever Production Editor: Jeffrey Holcomb Cover Designer: Hanna Dyer Printing History: October 1999: First Edition April 2001: Second Edition Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly & Associates, Inc. The use of the image of the peafowl in association with XML is a trademark of O’Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. 0-596-00133-9 [C] [5/01],

Table of Contents

Intr oduction ... 1 XML Ter minology ... 2 Unlear ning Bad Habits ... 3 An Overview of an XML Document ... 5 A Simple XML Document ... 5 A Simple Document Type Definition (DTD) ... 9 A Simple XSL Stylesheet ... 10 XML Reference ... 13 Well-For med XML ... 14 Special Markup ... 14 Element and Attribute Rules ... 17 XML Reserved Attributes ... 19 Entity and Character References ... 20 Document Type Definitions ... 21 Element Declarations ... 22 ANY and PCDATA ... 22 Entities ... 26 Attribute Declarations in the DTD ... 29 Included and Ignored Sections ... 34 The Extensible Stylesheet Language ... 37 For matting Objects ... 38 XSLT Stylesheet Structure ... 39 v, Templates and Patterns ... 40 Parameters and Variables ... 43 Stylesheet Import and Rules of Precedence ... 44 Loops and Tests ... 45 Numbering Elements ... 46 Output Method ... 47 XSLT Elements ... 48 XPath ... 70 Axes ... 73 Pr edicates ... 74 Functions ... 76 Additional XSLT Functions and Types ... 79 XPointer and XLink ... 81 Unique Identifiers ... 81 ID References ... 82 XPointer ... 83 XLink ... 87 Building Extended Links ... 90 XBase ... 96 vi,

XML Pocket Reference Introduction

The Extensible Markup Language (XML) is a document- pr ocessing standard that is an official recommendation of the World Wide Web Consortium (W3C), the same group respon- sible for overseeing the HTML standard. Many expect XML and its sibling technologies to become the markup language of choice for dynamically generated content, including non- static web pages. Many companies are alr eady integrating XML support into their products. XML is actually a simplified form of Standar d Generalized Markup Language (SGML), an international documentation standard that has existed since the 1980s. However, SGML is extr emely complex, especially for the Web. Much of the credit for XML’s creation can be attributed to Jon Bosak of Sun Micr osystems, Inc., who started the W3C working group responsible for scaling down SGML to a form mor e suitable for the Internet. Put succinctly, XML is a meta language that allows you to cre- ate and format your own document markups. With HTML, existing markup is static: and , for example, ar e tightly integrated into the HTML standard and cannot be changed or extended. XML, on the other hand, allows you to cr eate your own markup tags and configure each to your lik- ing — for example, , , , or . Each of these elements can be defined through your own document type definitions and stylesheets and applied to one or more XML documents. XML schemas pro- vide another way to define elements. Thus, it is important to Introduction 1, realize that there are no “corr ect” tags for an XML document, except those you define yourself. While many XML applications currently support Cascading Style Sheets (CSS), a more extensible stylesheet specification exists, called the Extensible Stylesheet Language (XSL). With XSL, you ensure that XML documents are for matted the same way no matter which application or platform they appear on. XSL consists of two parts: XSLT (transfor mations) and XSL-FO ( for matting objects). Transfor mations, as discussed in this book, allow you to work with XSLT and convert XML docu- ments to other formats such as HTML. Formatting objects are described briefly in the section “Formatting Objects.” This book offers a quick overview of XML, as well as some sample applications that allow you to get started in coding. We won’t cover everything about XML. Some XML-related specifications are still in flux as this book goes to print. How- ever, after reading this book, we hope that the components that make up XML will seem a little less foreign.

XML Ter minolog y

Befor e we move further, we need to standardize some termi- nology. An XML document consists of one or more elements. An element is marked with the following form: This is text formatted according to the Body element . This element consists of two tags: an opening tag, which places the name of the element between a less-than sign (<) and a greater-than sign (>), and a closing tag, which is identi- cal except for the forward slash (/) that appears before the element name. Like HTML, the text between the opening and closing tags is considered part of the element and is pro- cessed according to the element’s rules. 2 XML Pocket Reference, Elements can have attributes applied, such as the following: 25.43 Her e, the attribute is specified inside of the opening tag and is called curr ency. It is given a value of Eur o, which is placed inside quotation marks. Attributes are often used to further refine or modify the default meaning of an element. In addition to the standard elements, XML also supports empty elements. An empty element has no text between the opening and closing tags. Hence, both tags can (optionally) be com- bined by placing a forward slash before the closing marker. For example, these elements are identical: Empty elements are often used to add nontextual content to a document or provide additional information to the application that parses the XML. Note that while the closing slash may not be used in single-tag HTML elements, it is mandatory for single-tag XML empty elements.

Unlear ning Bad Habits

Wher eas HTML browsers often ignore simple errors in docu- ments, XML applications are not nearly as forgiving. For the HTML reader, ther e areafew bad habits from which we should dissuade you: XML is case-sensitive Element names must be used exactly as they are defined. For example, and ar e not the same. Attribute values must be in quotation marks You can’t specify an attribute value as , an err or that HTML browsers often overlook. An attribute value must always be inside XML Ter minolog y 3, single or double quotation marks, or else the XML parser will flag it as an error. Her e is the correct way to specify such a tag: A non-empty element must have an opening and a closing tag Each element that specifies an opening tag must have a closing tag that matches it. If it does not, and it is not an empty element, the XML parser generates an error. In other words, you cannot do the following: This is a paragraph. This is another paragraph. Instead, you must have an opening and a closing tag for each paragraph element: This is a paragraph. This is another paragraph. Tags must be nested correctly It is illegal to do the following: This is incorrect The closing tag for the element should be inside the closing tag for the element to match the near- est opening tag and preserve the correct element nesting. It is essential for the application parsing your XML to pro- cess the hierarchy of the elements: This is correct These syntactic rules are the source of many common errors in XML, especially because some of this behavior can be ignor ed by HTML browsers. An XML document adhering to these rules (and a few others that we’ll see later) is said to be well-for med. 4 XML Pocket Reference,

An Overview of an XML Document

Generally, two files are needed by an XML-compliant applica- tion to use XML content: The XML document This file contains the document data, typically tagged with meaningful XML elements, any of which may con- tain attributes. Document Type Definition (DTD) This file specifies rules for how the XML elements, attributes, and other data are defined and logically related in the document. Additionally, another type of file is commonly used to help display XML data: the stylesheet. The stylesheet dictates how document elements should be for- matted when they are displayed. Note that you can apply dif- fer ent stylesheets to the same document, depending on the envir onment, thus changing the document’s appearance with- out affecting any of the underlying data. The separation between content and formatting is an important distinction in XML.

A Simple XML Document

Example 1 shows a simple XML document. Example 1. sample.xml XML Pocket Reference 12.95 Let’s look at this example line by line. In the first line, the code between the is called an XML declaration. This declaration contains special XML Ter minolog y 5, infor mation for the XML processor (the program reading the XML), indicating that this document conforms to Version 1.0 of the XML standard and uses UTF-8 (Unicode optimized for ASCII) encoding. The second line is as follows: This line points out the root element of the document, as well as the DTD validating each of the document elements that appear inside the root element. The root element is the outer- most element in the document that the DTD applies to; it typi- cally denotes the document’s starting and ending point. In this example, the element serves as the root ele- ment of the document. The SYSTEM keyword denotes that the DTD of the document resides in an external file named sam- ple.dtd. On a side note, it is possible to simply embed the DTD in the same file as the XML document. However, this is not recommended for general use because it hampers reuse of DTDs. Following that line is a comment. Comments always begin with . You can write whatever you want inside comments; they are ignor ed by the XML processor. Be awar e that comments, however, cannot come before the XML declaration and cannot appear inside an element tag. For example, this is illegal: > Finally, the elements , , and ar e XML elements we invented. Like most ele- ments in XML, they hold no special significance except for whatever document rules we define for them. Note that these elements look slightly differ ent than those you may have seen pr eviously because we are using namespaces. Each element tag can be divided into two parts. The portion before the colon (:) identifies the tag’s namespace; the portion after the colon identifies the name of the tag itself. 6 XML Pocket Reference, Let’s discuss some XML terminology. The and elements would both consider the element their par ent. In the same manner, ele- ments can be grandpar ents and grandchildr en of other ele- ments. However, we typically abbreviate multiple levels by stating that an element is either an ancestor or a descendant of another element. Namespaces Namespaces wer e cr eated to ensure uniqueness among XML elements. They are not mandatory in XML, but it’s often wise to use them. For example, let’s pretend that the element was simply named . When you think about it, it’s not out of the question that another publisher would create its own element in its own XML documents. If the two publishers combined their documents, resolving a single (cor- rect) definition for the tag would be impossible. When two XML documents containing identical elements from dif ferent sources are merged, those elements are said to col- lide. Namespaces help to avoid element collisions by scoping each tag. In Example 1, we scoped each tag with the OReilly name- space. Namespaces are declar ed using the xmlns:something attribute, where something defines the prefix of the name- space. The attribute value is a unique identifier that differ enti- ates this namespace from all other namespaces; the use of a URI is recommended. In this case, we use the O’Reilly URI http://www.or as the default namespace, which should guarantee uniqueness. A namespace declaration can appear as an attribute of any element, in which case the namespace remains inside that element’s opening and closing tags. Here are some examples: ... XML Ter minolog y 7, ... You are allowed to define more than one namespace in the context of an element: ... If you do not specify a name after the xmlns pr efix, the name- space is dubbed the default namespace and is applied to all elements inside the defining element that do not use a name- space prefix of their own. For example: XML Pocket Reference 0-596-00133-9 18231 Her e, the default namespace (repr esented by the URI http://www.or is applied to the elements , , , and . However, it is not applied to the element, which has its own namespace. Finally, you can set the default namespace to an empty string. This ensures that there is no default namespace in use within a specific element:
Learn XML in a Week 10.00
Her e, the and elements have no default names- pace. 8 XML Pocket Reference,

A Simple Document Type Definition (DTD)

Example 2 creates a simple DTD for our XML document. Example 2. sample.dtd The purpose of this DTD is to declare each of the elements used in our XML document. All document-type data is placed inside a construct with the characters . Each construct declares a valid element for our XML document. With the second line, we’ve specified that the element is valid: The parentheses group together the requir ed child elements for the element . In this case, the and elements must be included inside our element tags, and they must appear in the order specified. The elements and ar e ther efor e consider ed childr en of . Likewise, the and elements are declar ed in our DTD: Again, parentheses specify requir ed elements. In this case, they both have a single requir ement, repr esented by #PCDATA. This is shorthand for parsed character data, which means that any characters are allowed, as long as they do not include XML Ter minolog y 9, other element tags or contain the characters < or &, or the sequence ]]>. These characters are forbidden because they could be interpreted as markup. (We’ll see how to get around this shortly.) The line indicates that the attribute of the element defaults to the URI associated with O’Reilly & Associates if no other value is explicitly speci- fied in the element. The XML data shown in Example 1 adheres to the rules of this DTD: it contains an element, which in turn contains an element followed by an element inside it (in that order). Therefor e, if this DTD is applied to the data with a statement, the document is said to be valid.

A Simple XSL Stylesheet

XSL allows developers to describe transformations using XSL Transfor mations (XSLT), which can convert XML documents into XSL Formatting Objects, HTML, or other textual output. As this book goes to print, the XSL Formatting Objects specifi- cation is still changing; therefor e, this book covers only the XSLT portion of XSL. The examples that follow, however, are consistent with the W3C specification. Let’s add a simple XSL stylesheet to the example: 10 XML Pocket Reference, The first thing you might notice when you look at an XSL stylesheet is that it is formatted in the same way as a regular XML document. This is not a coincidence. By design, XSL stylesheets are themselves XML documents, so they must adher e to the same rules as well-formed XML documents. Br eaking down the pieces, you should first note that all XSL elements must be contained in the appropriate outer element. This tells the XSLT processor that it is describing stylesheet information, not XML content itself. After the opening tag, we see an XSLT dir ective to optimize output for HTML. Following that are the rules that will be applied to our XML document, given by the elements (in this case, there is only one rule). Each rule can be further broken down into two items: a tem- plate pattern and a template action. Consider the line: This line forms the template pattern of the stylesheet rule. Her e, the target pattern is the root element, as designated by match="/". The / is shorthand to repr esent the XML document’s root element. The contents of the element: specify the template action that should be perfor med on the target. In this case, we see the empty element located inside a element. When the XSLT pro- cessor transforms the target element, every element inside the root element is surrounded by the tags, which will likely cause the application formatting the output to increase the font size. In our initial XML example, the and elements are both enclosed inside the tags. Therefor e, the font size will be applied to XML Ter minolog y 11, the contents of those tags. Example 3 displays a more realistic example.

Example 3. sample.xsl


Price: $ + tax
12 XML Pocket Reference, In this example, we target the element, print- ing the word Books: befor e it in a larger font size. In addition, the element applies the default font size to each of its children, and the tag uses a slightly larger font size to display its children, overriding the default size of its parent, . (Of course, neither one has any children elements; they simply have text between their tags in the XML document.) The text Price: $ will precede each of ’s children, and the characters + tax will come after it, formatted accordingly. Her e is the result after we pass sample.xsl thr ough an XSLT pr ocessor: Books:
XML Pocket Reference
Price $12.95 + tax
And that’s it: everything needed for a simple XML document! Running the result through an HTML browser, you should see something similar to Figure 1.

XML Reference

Now that you have had a quick taste of working with XML, her e is an overview of the more common rules and constructs of the XML language. XML Reference 13, Figur e 1. Sample XML output

Well-For med XML

These are the rules for a well-formed XML document: • All element attribute values must be in quotation marks. • An element must have both an opening and a closing tag, unless it is an empty element. • If a tag is a standalone empty element, it must contain a closing slash (/) befor e the end of the tag. • All opening and closing element tags must nest correctly. • Isolated markup characters are not allowed in text; < or & must use entity refer ences. In addition, the sequence ]]> must be expressed as ]]> when used as regular text. (Entity refer ences ar e discussed in further detail later.) • Well-for med XML documents without a corresponding DTD must have all attributes of type CDATA by default.

Special Markup

XML uses the following special markup constructs. 14 XML Pocket Reference, Although they are not requir ed to, XML documents typically begin with an XML declaration, which must start with the characters . Attributes include: version The version attribute specifies the correct version of XML requir ed to process the document, which is currently 1.0. This attribute cannot be omitted. encoding The encoding attribute specifies the character encoding used in the document (e.g., UTF-8 or iso-8859-1). UTF-8 and UTF-16 are the only encodings that an XML proces- sor is requir ed to handle. This attribute is optional. standalone The optional standalone attribute specifies whether an exter nal DTD is requir ed to parse the document. The value must be either yes or no (the default). If the value is no or the attribute is not present, a DTD must be declared with an XML instruction. If it is yes, no exter- nal DTD is requir ed. For example: A processing instruction allows developers to place attributes specific to an outside application within the document. Pro- cessing instructions always begin with the characters . For example: 15, You can create your own processing instructions if the XML application processing the document is aware of what the data means and acts accordingly. The instruction allows you to specify a DTD for an XML document. This instruction currently takes one of two for ms:


The SYSTEM variant specifies the URI location of a DTD for private use in the document. For example:


The PUBLIC variant is used in situations in which a DTD has been publicized for widespread use. In these cases, the DTD is assigned a unique name, which the XML pro- cessor may use by itself to attempt to retrieve the DTD. If this fails, the URI is used: Public DTDs follow a specific naming convention. See the XML specification for details on naming public DTDs. You can place comments anywhere in an XML document, except within element tags or before the initial XML process- ing instructions. Comments in an XML document always start 16 XML Pocket Reference, with the characters . In addition, they may not include double hyphens within the comment. The contents of the comment are ignor ed by the XML processor. For example: 2000 49.95


You can define special sections of character data, or CDATA, which the XML processor does not attempt to interpret as markup. Anything included inside a CDATA section is treated as plain text. CDATA sections begin with the characters . For example: tag of documents 5 & 6: "Sales" and "Profit and Loss". Luckily, the XML processor wont apply rules of formatting to these sentences! ]]> Note that entity refer ences inside a CDATA section will not be expanded.

Element and Attribute Rules

An element is either bound by its start and end tags or is an empty element. Elements can contain text, other elements, or a combination of both. For example: Elements can contain text, other elements, or a combination. For example, a chapter might contain a title and multiple paragraphs, and a paragraph might contain text and emphasis elements. CDATA 17, An element name must start with a letter or an underscore. It can then have any number of letters, numbers, hyphens, peri- ods, or underscores in its name. Elements are case-sensitive : , , and ar e consider ed thr ee dif ferent ele- ment types. Element type names may not start with the string xml in any variation of upper- or lowercase. Names beginning with xml ar e reserved for special uses by the W3C XML Working Gr oup. Colons (:) are per mitted in element type names only for specifying namespaces; otherwise, colons are forbidden. For example: Example Comment Legal <_Budget> Legal Illegal: has a space <205Para> Illegal: starts with number Illegal: contains @ character Illegal: starts with xml Element type names can also include accented Roman charac- ters, letters from other alphabets (e.g., Cyrillic, Greek, Hebr ew, Arabic, Thai, Hiragana, Katakana, or Devanagari), and ideograms from the Chinese, Japanese, and Korean lan- guages. Valid element type names can therefor e include , , , and , plus a number of others our publishing system isn’t equipped to handle. If you use a DTD, the content of an element is constrained by its DTD declaration. Better XML applications inform you which elements and attributes can appear inside a specific element. Otherwise, you should check the element declara- tion in the DTD to determine the exact semantics. 18 XML Pocket Reference, Attributes describe additional information about an element. They always consist of a name and a value, as follows: The attribute value is always quoted, using either single or double quotes. Attribute names are subject to the same restric- tions as element type names.

XML Reserved Attributes

The following are reserved attributes in XML. xml:lang xml:lang="iso_639_identifier" The xml:lang attribute can be used on any element. Its value indicates the language of the body of the element. This is use- ful in a multilingual context. For example, you might have: Hello Bonjour This format allows you to display one element or the other, depending on the user’s language prefer ence. The syntax of the xml:lang value is defined by ISO-639. A two- letter language code is optionally followed by a hyphen and a two-letter country code. Traditionally, the language is given in lowercase and the country in uppercase (and for safety, this rule should be followed), but processors are expected to use the values in a case-insensitive manner. In addition, ISO-3166 provides extensions for nonstandardized languages or language variants. Valid xml:lang values include notations such as en, en-US, en-UK, en-cockney, i-navajo, and x-minbari. xml:lang 19, xml:space xml:space="default|preserve" The xml:space attribute indicates whether any whitespace inside the element is significant and should not be altered by the XML processor. The attribute can take one of two enumer- ated values: pr eserve The XML application preserves all whitespace (newlines, spaces, and tabs) present within the element. default The XML processor uses its default processing rules when deciding to preserve or discard the whitespace inside the element. You should set xml:space to pr eserve only if you want an ele- ment to behave like the HTML element, such as when it documents source code.

Entity and Character References

Entity refer ences ar e used as substitutions for specific charac- ters (or any string substitution) in XML. A common use for entity refer ences is to denote document symbols that might otherwise be mistaken for markup by an XML processor. XML pr edefines five entity refer ences for you, which are substitu- tions for basic markup symbols. However, you can define as many entity refer ences as you like in your own DTD. (See the next section.) Entity refer ences always begin with an ampersand (&) and end with a semicolon (;). They cannot appear inside a CDATA section but can be used anywhere else. Predefined entities in XML are shown in the following table: 20 XML Pocket Reference, Entity Char Notes & & Do not use inside processing instructions. < < Use inside attribute values quoted with ". > > Use after ]] in normal text and inside processing instructions. " " Use inside attribute values quoted with ". ' Use inside attribute values quoted with . In addition, you can provide character refer ences for Unicode characters with a numeric character refer ence. A decimal char- acter refer ence consists of the string &#, followed by the deci- mal number repr esenting the character, and finally, a semicolon (;). For hexadecimal character refer ences, the string &#x is followed first by the hexadecimal number repr esenting the character and then a semicolon. For example, to repr esent the copyright character, you could use either of the following lines: This document is © 2001 by OReilly and Assoc. This document is © 2001 by OReilly and Assoc. The character refer ence is replaced with the “circled-C” (©) copyright character when the document is formatted.

Document Type Definitions

A DTD specifies how elements inside an XML document should relate to each other. It also provides grammar rules for the document and each of its elements. A document adhering to the XML specifications and the rules outlined by its DTD is consider ed to be valid. (Don’t confuse this with a well-formed document, which adheres only to the XML syntax rules out- lined earlier.) Document Type Definitions 21,

Element Declarations

You must declare each of the elements that appear inside your XML document within your DTD. You can do so with the declaration, which uses this format: This declares an XML element and an associated rule called a content model, which relates the element logically to the XML document. The element name should not include < > charac- ters. An element name must start with a letter or an under- scor e. After that, it can have any number of letters, numbers, hyphens, periods, or underscores in its name. Element names may not start with the string xml in any variation of upper- or lowercase. You can use a colon in element names only if you use namespaces; otherwise, it is forbidden.


The simplest element declaration states that between the opening and closing tags of the element, anything can appear: The ANY keyword allows you to include other valid tags and general character data within the element. However, you may want to specify a situation where you want only general characters to appear. This type of data is better known as parsed character data, or PCDATA. You can specify that an element contain only PCDATA with a declaration such as the following: Remember, this declaration means that any character data that is not an element can appear between the element tags. 22 XML Pocket Reference, Ther efor e, it’s legal to write the following in your XML docu- ment: XML Pocket Reference Java Network Programming However, the following is illegal with the previous PCDATA declaration: XML <emphasis>Pocket Reference</emphasis> On the other hand, you may want to specify that another ele- ment must appear between the two tags specified. You can do this by placing the name of the element in the parenthe- ses. The following two rules state that a element must contain a element, and a <title> element must contain parsed character data (or null content) but not another ele- ment: <!ELEMENT books (title)> <!ELEMENT title (#PCDAT A)> <h2>Multiple sequences</h2> If you wish to dictate that multiple elements must appear in a specific order between the opening and closing tags of a spe- cific element, you can use a comma (,) to separate the two instances: <!ELEMENT books (title, authors)> <!ELEMENT title (#PCDAT A)> <!ELEMENT authors (#PCDAT A)> In the preceding declaration, the DTD states that within the opening <books> and closing </books> tags, there must first appear a <title> element consisting of parsed character data. It must be immediately followed by an <authors> element con- taining parsed character data. The <authors> element cannot pr ecede the <title> element. Document Type Definitions 23, Her e is a valid XML document for the DTD excerpt defined pr eviously: <books> <title>XML Pocket Reference, Second Edition Robert Eckstein with Michel Casabianca The previous example showed how to specify both elements in a declaration. You can just as easily specify that one or the other appear (but not both) by using the vertical bar (|): This declaration states that either a element or an <authors> element can appear inside the <books> element. Note that it must have one or the other. If you omit both ele- ments or include both elements, the XML document is not consider ed valid. You can, however, use a recurr ence opera- tor to allow such an element to appear more than once. Let’s talk about that now. <h2>Grouping and recurrence</h2> You can nest parentheses inside your declarations to give finer granularity to the syntax you’re specifying. For example, the following DTD states that inside the <books> element, the XML document must contain either a <description> element or a <title> element immediately followed by an <author> ele- ment. All three elements must consist of parsed character data: <!ELEMENT books ((title, author)|description)> <!ELEMENT title (#PCDAT A)> <!ELEMENT author (#PCDAT A)> <!ELEMENT description (#PCDAT A)> Now for the fun part: you are allowed to dictate inside an ele- ment declaration whether a single element (or a grouping of elements contained inside parentheses) must appear zero or 24 XML Pocket Reference, one times, one or more times, or zero or mor e times. The characters used for this appear immediately after the target element (or element grouping) that they refer to and should be familiar to Unix shell programmers. Occurrence operators ar e shown in the following table: Attr ibute Descr iption ? Must appear once or not at all (zero or one times) + Must appear at least once (one or more times) * May appear any number of times or not at all (zero or mor e times) If you want to provide finer granularity to the <author> ele- ment, you can redefine the following in the DTD: <!ELEMENT author (authorname+)> <!ELEMENT authorname (#PCDAT A)> This indicates that the <author> element must have at least one <author name> element under it. It is allowed to have more than one as well. You can define more complex relationships with parentheses: <!ELEMENT reviews (rating, synopsis?, comments+)*> <!ELEMENT rating ((tutorial|reference)*, overall)> <!ELEMENT synopsis (#PCDAT A)> <!ELEMENT comments (#PCDAT A)> <!ELEMENT tutorial (#PCDAT A)> <!ELEMENT reference (#PCDAT A)> <!ELEMENT overall (#PCDAT A)> <h2>Mixed content</h2> Using the rules of grouping and recurr ence to their fullest allows you to create very useful elements that contain mixed content. Elements with mixed content contain child elements Document Type Definitions 25, that can intermingle with PCDATA. The most obvious example of this is a paragraph: <para> This is a <emphasis>paragraph</emphasis> element. It contains this <link ref="">link</link> to the W3C. Their website is <emphasis>very</emphasis> helpful. </para> Mixed content declarations look like this: <!ELEMENT quote (#PCDAT A|name|joke|soundbite)*> This declaration allows a <quote> element to contain text (#PCDATA), <name> elements, <joke> elements, and/or <sound- bite> elements in any order. You can’t specify things such as: <!ELEMENT memo (#PCDAT A, from, #PCDAT A, to, content)> Once you include #PCDATA in a declaration, any following elements must be separated by “or” bars (|), and the grouping must be optional and repeatable (*). <h2>Empty elements</h2> You must also declare each of the empty elements that can be used inside a valid XML document. This can be done with the EMPTY keyword: <!ELEMENT elementname EMPTY> For example, the following declaration defines an element in the XML document that can be used as <statuscode/> or <statuscode></statuscode>: <!ELEMENT statuscode EMPTY> <h2>Entities</h2> Inside a DTD, you can declare an entity, which allows you to use an entity refer ence to substitute a series of characters for another character in an XML document—similar to macros. 26 XML Pocket Reference, <h2>General entities</h2> A general entity is an entity that can substitute other charac- ters inside the XML document. The declaration for a general entity uses the following format: <!ENTITY name "replacement_characters"> We have already seen five general entity refer ences, one for each of the characters <, >, &, ', and ". Each of these can be used inside an XML document to prevent the XML processor fr om interpr eting the characters as markup. (Incidentally, you do not need to declare these in your DTD; they are always pr ovided for you.) Earlier, we provided an entity refer ence for the copyright character. We could declare such an entity in the DTD with the following: <!ENTITY copyright "©"> Again, we have tied the ©right; entity to Unicode value 169 (or hexadecimal 0xA9), which is the “circled-C” (©) copy- right character. You can then use the following in your XML document: <copyright> ©right; 2001 by MyCompany, Inc. </copyright> Ther e areacouple of restrictions to declaring entities: • You cannot make circular refer ences in the declarations. For example, the following is invalid: <!ENTITY entitya "&entityb; is really neat!"> <!ENTITY entityb "&entitya; is also really neat!"> • You cannot substitute nondocument text in a DTD with a general entity refer ence. The general entity refer ence is resolved only in an XML document, not a DTD docu- ment. (If you wish to have an entity refer ence resolved in the DTD, you must instead use a parameter entity refer- ence.) Document Type Definitions 27, <h2>Parameter entities</h2> Parameter entity refer ences appear only in DTDs and are replaced by their entity definitions in the DTD. All parameter entity refer ences begin with a percent sign, which denotes that they cannot be used in an XML document—only in the DTD in which they are defined. Here is how to define a parameter entity: <!ENTITY % name "replacement_characters"> Her e ar e some examples using parameter entity refer ences: <!ENTITY % pcdata "(#PCDAT A)"> <!ELEMENT authortitle %pcdata;> As with general entity refer ences, you cannot make circular refer ences in declarations. In addition, parameter entity refer- ences must be declared before they can be used. <h2>Exter nal entities</h2> XML allows you to declare an exter nal entity with the follow- ing syntax: <!ENTITY quotes SYSTEM ""> This allows you to copy the XML content (located at the spec- ified URI) into the current XML document using an external entity refer ence. For example: <document> <heading>Current Stock Quotes</heading> "es; </document> This example copies the XML content located at the URI http://www.or into the document when it’s run through the XML processor. As you might guess, this works quite well when dealing with dynamic data. 28 XML Pocket Reference, <h2>Unparsed entities</h2> By the same token, you can use an unparsed entity to declare non-XML content in an XML document. For example, if you want to declare an outside image to be used inside an XML document, you can specify the following in the DTD: <!ENTITY image1 SYSTEM "" NDAT A GIF89a> Note that we also specify the NDATA (notation data) keyword, which tells exactly what type of unparsed entity the XML pro- cessor is dealing with. You typically use an unparsed entity refer ence as the value of an element’s attribute, one defined in the DTD with the type ENTITY or ENTITIES. Her e is how you should use the unparsed entity declared previously: <image src="image1"/> Note that we did not use an ampersand (&) or a semicolon (;). These are only used with parsed entities. <h2>Notations</h2> Finally, notations ar e used in conjunction with unparsed enti- ties. A notation declaration simply matches the value of an NDATA keyword (GIF89a in our example) with more specific infor mation. Applications are free to use or ignore this infor- mation as they see fit: <!NOTATION GIF89a SYSTEM "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN"> <h2>Attribute Declarations in the DTD</h2> Attributes for various XML elements must be specified in the DTD. You can specify each of the attributes with the <!ATTLIST> declaration, which uses the following form: <!ATTLIST target_element attr_name attr_type default> Document Type Definitions 29, The <!ATTLIST> declaration consists of the target element name, the name of the attribute, its datatype, and any default value you want to give it. Her e ar e some examples of legal <!ATTLIST> declarations: <!ATTLIST box length CDAT A "0"> <!ATTLIST box width CDAT A "0"> <!ATTLIST frame visible (true|false) "true"> <!ATTLIST person marital (single | married | divorced | widowed) #IMPLIED> In these examples, the first keyword after ATTLIST declar es the name of the target element (i.e., <box>, <frame>, <person>). This is followed by the name of the attribute (i.e., length, width, visible, marital). This, in turn, is generally followed by the datatype of the attribute and its default value. <h2>Attribute modifiers</h2> Let’s look at the default value first. You can specify any default value allowed by the specified datatype. This value must appear as a quoted string. If a default value is not appr opriate, you can specify one of the modifiers listed in the following table in its place: Modifier Description #REQUIRED The attribute value must be specified with the ele- ment. #IMPLIED The attribute value is unspecified, to be determined by the application. #FIXED "value" The attribute value is fixed and cannot be changed by the user. "value" The default value of the attribute. With the #IMPLIED keyword, the value can be omitted from the XML document. The XML parser must notify the applica- tion, which can take whatever action it deems appropriate at 30 XML Pocket Reference, that point. With the #FIXED keyword, you must specify the default value immediately afterwards: <!ATTLIST date year CDAT A #FIXED "2001"> <h2>Datatypes</h2> The following table lists legal datatypes to use in a DTD: Type Descr iption CDATA Character data enumerated A series of values from which only one can be chosen ENTITY An entity declared in the DTD ENTITIES Multiple whitespace-separated entities declared in the <h2>DTD</h2> ID A unique element identifier IDREF The value of a unique ID type attribute IDREFS Multiple whitespace-separated IDREFs of elements NMTOKEN An XML name token NMTOKENS Multiple whitespace-separated XML name tokens NOTATION A notation declared in the DTD The CDATA keyword simply declares that any character data can appear, although it must adhere to the same rules as the PCDATA tag. Here are some examples of attribute declarations that use CDATA: <!ATTLIST person name CDAT A #REQUIRED> <!ATTLIST person email CDAT A #REQUIRED> <!ATTLIST person company CDATA #FIXED "OReilly"> Her e ar e two examples of enumerated datatypes where no keywords are specified. Instead, the possible values are sim- ply listed: <!ATTLIST person marital (single | married | divorced | widowed) #IMPLIED> <!ATTLIST person sex (male | female) #REQUIRED> Document Type Definitions 31, The ID, IDREF, and IDREFS datatypes allow you to define attributes as IDs and ID refer ences. An ID is simply an attribute whose value distinguishes the current element from all others in the current XML document. IDs are useful for applications to link to various sections of a document that contain an ele- ment with a uniquely tagged ID. IDREFs are attributes that ref- er ence other IDs. Consider the following XML document: <?xml version="1.0" standalone="yes"?> <!DOCTYPE sector SYSTEM sector.dtd> <sector> <employee empid="e1013">Jack Russell</employee> <employee empid="e1014">Samuel Tessen</employee> <employee empid="e1015" boss="e1013"> Terri White</employee> <employee empid="e1016" boss="e1014"> Steve McAlister</employee> </sector> and its DTD: <!ELEMENT sector (employee*)> <!ELEMENT employee (#PCDAT A)> <!ATTLIST employee empid ID #REQUIRED> <!ATTLIST employee boss IDREF #IMPLIED> Her e, all employees have their own identification numbers (e1013, e1014, etc.), which we define in the DTD with the ID keyword using the empid attribute. This attribute then forms an ID for each <employee> element; no two <employee> ele- ments can have the same ID. Attributes that only refer ence other elements use the IDREF datatype. In this case, the boss attribute is an IDREF because it uses only the values of other ID attributes as its values. IDs will come into play when we discuss XLink and XPointer. The IDREFS datatype is used if you want the attribute to refer to more than one ID in its value. The IDs must be separated by whitespace. For example, adding this to the DTD: <!ATTLIST employee managers IDREFS #REQUIRED> 32 XML Pocket Reference, allows you to legally use the XML: <employee empid="e1016" boss="e1014" managers="e1014 e1013"> Steve McAllister </employee> The NMTOKEN and NMTOKENS attributes declare XML name tokens. An XML name token is simply a legal XML name that consists of letters, digits, underscores, hyphens, and periods. It can contain a colon if it is part of a namespace. It may not contain whitespace; however, any of the permitted characters for an XML name can be the first character of an XML name token (e.g., .pr ofile is a legal XML name token, but not a legal XML name). These datatypes are useful if you enumerate tokens of languages or other keyword sets that match these restrictions in the DTD. The attribute types ENTITY and ENTITIES allow you to exploit an entity declared in the DTD. This includes unparsed entities. For example, you can link to an image as follows: <!ELEMENT image EMPTY> <!ATTLIST image src ENTITY #REQUIRED> <!ENTITY chapterimage SYSTEM "chapimage.jpg" NDAT A "jpg"> You can use the image as follows: <image src="chapterimage"> The ENTITIES datatype allows multiple whitespace-separated refer ences to entities, much like IDREFS and NMTOKENS allow multiple refer ences to their datatypes. The NOTATION keyword simply expects a notation that appears in the DTD with a <!NOTATION> declaration. Here, the player attribute of the <media> element can be either mpeg or jpeg: <!NOTATION mpeg SYSTEM "mpegplay.exe"> <!NOTATION jpeg SYSTEM "netscape.exe"> <!ATTLIST media player NOTATION (mpeg | jpeg) #REQUIRED> Document Type Definitions 33, Note that you must enumerate each of the notations allowed in the attribute. For example, to dictate the possible values of the player attribute of the <media> element, use the following: <!NOTATION mpeg SYSTEM "mpegplay.exe"> <!NOTATION jpeg SYSTEM "netscape.exe"> <!NOTATION mov SYSTEM "mplayer.exe"> <!NOTATION avi SYSTEM "mplayer.exe"> <!ATTLIST media player NOTATIONS (mpeg | jpeg | mov) #REQUIRED> Note that according the rules of this DTD, the <media> ele- ment is not allowed to play AVI files. The NOTATION keyword is rarely used. Finally, you can place all the ATTLIST entries for an element inside a single ATTLIST declaration, as long as you follow the rules of each datatype: <!ATTLIST person name CDAT A #REQUIRED number IDREF #REQUIRED company CDATA #FIXED "OReilly"> <h2>Included and Ignored Sections</h2> Within a DTD, you can bundle together a group of declara- tions that should be ignored using the IGNORE dir ective: <![IGNORE[ DTD content to be ignored ]]> Conversely, if you wish to ensure that certain declarations are included in your DTD, use the INCLUDE dir ective, which has a similar syntax: <![INCLUDE[ DTD content to be included ]]> Why you would want to use either of these declarations is not obvious until you consider replacing the INCLUDE or IGNORE 34 XML Pocket Reference, dir ectives with a parameter entity refer ence that can be changed easily on the spot. For example, consider the follow- ing DTD: <?xml version="1.0" encoding="iso-8859-1"?> <![%book;[ <!ELEMENT text (chapter+)> ]]> <![%article;[ <!ELEMENT text (section+)> ]]> <!ELEMENT chapter (section+)> <!ELEMENT section (p+)> <!ELEMENT p (#PCDAT A)> Depending on the values of the entities book and article, the definition of the text element will be differ ent: • If book has the value INCLUDE and article has the value IGNORE, then the text element must include chapters (which in turn may contain sections that themselves include paragraphs). • But if book has the value IGNORE and article has the value INCLUDE, then the text element must include sections. When writing an XML document based on this DTD, you may write either a book or an article simply by properly defining book and article entities in the document’s inter nal subset. <h2>Inter nal subsets</h2> You can place parts of your DTD declarations inside the DOCTYPE declaration of the XML document, as shown: <!DOCTYPE boilerplate SYSTEM "generic-inc.dtd" [ <!ENTITY corpname "Acme, Inc."> ]> The region between brackets is called the DTD’s internal sub- set. When a parser reads the DTD, the internal subset is read first, followed by the exter nal subset, which is the file refer- enced by the DOCTYPE declaration. Document Type Definitions 35, Ther e ar e restrictions on the complexity of the internal subset, as well as processing expectations that affect how you should structur e it: • Conditional sections (such as INCLUDE or IGNORE) are not per mitted in an internal subset. • Any parameter entity refer ence in the internal subset must expand to zero or mor e declarations. For example, specifying the following parameter entity refer ence is legal: %paradecl; as long as %paradecl; expands to the following: <!ELEMENT para CDAT A> However, if you simply write the following in the internal subset, it is considered illegal because it does not expand to a whole declaration: <!ELEMENT para (%paracont;)> Nonvalidating parsers aren’t requir ed to read the external sub- set and process its contents, but they are requir ed to process any defaults and entity declarations in the internal subset. However, a parameter entity can change the meaning of those declarations in an unresolvable way. Therefor e, a parser must stop processing the internal subset when it comes to the first exter nal parameter entity refer ence that it does not process. If it’s an internal refer ence, it can expand it, and if it chooses to fetch the entity, it can continue processing. If it does not pro- cess the entity’s replacement, it must not process the attribute list or entity declarations in the internal subset. Why use this? Since some entity declarations are often rele- vant only to a single document (for example, declarations of chapter entities or other content files), the internal subset is a good place to put them. Similarly, if a particular document needs to override or alter the DTD values it uses, you can place a new definition in the internal subset. Finally, in the event that an XML processor is nonvalidating (as we 36 XML Pocket Reference, mentioned previously), the internal subset is the best place to put certain DTD-related information, such as the identification of ID and IDREF attributes, attribute defaults, and entity decla- rations. <h2>The Extensible Stylesheet Language</h2> The Extensible Stylesheet Language (XSL) is one of the most intricate specifications in the XML family. XSL can be broken into two parts: XSLT, which is used for transformations, and XSL Formatting Objects (XSL-FO). While XSLT is curr ently in widespr ead use, XSL-FO is still maturing; both, however, pr omise to be useful for any XML developer. This section will provide you with a firm understanding of how XSL is meant to be used. For the very latest information on XSL, visit the home page for the W3C XSL working group at http://www.w3.or g/Style/XSL /. As we mentioned, XSL works by applying element-formatting rules that you define for each XML document it encounters. In reality, XSL simply transforms each XML document from one series of element types to another. For example, XSL can be used to apply HTML formatting to an XML document, which would transform it from: <?xml version="1.0"?> <OReilly:Book title="XML Comments"> <OReilly:Chapter title="Working with XML"> <OReilly:Image src=""/> <OReilly:HeadA>Starting XML</OReilly:HeadA> <OReilly:Body> If you havent used XML, then ... </OReilly:Body> </OReilly:Chapter> </OReilly:Book> to the following HTML: <HTML> <HEAD> <TITLE>XML Comments The Extensible Stylesheet Language 37,

Working with XML

Starting XML

If you havent used XML, then ...

If you look carefully, you can see a predefined hierarchy that remains from the source content to the resulting content. To ventureaguess, the element probably maps to the , , , and <BODY> elements in HTML. The <OReilly:Chapter> element maps to the HTML <H1> element, the <OReilly:Image> element maps to the <img> ele- ment, and so on. This demonstrates an essential aspect of XML: each document contains a hierarchy of elements that can be organized in a tr ee-like fashion. (If the document uses a DTD, that hierarchy is well defined.) In the previous XML example, the <OReilly:Chapter> element is a leaf of the <OReilly:Book> ele- ment, while in the HTML document, the <BODY> and <HEAD> elements are leaves of the <HTML> element. XSL’s primary purpose is to apply formatting rules to a sour ce tr ee, render- ing its results to a result tree, as we’ve just done. However, unlike other stylesheet languages such as CSS, XSL makes it possible to transform the structure of the document. XSLT applies transformation rules to the document source and by changing the tree structure, produces a new document. It can also amalgamate several documents into one or even pro- duce several documents starting from the same XML file. <h2>Formatting Objects</h2> One area of the XSL specification that is gaining steam is the idea of for matting objects. These objects serve as universal for matting tags that can be applied to virtually any arena, including both video and print. However, this (rather large) ar ea of the specification is still in its infancy, so we will not 38 XML Pocket Reference, discuss it further in this refer ence. For more infor mation on formatting objects, see http://www.w3.or g/TR/XSL /. The remainder of this section discusses XSL Transfor mations. <h2>XSLT Stylesheet Structure</h2> The general order for elements in an XSL stylesheet is as follows: <xsl:stylesheet version="1.0" xmlns:xsl=""> <xsl:import/> <xsl:include/> <xsl:strip-space/> <xsl:preserve-space/> <xsl:output/> <xsl:key/> <xsl:decimal-format/> <xsl:namespace-alias/> <xsl:attribute-set>...</xsl:attribute-set> <xsl:variable>...</xsl:variable> <xsl:param>...</xsl:param> <xsl:template match="..."> ... </xsl:template> <xsl:template name="..."> ... </xsl:template> </xsl:stylesheet> Essentially, this ordering boils down to a few simple rules. First, all XSL stylesheets must be well-formed XML documents, and each <XSL> element must use the namespace specified by the xmlns declaration in the <stylesheet> element (commonly xsl:). Second, all XSL stylesheets must begin with the XSL root element tag, <xsl:stylesheet>, and close with the corresponding tag, </xsl:stylesheet>. Within the opening tag, the XSL names- pace must be defined: XSLT Stylesheet Structure 39, <xsl:stylesheet version="1.0" xmlns:xsl=""> After the root element, you can import external stylesheets with <xsl:import> elements, which must always be first within the <xsl:stylesheet> element. Any other elements can then be used in any order and in multiple occurrences if needed. <h2>Templates and Patter ns</h2> An XSLT stylesheet transforms an XML document by applying templates for a given type of node. A template element looks like this: <xsl:template match="pattern"> ... </xsl:template> wher e patter n selects the type of node to be processed. For example, say you want to write a template to transform a <para> node (for paragraph) into HTML. This template will be applied to all <para> elements. The tag at the beginning of the template will be: <xsl:template match="para"> The body of the template often contains a mix of “template instructions” and text that should appear literally in the result, although neither are requir ed. In the previous example, we want to wrap the contents of the <para> element in <p> and </p> HTML tags. Thus, the template would look like this: <xsl:template match="para"> <p><xsl:apply-templates/></p> </xsl:template> The <xsl:apply-templates/> element recursively applies all other templates from the stylesheet against the <para> element (the curr ent node) while this template is processing. Every stylesheet has at least two templates that apply by default. 40 XML Pocket Reference, <h2>The first default template processes text and attribute nodes</h2> and writes them literally in the document. The second default template is applied to elements and root nodes that have no associated namespace. In this case, no output is generated, but templates are applied recursively from the node in ques- tion. <h2>Now that we have seen the principle of templates, we can</h2> look at a more complete example. Consider the following <h2>XML document:</h2> <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE text SYSTEM "example.dtd"> <chapter> <title>Sample text
This is the first section of the text.
This is the second section of the text.

To transfor m this into HTML, we use the following template:

<xsl:value-of select="title"/>

Templates and Patter ns 41


Let’s look at how this stylesheet works. As processing begins, the current node is the document root (not to be confused with the element, which is its only descendant), des- ignated as / (like the root directory in a Unix filesystem). The XSLT processor searches the stylesheet for a template with a matching pattern in any children of the root. Only the first template matches (). The first tem- plate is then applied to the node, which becomes the current node. The transformation then takes place: the , , , and <body> elements are simply copied into the docu- ment because they are not XSL instructions. Between the tags <head> and </head>, the <xsl:value-of select="title"/> element copies the contents of the <title> element into the document. Finally, the <xsl:apply-templates/> element tells the XSL proces- sor to apply the templates recursively and insert the result between the <body> and </body> tags. This time through, the title and section templates are applied because their patterns match. The title template inserts the contents of the <title> element between the HTML <center> and <h1> tags, thus displaying the document title. The section tem- plate works by using the <xsl:value-of select="@title"> element to recopy the contents of the current element’s title attribute into 42 XML Pocket Reference, the document produced. We can indicate in a pattern that we want to copy the value of an attribute by placing the at sym- bol (@) in front of its name. The process continues recursively to produce the following HTML document: <html> <head> <title>Sample text

Sample text

First section

This is the first section of the text.

Second section

This is the second section of the text.

As you will see later, patter ns ar e XPath expressions for locat- ing nodes in an XML document. This example includes very basic patterns, and we have only scratched the surface of what can be done with templates. More infor mation will be found in the section “XPath.” In addition, the element has a mode attribute that can be used for conditional processing. An template is tested only when it is called by an element that matches its mode. This functionality can be used to change the processing applied to a node dynamically.

Parameters and Variables

To finish up with templates, we should discuss the name attribute. These templates are similar to functions and can be called explicitly with the ele- ment, where name matches the name of the template you want to invoke. When you call a template, you can pass it Templates and Patter ns 43, parameters. Let’s assume we wrote a template to add a footer containing the date the document was last updated. We could call the template, passing it the date of the last update this way: The call-template declar es and uses the parameter this way: today
Last update:
The parameter is declared within the template with the element whose content (today) pro- vides a default value. We can use this parameter inside the template by placing a dollar sign ($) in front of the name. We can also declare variables using the element, where the content of the element gives the variable its value. The variables are used like parameters by placing a dollar sign ($) in front of their names. Note that even though they are called variables, their values are con- stant and cannot be changed. A variable’s visibility also depends on where it is declar ed. A variable that is declared dir ectly as a child element of can be used thr oughout the stylesheet as a global variable. Conversely, when a variable is declared in the body of the template, it is visible only within that same template.

Stylesheet Import and Rules of Precedence

Stylesheets may be imported using the element, where the hr ef attribute indicates the path of the stylesheet to be imported. Note that an statement must be a direct child of the element. 44 XML Pocket Reference, Imported stylesheet templates have lower precedence than templates contained in the file into which they are incorpo- rated. This means that if two templates compete for the pro- cessing of an element, the template of the original file takes pr ecedence over the template of the imported file. Thus, imported templates can be overridden by redefining them in the original stylesheet. The rules of precedence can be changed in two ways: • The element can be used to give imported templates precedence in the body of a tem- plate. • The priority="level" attribute can be given in the opening tag. Therefor e, the level of precedence defined for the template is a real number. The larger the number, the more precedence the template has. A value of +1 ensures that the template has precedence over other templates for which no precedence has been defined (0 is the default). A value of –1 guarantees that any other unprioritized template has precedence. Priority values overrule import precedence. Stylesheets can also be included in an XSL file with the element. The precedence of an included template is the same as that of the calling stylesheet templates.

Loops and Tests

To process an entire list of elements at the same time, use the loop. For example, the following template adds a table of contents to our example:
Templates and Patter ns 45, The body of this loop processes all the elements that are childr en of the current node. Within the loop, we output the value of each section’s title attribute, followed by a line break. XSL also defines elements that can be used for tests: The body of this element is executed only if the test expr ession is true. This element allows for several possible conditions. It is comparable to switch in the C and Java languages. The element is illustrated as follows: The body of the first element whose test expr ession is true will be executed. The XSL processor then moves on to the instructions following the closing element tag, skipping the remaining tests. The element is optional; its body is exe- cuted only if none of the preceding elements were exe- cuted.

Numbering Elements

XSL provides a simple method for numbering elements with the element. Let’s assume we want to number the sections and paragraphs in a document. We can do this by 46 XML Pocket Reference, adding the following code before displaying the section titles and the content of the paragraphs: - The result is: 1 - First section 1.1 - This is the first section of text. 2 - Second section 2.1 - This is the second section of text. The count attribute decides which elements should be num- ber ed. Elements must be separated by a |. The level attribute specifies the level of numbering and may take one of three string values: single, multiple, or any. single tells the processor to number only one level. In this case, paragraph numbers will not indicate the section number. multiple numbers several levels, meaning that the first part of the paragraph number is the section number in our previous example. any tells the pro- cessor to add numbering without regard to level. Here, the numbers of the sections and paragraphs are consecutive. The format attribute indicates the style of numbering. Letters or numbers may be used, with a separator in between. The letters may be A or a (for alphabetical numbering in upper- or lowercase), I or i (for numbering in upper- or lowercase Roman numerals), or 1 (for numbering in Arabic numerals). For example, to number sections with Roman numerals and paragraphs with lowercase letters, use this format attribute: format="I.a"

Output Method

An XSLT processor can be instructed to produce a specific type of output with the element. For example, causes the processor to execute certain transformations needed for the resulting document to Templates and Patter ns 47, be valid HTML. Specifically, it transforms empty tags. For example, the XML
tag is converted to the HTML
tag (for horizontal rules) without a closing slash. It is also possible to indicate an XML output method (method="xml"), where the XSLT processor adds the standard XML header (). It may seem strange to pro- duce an XML document from another XML document, yet it is often helpful to convert a document from one DTD to a valid document for another DTD. Thus, XSLT is also a language for inter-DTD conversions. Finally, you can specify a text output method (method="text") to produce pure text. XSLT has built-in outputs for XML, HTML, and text, but some processors may support other out- put methods (sometimes identified by URLs). We should point out that when you choose the HTML or XML output method, the processor may remove or rearrange whitespace in blocks of text (spaces, tabs, and carriage retur ns). However, ther e ar e several solutions for preserving whitespace. The first is to indicate the list of elements to be pr eserved in the element. The second is to add the indent="no" attribute to the element to indicate that you do not want the resulting document to be indented. We should point out, however, that spaces are no longer preserved in elements where content is written as-is in the resulting document. No indent- ing is produced for the text output method.

XSLT Elements

The following list is an enumeration of XSLT elements. 48 XML Pocket Reference, This styles the current node and each of its children using the imported stylesheet rules, ignoring those in the stylesheet that per formed the import. Note that the rules don’t apply to the curr ent node’s siblings or ancestors. This specifies that the immediate children (default) or the selected nodes of the source element should be processed further. For example: This example processes the children of the selected
element after applying a bold tag. The optional select attribute deter mines which nodes should be processed:

This example processes only specific children of the selected
element. In this case, the first target is a element that is a descendant of a element that has defined an indent attribute. The second target is a ele- ment that is the direct child of a element that has defined an indent attribute. The optional mode attribute causes only templates with a matching mode to be applied. 49, ... This adds an attribute with the given name to an element in the result tree. Only one attribute with a particular name can be added to a specific element. The contents of the element form the value of the attribute: Moby Dick This is about a whale This creates the following element in the result tree: This is about a whale The optional namespace attribute specifies a namespace for the new attribute. This allows the naming of a collection of attributes that can be applied to elements. The following example creates an attribute set for images and applies them with a template: 0 120 60 50 XML Pocket Reference,

The use-attribute-sets option allows you to include a list of

other attribute sets in the one being defined. ...

This function invokes a template by its name. It is possible to

specify parameters in the body of this element. The following example calls the template image while passing the parameters width and height: 120 60 ...

The element, in conjunction with the elements

and , offers the ability to perfor m multiple condition tests. For example: Start Here: Then Read: 51, This example matches against each of the qualifying elements, but it must test each <title> element to determine how to format it. Here, formatting depends on whether the element is first. The string Start Here: is applied before the first <title> element, and the string Then Read: is placed before the others. <xsl:comment> <xsl:comment> ... </xsl:comment> This inserts a comment into the XML document. For example: <xsl:comment>English material below</xsl:comment> is translated into a comment in the XML result tree when it is pr ocessed: <!- English material below -> <xsl:copy> <xsl:copy [use-attribute-sets="list"]> ... </xsl:copy> This element copies the current node from the source docu- ment into the output document. This copies the node itself, as well as any namespace nodes the node possesses. However, it does not copy the node’s content or attributes. The use-attribute-sets attribute contains a whitespace- sepa- rated list with names of <xsl:attribute-set> elements. These attribute sets are merged, and all attributes in the merged set ar e added to the copied element. The use-attribute-sets attribute can only be used when the node copied is an element node. 52 XML Pocket Reference, <xsl:copy-of> <xsl:copy-of select="expression"/> The <xsl:copy-of> instruction inserts the result tree fragment identified by the select attribute into the output document. This copies not only the specific node or nodes identified by the expression, but also all those nodes’ children, attributes, namespaces, and descendants. (This is how it differs from xsl:copy.) If the expression selects something other than a node set or a result tree fragment (e.g., a number), then the expr ession is converted to its string value, and the string is output. <xsl:decimal-for mat> <xsl:decimal-format [name ="name"] [decimal-separator = "char"] [grouping-separator = "char"] [infinity = "string"] [minus-sign = "char"] [NaN = "string"] [percent = "char"] [per-mille = "char"] [zero-digit = "char"] [digit = "char"] [pattern-separator = "char"]/> The <xsl:decimal-for mat> element defines a pattern by which the XPath for mat-number() function can convert floating-point numbers into text strings. The attributes are specified as follows: name The string by which the for mat-number() function identifies which <xsl:decimal-for mat> element to use. If this attribute is omitted, then the element establishes the default deci- mal format used by the for mat-number() function. <xsl:decimal-for mat> 53, decimal-separator The character that separates the integer part from the fractional part in a floating-point number. This is a period (decimal point) in English and a comma in French. It may be something else again in other languages. gr ouping-separator The character that separates groups of digits (e.g., the comma that separates every three digits in English). infinity The string that repr esents IEEE 754 infinity; Infinity by default. minus-sign The character prefixed to negative numbers; a hyphen by default. NaN The string that repr esents IEEE 754 Not a Number; NaN by default. per cent The character that repr esents a percent; % by default. per-mille The character that repr esents a per mille; #x2030 by default. zer o-digit The character that repr esents zer o in a format pattern; 0 by default. digit The character that repr esents a digit in a format pattern; # by default. patter n-separator The character that separates positive and negative sub- patter ns in a format pattern; a semicolon (;) by default. 54 XML Pocket Reference, <xsl:element> <xsl:element name="name" [namespace="URI"] [use-attribute-sets="list"]> ... </xsl:element> This inserts the element <name> into the result document. For example: <xsl:element name="book"> <xsl:element name="chapter"> <xsl:text>The Opening of Pandoras Box</xsl:text> </xsl:element> </xsl:element> This creates the following in the result tree: <book> <chapter>The Opening of Pandoras Box</chapter> </book> Elements without explicit namespaces use the default name- space of their current context. Also, you can create a name- space for the element yourself: <xsl:element name="OReilly:Book" namespace=""> This employs the namespace associated with the URI http://www.or with the element. If no namespaces are associated with the URI, it becomes the default namespace. The use-attribute-sets attribute contains a whitespace- sepa- rated list with names of <xsl:attribute-set> elements. These attribute sets are merged, and all attributes in the merged set ar e added to the element. <xsl:element> 55, <xsl:fallback> <xsl:fallback> ... </xsl:fallback> This element is used in conjunction with extension elements that aren’t a part of XSLT 1.0. <xsl:fallback> defines a template to be invoked if the enclosing element is undefined. It’s possible to test the availability of an element with element- available(). <xsl:for-each> <xsl:for-each select="node-set-expression"/> The <xsl:for-each> dir ective allows you to select any number of nodes in an XML document that match the same expression given by select. For example, consider the following XML doc- ument: <book> <chapter> <title>A Mystery Unfolds It was a dark and stormy night... A Sudden Visit Marcus found himself sleeping... Note there are two siblings in the document. Let’s assume we want to provide an HTML numbered list for each element that is the direct child of a <chapter> element, which in turn has a <book> element as a parent. The following template perfor ms the task: 56 XML Pocket Reference, <xsl:template match="book> <ol> <xsl:for-each select="chapter"> <li><xsl:process select="title"></li> </xsl:for-each> </ol> </xsl:template> After formatting, here is what the result looks like: <ol> <li>A Mystery Unfolds</li> <li>A Sudden Visit</li> </ol> The XSLT processor processes a <title> element in each <chap- ter> element that is the child of a <book> element. The result is a number ed list of chapters that could be used for a table of contents. <xsl:if> <xsl:if test="expression"> ... </xsl:if> You can use the <xsl:if> conditional to select a specific ele- ment while inside a template. The <xsl:if> element uses the test attribute to determine whether to include the contents of an element. The test attribute takes an expression that tests for a specific element or attribute. For example: <xsl:template match="chapter/title"> <xsl:apply-templates/> <xsl:if test="not([last()])">, </xsl:if> </xsl:template> This template matches each qualifying <title> element but inserts commas only after those that are not the last <title> ele- ment. The result is a standard comma-separated list. <xsl:if> 57, <xsl:impor t> <xsl:import href="address"/> This specifies the URI of an XSL stylesheet whose rules should be imported into this stylesheet. The import statement must occur before any other elements in the stylesheet. If a conflict arises between matching rules, rules in the XSL stylesheet per- for ming the import take precedence over rules in the imported stylesheet. In addition, if more than one stylesheet is imported into this document, the most recently imported stylesheet takes precedence over stylesheets imported before it: <xsl:import href="webpage.xsl"/> This example imports the stylesheet found in the webpage.xsl file. <xsl:include> <xsl:include href="address"/> This specifies the name of an XSL stylesheet that is to be included in the document. The include pr ocessing will replace the <xsl:include> statement with the contents of the file. Because the included document has been inserted in the referring stylesheet, any included rules have the same prefer- ence as those in the referring stylesheet (compare to <xsl:import>): <xsl:include href="chapterFormats.xsl"/> <xsl:key> <xsl:key name="name" match="pattern" use="expression"/> 58 XML Pocket Reference, Keys are comparable to identifiers in XML. This element is used in <xsl:stylesheet> to create a refer ence to elements speci- fied by the pattern and expression values. For example: <xsl:key name="chap" match="chapter" use="@title"/> This element creates a key named chap to identify chapters by title. You can then refer ence a chapter with an XPath function such as: key("chap", "The XSL Language") <xsl:message> <xsl:message [terminate="yes|no"]> ... </xsl:message> The <xsl:message> instruction asks the XSLT processor to send a message to the user or calling program. Exactly what it does with those messages depends on the processor. One common use of <xsl:message> is to print debugging information. If the ter minate attribute is present and has the value yes, then the XSLT processor should halt after the message has been deliver ed and acted on. <xsl:namespace-alias> <xsl:namespace-alias stylesheet-prefix="prefix1" result-prefix="prefix2"/> The <xsl:namespace-alias> element declares that one name- space URI ( pr efix1) in the stylesheet should be replaced by a dif ferent namespace URI ( pr efix2) in the result tree. Either attribute value can be set to #default to indicate that the non- pr efixed default namespace is to be used. <xsl:namespace-alias> 59, <xsl:number> <xsl:number [value = "expression"] [count = "pattern"] [from = "pattern"] [level = "single|multiple|any"] [format = "letter/digit"] [lang = "langcode"] [letter-value = "alphabetic|traditional"] [grouping-separator = "char"] [grouping-size = "number"] /> This element inserts a formatted integer into the result tree. The value of this number can be determined by the attributes or generated by the XSLT processor. The attributes are described as follows: value This attribute contains an XPath expression retur ning the number to be formatted. If necessary, the number is rounded to the nearest integer. Most commonly, the value attribute is omitted, in which case the number is calcu- lated from the position of the current node in the source document. The position is calculated as specified by the level, count, and fr om attributes. count This attribute contains a pattern that specifies which nodes should be counted at those levels. The default is to count all nodes of the same node type (element, text, attribute, etc.) and name as the current node. fr om This attribute contains a pattern identifying the node from which counting starts; that is, it says which node is number 1. level This attribute can be set to single (all preceding siblings of the ancestor of the current node that match the count pat- 60 XML Pocket Reference, ter n), multiple (for nested counting of each type of ances- tor of the current node that match the count patter n), or any (count all nodes in the document that match the count patter n and precede the current node). The default is sin- gle. for mat This attribute determines how the list will be numbered. For mat tokens include: • 1, 2, 3, 4, 5, 6 • 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12 • A, B, C, D .Z, AA, AB, AC .• a, b, c, d .z, aa, ab, ac .• i, ii, iii, iv, v, vi, vii, viii, ix, x, xi .• I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII .You can change the starting point as well. For instance, setting the format token to 5 would create the sequence 5, 6, 7, 8, 9. lang This contains the RFC 1766 language code describing the language in which the number should be formatted (e.g., en or fr). letter-value The default is traditional. However, you can set this to alphabetic to indicate that a format of I should start the sequence I, J, K, L, M, N rather than I, II, III, IV, V, VI. gr ouping-separator This specifies the character that separates groups of dig- its. For instance, in English this is customarily the comma that separates every three digits, as in 2,987,667,342. In Fr ench a space is used instead so this number would be written as 2 987 667 342. <xsl:number> 61, gr ouping-size This specifies the number of digits in each group. In most languages, including English, digits are divided into gr oups of three. However, a few languages use groups of four instead. <xsl:otherwise> <xsl:otherwise>...</xsl:otherwise> This attribute specifies the default case in an <xsl:choose> ele- ment. See the “<xsl:choose>” entry earlier in this refere nce section. <xsl:output> <xsl:output [method = "xml|html|text"] [version = "nmtoken"] [encoding = "encoding_name"] [omit-xml-declaration = "yes|no"] [standalone = "yes|no"] [doctype-public = "public_id"] [doctype-system = "system_id"] [cdata-section-elements = "element1 element2 ..."] [indent = "yes|no"] [media-type = "string"]/> The <xsl:output> element helps determine the exact formatting of the XML document produced when the result tree is stored in a file, written onto a stream, or otherwise serialized into a sequence of bytes. It has no effect on the production of the result tree itself. The following attributes are defined: method The default method is xml, which simply implies that the serialized output document will be a well-formed parsed entity or XML document. If method is set to html, or if the method attribute is not present and the root element of the output tree is <html>, then empty element tags such as <br/> ar e converted to <br> when output, and a variety of other changes are to attempt to generate HTML that is 62 XML Pocket Reference, mor e compatible with existing browsers. The text method only outputs the contents of the text nodes in the output tr ee. It strips all markup. XSLT processors are also allowed to recognize and support other values such as TeX or RTF. version This contains a name token that identifies the version of the output method. In practice, this has no effect on the output. encoding This contains the name of the encoding the outputter should use, such as ISO-8859-1 or UTF-16. omit-xml-declaration If this has the value yes, then no XML declaration is included. If it has the value no or is not present, then an XML declaration is included. standalone This sets the value of the standalone attribute in the XML declaration. Like that attribute, it must have the value yes or no. doctype-public This specifies the public identifier used in the document type declaration. doctype-system This specifies the system identifier used in the document type declaration. cdata-section-elements This is a whitespace-separated list of the qualified ele- ment names in the result tree whose contents should be emitted using a CDATA section rather than a character refer ence. indent If this has the value yes, the processor is allowed (but not requir ed) to insert extra whitespace to attempt to “pretty- print” the output tree. The default is no. <xsl:output> 63, media-type This specifies the MIME media type of the output, such as text/html or text/xml. <xsl:param> <xsl:param name="name" [select="expression"]> ... </xsl:param> An <xsl:param> element binds its contents to the specified name, which can be called from and included in a template. As a top-level element, <xsl:param> pr ovides a default value used if the named parameter is not supplied when a stylesheet is called. An <xsl:param> element may also appear inside an <xsl:template> element to receive the values of the parameters passed in with <xsl:with-param>, and to provide a default value good only inside that template for the case whereaproper <xsl:with-param> element is not used. If the select attribute is included, its value becomes the default value of the parameter, in which case the value of the content should be empty. <xsl:preser ve-space> <xsl:preserve-space elements="element1 element2 ..."/> This declares one or more XML elements in which all white- space located between the opening and closing tags is pre- served; hence, the XML processor will not remove it. By default, whitespace is not removed from elements; <xsl: pre- serve-space> can override any elements declared in the <xsl:strip-space> dir ective: <xsl:preserve-space elements="title"/> 64 XML Pocket Reference, <xsl:processing-instr uction> <xsl:processing-instruction name="name"> ... <xsl:processing-instruction> The <xsl:pr ocessing-instruction> element inserts a processing instruction into the result tree. This element cannot be used to generate an XML declaration; use <xsl:output> for that. The name attribute specifies the target of the processing instruc- tion. <xsl:sor t> <xsl:sort select = "expression" [data-type = "text|number"] [lang = "langcode"] [order = "ascending|descending"] [case-order = "upper-first|lower-first"]/> The <xsl:sort> instruction appears as a child of either <xsl:apply- templates> or <xsl:for-each>. It changes the order of the context node list from document order to some other order, such as alphabetic. Multiple-key sorts (for example, sort by last name, then by first name, then by middle name) can be perfor med with multiple <xsl:sort> elements in descending order of importance of the keys. The following attributes are defined: select This contains the key to sort by. data-type By default, sorting is purely alphabetic. However, alpha- betic sorting leads to strange results with numbers. For instance, 10, 100, and 1000 all sort before 2, 3, and 4. You can specify numeric sorting by setting the data-type attribute to number. <xsl:sor t> 65, lang Sorting is language dependent. The language can be adjusted by setting the lang attribute to an RFC 1766 lan- guage code. The default language is system dependent. or der This specifies the order by which strings are sorted. The value can be either descending or ascending. The default is ascending. case-or der The case-order attribute can be set to upper-first or lower- first to specify whether uppercase letters sort before low- ercase letters or vice versa. The default depends on the language. <xsl:strip-space> <xsl:strip-space elements="element1 element2 ..."/> This declares an XML element or list of elements in which all whitespace located between the opening and closing tags is insignificant and should be removed by the XSL processor: <xsl:strip-space elements="title"/> Note that this is not necessarily the same as the xml:space="default" attribute, which allows the XSL processor mor e fr eedom to decide how to handle whitespace. <xsl:stylesheet> <xsl:stylesheet version = "number" xmlns:xsl="" [id = "id"] [extension-element-prefixes = "prefix1 prefix2..."] [exclude-result-prefixes = "prefixa prefixb..."]> ... </xsl:stylesheet> 66 XML Pocket Reference, The <xsl:stylesheet> element is the root element for XSLT stylesheets. The contents of this element must first contain any <xsl:import> elements, followed by any other top-level ele- ments in any order. <xsl:stylesheet> uses the following attributes: version The version number of XSLT used by the stylesheet. xmlns:xsl This attribute contains a standard namespace declaration that maps the prefix xsl to the namespace URI http://www.w3.or g/1999/XSL/T ransform. The prefix can be changed if necessary. This attribute is technically optional, but de facto requir ed. id Any XML name that’s unique within the stylesheet and is of type ID. extension-element-pr efixes A whitespace-separated list of namespace prefixes used by extension elements in this document. exclude-r esult-pr efixes A whitespace-separated list of namespace prefixes whose declarations should not be copied into the output docu- ment. If a namespace is needed in the output, it will be copied regardless. <xsl:template> <xsl:template [match = "pattern"] [priority = "number"] [name = "name"] [mode = "mode"]> ... </xsl:template> The <xsl:template> top-level element is the key to all of XSLT. The match attribute contains a pattern against which nodes are compar ed as they’re processed. If the pattern is the best <xsl:template> 67, match for a node, then the contents are instantiated and inserted into the output tree. This element uses the following attributes: match A patter n against which nodes can be compared. This patter n is a location path that uses the abbreviated XPath syntax. Only the child and attribute axes may be used. The // separator may also be used. priority A number. In the event that more than one template matches a given node, the one that most specifically matches the node is chosen. If several templates match a node with the same level of specificity, then the template with the highest value of the priority attribute is instanti- ated. If several matching templates have equal priorities, then the last one in the stylesheet is chosen (the proces- sor may also throw an error in this situation). name A name by which this template can be invoked from an <xsl:call-template> element rather than by node matching. mode The template’s mode. If the <xsl:template> element has a mode, then this template is only matched when the mode attribute of the calling instruction matches the value of this mode attribute. <xsl:text> <xsl:text> [disable-output-escaping="yes|no"]> ... </xsl:text> This inserts text verbatim into the document. For example: <xsl:text>The price is $20.00.</xsl:text> 68 XML Pocket Reference, is inserted into the XML document as: The price is $20.00. XML special characters (such as & and <) included in the con- tent of this element are escaped (i.e., replaced by character entities) in the output by default. The attribute disable-output- escaping can be set to yes to disable this behavior. <xsl:value-of> <xsl:value-of select="expression"> [disable-output-escaping="yes|no"]/> This extracts a specific value from a source tree. The select attribute is a single pattern-matching expression that resolves to the value of a string, an element, or an attribute: <xsl:template match="index"> This index is <xsl:value-of select="@(type)"> <xsl:apply-templates/> </xsl:template> The select attribute extracts the value of an element or attribute in the source tree and prints it verbatim in the result tr ee. XML special characters (such as & and <) included in the content of this element are escaped (i.e., replaced by charac- ter entities) in the output by default. The attribute disable-out- put-escaping can be set to yes to disable this behavior. <xsl:variable> <xsl:variable name="name" [select="expression"]> ... </xsl:variable> The top-level <xsl:variable> element binds a name to a value of any type (string, number, node set, etc.). The value can then be derefer enced elsewher e in the stylesheet using the form $name in attribute value templates. Once a variable name has been assigned a value, it cannot change. The select attribute is <xsl:variable> 69, an optional expression that sets the value of the variable. If <xsl:variable> has a select attribute, then it must be an empty element. <xsl:when> <xsl:when test="expression"> ... </xsl:when> This is a conditional for testing in an <xsl:choose> element. See the “<xsl:choose>” entry earlier in this refer ence section. <xsl:with-param> <xsl:with-param name="name" [select="expression"]> ... </xsl:with-param> The <xsl:with-param> element passes a named parameter to a template that expects it. It can be a child either of <xsl:apply- templates> or <xsl:call-template>. The parameter is received in the <xsl:template> by an <xsl:param> element with the same name. If a template expects to receive a particular parameter and doesn’t get it, then it can take the default from the value of the <xsl:param> element instead. <h2>XPath</h2> XPath is a recommendation of the World Wide Web Consor- tium (W3C) for locating nodes in an XML document tree. XPath is not designed to be used alone but in conjunction with other tools, such as XSLT or XPointer. These tools use XPath intensively and extend it for their own needs through new functions and new basic types. 70 XML Pocket Reference, XPath provides a syntax for locating a node in an XML docu- ment. It takes its inspiration from the syntax used to denote paths in filesystems such as Unix. This node, often called the context node, depends on the context of the XPath expres- sion. For example, the context of an XSLT expr ession found in an <xsl:template match="para"> template will be the selected <para> element (recall that XSLT templates use XPath expres- sions). This node can be compared to a Unix shell’s current dir ectory. Given our earlier XML examples, it is possible to write the fol- lowing expressions: chapter Selects the <chapter> element descendants of the context node chapter/para Selects the <para> element descendants of the <chapter> element children of the context node ../chapter Selects the <chapter> element descendants of the parent of the context node ./chapter Selects the <chapter> element descendants of the context node * Selects all element children of the context node */para Selects the <para> grandchildr en of the context node .//para Selects the <para> element descendants (children, chil- dr en of children, etc.) of the context node /para Selects the <para> element children of the document root element XPath 71, In addition, XPath recognizes the at symbol (@) for selecting an attribute instead of an element. Thus the following expres- sions can be used to select an attribute: para/@id Selects the id attribute of the <para> element descendants of the context node @* Selects all the attributes in the context node Paths can be combined using the | operator. For example, intr o | chapter selects the <intr o> and <chapter> elements of the childr en of the context node. Certain functions can also be included in the path. The func- tions must returnanode or set of nodes. The functions avail- able are: Function Selection node( ) Any node (of any type) text( ) Text node comment( ) Comment node processing-instr uction( ) Pr ocessing-instruction node id(id) Node whose unique identifier is id The id() function is especially helpful for locating a node by its unique identifier (recall that identifiers are attributes defined by the DTD). For example, we can write the expres- sion id("xml-r ef")/title to select the <title> element whose parent has the xml-r ef identifier. The preceding examples show that the analogy with file paths is rather limited. However, this syntax for writing an XPath expr ession is a simplification of the more complete XPath syn- tax where an axis precedes each step in the path. 72 XML Pocket Reference, <h2>Axes</h2> Axes indicate the direction taken by the path. In the previous examples, the syntactic qualifiers such as / for root, .. for par- ent, and // for descendant, are abbr eviations that indicate the axis of the node search. These are some of the simple axes on which to search for a node. XPath defines other search axes that are indicated by a prefix separated from the rest of the XPath expression (called loca- tion-steps) by a double colon. For example, to indicate that we requireapara node to be the parent of the context node in the document, we could write the expression pr eced- ing::para. XPath defines 13 axes: Axis Selection self The context node itself (abbre viated as .) child The children of the context node (by default) descendant The descendants of the context node; a descendant is a child, or a child of a child, and so on descendant-or-self Same as the descendant, but also contains the context node (abbreviated as //) parent The parent of the context node (abbreviated as ..) ancestor The ancestors of the context node ancestor-or-self The same nodes as the ancestor, plus the con- text node following-sibling Siblings (having the same parent as the context node) in the same document that are after the context node preceding-sibling Siblings in the same document that are befor e the context node following All nodes in the same document that are after the context node preceding All nodes in the same document that are befor e the context node XPath 73, Axis Selection attribute The attributes of the context node (abbreviated as @) namespace The namespace nodes of the context node It is possible to write the following expressions: ancestor::chapter Selects the <chapter> elements that are ancestors of the context node following-sibling::para/@title Selects the title attributes of <para> elements in siblings of the context node that follow it in document order id('xpath')/following::chapter/node() Selects all the nodes in the <chapter> element following the element with the xpath identifier in document order The result of an XPath expression is a node-set. It may be helpful to filter a node-set with predicates. <h2>Predicates</h2> A predicate is an expression in square brackets that filters a node-set. For example, we could write the following expr essions: //chapter[1] Selects the first <chapter> element in the document //chapter[@title='XPath'] Selects the <chapter> element in the document where the value of the title attribute is the string XPath //chapter[section] Selects the <chapter> elements in the document with a <section> child <para[last()]> Selects the last <para> element child of the context node 74 XML Pocket Reference, Note that a path in a predicate does not change the path pre- ceding the predicate, but only filters it. Thus, the following expr ession: /book/chapter[conclusion] selects a <chapter> element that is a child of the <book> ele- ment at the root of the document with a descendant of type conclusion, but not a <conclusion> element itself. Ther e may be more than one predicate in an expression. The following expression: /book/chapter[1]/section[2] selects the second section of the first chapter. In addition, the order of the predicates matters. Thus, the following expres- sions are not the same: chapter[example][2] Selects the second <chapter> that includes <example> ele- ments chapter[2][example] Selects the second <chapter> element if it includes at least one <example> element An expression can include logical or comparison operators. The following operators are available: Operator Meaning or Log ical or and Logical and not( ) Negation = != Equal to and differ ent fr om < <= Less than and less than or equal to > >= Mor e than and more than or equal to XPath 75, The character < must be entered as < in expressions. Paren- theses may be used for grouping. For example: chapter[@title = 'XPath'] Selects <chapter> elements where the title attribute has the value XPath chapter[position() < 3] Selects the first two <chapter> elements chapter[position() != last()] Selects <chapter> elements that are not in the last position chapter[section/@title='examples' or subsection/@title= 'examples'] Selects <chapter> elements that include <section> or <sub- section> elements with the title attribute set to examples XPath also defines operators that act on numbers. The numeric operators are +, –, *, div (division of real numbers), and mod (modulo). <h2>Functions</h2> In the previous examples we saw such XPath functions as position() and not(). XPath defines four basic types of functions that retur n: booleans (true or false), numbers (real numbers), strings (strings of characters), and node-sets. The functions are gr ouped based on the datatypes they act upon. The following functions deal with node-sets (optional argu- ments are followed by a question mark): last() Retur ns the total number of nodes of which the context node is a part position() Retur ns a number that is the position of the context node (in document order or after sorting) 76 XML Pocket Reference, count(node-set) Retur ns the number of nodes contained in the specified node-set id(name) Retur ns the node with the identifier name local-name([node-set]) Retur ns a string that is the name (without the namespace) of the first node in document order of the node-set, or the context-node, if the argument is omitted namespace-uri([node-set]) Retur ns a string that is the URI for the namespace of the first node in document order of the node-set, or the con- text node, if the argument is omitted name([node-set]) Retur ns a string that is the full name (with namespace) of the first node in document order of the node-set, or the context node, if the argument is omitted The following functions deal with strings: string(object) Converts its argument object, which can be of any type, to a string. concat(str1, str2, .) Retur ns the concatenation of its arguments. starts-with(str1, str2) Retur ns true if the first argument string (str1) starts with the second argument string (str2). contains(str1, str2) Retur ns true if the first argument string (str1) contains the second argument string (str2). substring-befor e (str1, str2) Retur ns the substring of the first argument string (str1) that precedes the first occurrence of the second argument string (str2). XPath 77, substring-after (str1, str2) Retur ns the substring of the first argument string (str1) that follows the first occurrence of the second argument string (str2). substring(str, num[, length]) Retur ns the substring of the first argument (str) starting at the position specified by the second argument (num) with the length specified in the third. If the third argument is not specified, the substring continues to the end of the string. string-length(str) Retur ns the number of characters in the string. nor malize-space(str) Retur ns the argument string with whitespace normalized by stripping any leading and trailing whitespace and replacing sequences of whitespace characters by a single space. translate(str1, str2, str3) Retur ns the first argument string (str1) with occurrences of characters in the second argument string (str2) replaced by the character at the corresponding position in the third argument string (str3). The following functions deal with boolean operations: boolean(object) Converts its argument (object), which can be of any type, to a boolean not(boolean) Retur ns true if its argument evaluates as false true() Retur ns true false() Retur ns false 78 XML Pocket Reference, lang(str) Retur ns true if the language of the document (or the clos- est ancestor indicating the language) is the language passed in the argument (str) The following functions deal with numbers: number([obj]) Converts its argument (obj), which can be of any type, to a number (using the context node if the argument is omitted.) sum(node-set) Retur ns the sum of the result of converting every node in the node-set to a number. If any node is not a number, the function retur ns NaN (not a number). floor(num) Retur ns the largest integer that is not greater than the argument (num). ceiling(num) Retur ns the smallest integer that is not less than the argu- ment (num). round(num) Retur ns the integer that is closest to the argument (num). These functions can be used not only in XPath expressions, but in XSLT elements as well. For example, to count the num- ber of sections in a text, we could add the following to a stylesheet: <xsl:text>The number of sections is </xsl:text> <xsl:value-of select="count(//section)"/> <h2>Additional XSLT Functions and Types</h2> XSLT defines additional functionality for its own needs. One featur e is a new datatype (in addition to the four datatypes defined by XPath): the result tree fragment. This datatype is comparable to a node-set, except that its nodes are in a tree XPath 79, rather than an unorganized collection. All the operations that ar e per mitted for node-sets are per mitted for tree fragments. However, you cannot use the /, //, or [ ] operators on result tr ee fragments. XSLT also defines additional functions: document(obj[, node-set]) Retur ns a node-set that comprises the document whose URI (related to the second, optional argument) was passed as the first argument obj. If the second argument is omitted, the context node is used. key(str, obj) Retur ns the node-set of the nodes keyed by obj in the key named str (see the section “XSLT Elements” for an exam- ple). for mat-number(num, str1[, str2]) Retur ns a string containing the formatted value of num, according to the format-patter n string in str1 and the deci- mal-for mat string in str2 (or the default decimal- for mat if there is no third argument). curr ent() Retur ns the current node. unparsed-entity-uri(str) Retur ns the URI of the unparsed entity given by str. generate-id(node-set) Generates a unique ID for the first node in the given node-set. system-pr operty(str) Retur ns the value of the system property passed as a string str. The system properties are: xsl:version (the ver- sion of XSLT implemented by the processor), xsl:vendor (a string identifying the vendor of the XSL processor), and xsl:vendor-url (the vendor’s URL). 80 XML Pocket Reference, <h2>XPointer and XLink</h2> The final pieces of XML we cover are XPointer and XLink. These are separate standards in the XML family dedicated to working with XML links. Before we delve into them, however, we should warn you that the standards described here are not final as of publication time. It’s important to remember that an XML link is only an asser- tion of a relationship between pieces of documents; how the link is actually presented to a user depends on a number of factors, including the application processing the XML docu- ment. <h2>Unique Identifiers</h2> To create a link, we must first have a labeling scheme for XML elements. One way to do this is to assign an identifier to spe- cific elements we want to refer ence using an ID attribute: <paragraph id="attack"> Suddenly the skies were filled with aircraft. </paragraph> You can think of IDs in XML documents as street addresses: they provide a unique identifier for an element within a docu- ment. However, just as there might be an identical address in a dif ferent city, an element in a differ ent document might have the same ID. Consequently, you can tie together an ID with the document’s URI, as shown here: The combination of a document’s URI and an element’s ID should uniquely identify that element throughout the uni- verse. Remember that an ID attribute does not need to be named id, as shown in the first example. You can name it any- thing you want, as long as you define it as an XML ID in the document’s DTD. (However, using id is preferr ed in the event that the XML processor does not read the DTD.) XPointer and XLink 81, Should you give an ID to every element in your documents? No. Odds are that most elements will never be refer enced. It’s best to place IDs on items that a reader would want to refer to later, such as chapter and section divisions, as well as impor- tant items, such as term definitions. <h2>ID References</h2> The easiest way to refer to an ID attribute is with an ID refer- ence, or IDREF. Consider this example: <?xml version="1.0" standalone="yes"?> <DOCTYPE document [ <!ELEMENT document (employee*)> <!ELEMENT employee (#PCDAT A)> <!ATTLIST employee empnumber ID #REQUIRED> <!ATTLIST employee boss IDREF #IMPLIED> ]> <employee empnumber="emp123">Jay</employee> <employee empnumber="emp124">Kay</employee> <employee empnumber="emp125" boss="emp123">Frank</employee> <employee empnumber="emp126" boss="emp124">Hank</employee> As with ID attributes, an IDREF is typically declared in the DTD. However, if you’r e in an environment where the proces- sor might not read the DTD, you should call your ID refer- ences IDREF. The chief benefit of using an IDREF is that a validating parser can ensure that every one points to an actual element; unlike other forms of linking, an IDREF is guaranteed to refer to something within the current document. As we mentioned earlier, the IDREF only asserts a relationship of some sort; the stylesheet and the browser will determine what is to be done with it. If the referring element has some content, it might become a link to the target. But if the refer- ring element is empty, the stylesheet might instruct the br owser to perfor m some other action. As for the linking behavior, remember that in HTML a link can point to an entire document (which the browser will 82 XML Pocket Reference, download and display, positioned at the top) or to a specific location in a document (which the browser will display, usu- ally positioned with that point at the top of the screen). How- ever, linking changes drastically in XML. What does it mean to have a link to an entire element, which might be a paragraph (or smaller) or an entire group of chapters? The XML applica- tion attempts some kind of guess, but the display is best con- tr olled by the stylesheet. For now, it’s best to simply make a link as meaningful as you can. <h2>XPointer</h2> XPointer is designed to resolve the problem of locating an element or range of elements in an XML document. It is possi- ble to do this in HTML if the element is refer enced by an <a name="name"> tag. Here, a link is made for the section of the document using the <a href="url#name"> tag. Fragment-identifier syntax As we saw earlier, XML has this type of functionality through its unique identifiers. It is possible to locate an element with an identifier using a link such as the following: document.xml#identifier wher e identifier is a valid XPointer fragment identifier. How- ever, this form is a simplification that is tolerated for compati- bility with previous versions. The most common syntax for an XPointer fragment identifier is: document.xml#xpointer(xpath) Her e xpath is an expression consistent with the XPath specifi- cation. It is the right thing to do in this case because it can be used to locate a node-set within a document. The link docu- ment.xml#identifier can be rewritten as: document.xml#xpointer(id("identifier")) XPointer and XLink 83, Ther e is a third possible form made up of a whole number separated by slashes. Each whole number selects an n th child fr om its predecessor in the expression. Several fragment identifiers can be combined by placing them one after the other. For example: document.xml#xpointer(...)xpointer(...)... The application must evaluate the fragments, from left to right, and use the first valid fragment. This functionality is useful for two reasons: • It offers several solutions, the first of which is based on suppositions that may prove to be false (and produce an err or). For example, we can try to locate a fragment in a document using an identifier, then (if no ID was defined) using the attribute value with the name id. We would write the fragment: xpointer(id("conclusion"))xpointer(//*[@id=conclusion]) • It also allows for future specifications. If an XPointer application encounters an expression that does not begin with xpointer, it will simply ignore it and move on to the next expression. As we mentioned earlier, the XPointer application is responsi- ble for link rendering, but it is also responsible for error han- dling. If the link’s URL is wrong or if the fragment identifier is not valid, it is up to the application to manage the situation (by displaying an error message, for example). XPointer datatypes Earlier we showed you how to locate an XML node within a document. XPointer goes even further by defining the point, range, and position (location) types: Point Can precede or follow a node (point of type node) or a character (thus, a point of type character). 84 XML Pocket Reference, Range Is defined as the content of a document between two points (where the starting point cannot be located after the ending point within a document). A range cannot be reduced to a set of nodes and characters because it can include fragments of the former. Position Is a generalized concept of the node. It can be a node, a point, or a range. Equipped with these new datatypes, XPointer can set out to locate a resource in an XML document. Manipulation of points, ranges, and positions A range is defined using the to operator. This operator is enclosed in starting points (to the left) and ending points (to the right). The second point is calculated using the first point as a refer ence. For example, to make a range from the begin- ning of the first paragraph to the end of the last paragraph in a section where the ID is XPointer, you would write: xpointer(id("XPointer")/para[1] to id("XPointer")/para[last()]) or: xpointer(id("XPointer")/para[1] to following-sibling::para[last()]) A range defined this way may be compared with the selection a user can make in a document with a mouse. Naturally, XPointer also has functions to manipulate points and ranges. The available functions are: string-range(positions, string[, of fset][, length]) This function can be used to search for strings in a docu- ment and returnaset of positions where they appear. The first argument is an XPath expression — a set of posi- tions where the search must take place. The second is the string being searched. To search for the string XML in XPointer and XLink 85, <chapter> elements where the title attribute is XPointer, we would write the expression: string-range(//chapter[@title=XPointer], "XML") To index the word XML by pointing to the first occur- rence of the word in an element such as <para>, use the following expression: string-range(//para, "XML")[1] This function takes two other optional arguments. The third argument, of fset, is a number that indicates the first character to be included in the result range offset from the beginning of the string searched for. The fourth argu- ment, length, gives the length of the result range. By default, of fset has a value of 1, thus the result range begins before the first character in the string. length has a default value such that the result range covers the entire string searched. range(positions) This function takes an XPath expression and retur ns a set of ranges (a location set) where each includes the posi- tions passed as parameters. It can be used to convert a set of positions (which may be nodes) to a set compris- ing ranges only. range-inside(positions) This function takes an XPath expression and retur ns a set of ranges (a location set) for each of the positions passed as arguments. start-point(positions) This function takes an XPath expression and retur ns the starting point of the range for each of the positions passed as arguments. The result is a set of points. end-point(positions) This function takes an XPath expression and retur ns the end point of the range for each of the positions passed as arguments. The result is a set of points. 86 XML Pocket Reference, her e() This function is defined only within an XML document. It retur ns a unique position comprising the element con- taining the XPointer expression or the attribute that con- tains it. origin() This function can be used only for links triggered by the user. It retur ns the element’s position to the original link. <h2>XLink</h2> Now that we know about XPointer, let’s take a look at some inline links: <?xml version="1.0"?> <simpledoc xmlns:xlink=""> <title>An XLink Demonstration
This is a paragraph in the first section. More information about XLink can be found at the W3C .
This is a paragraph in the second section. You should go read the first section first.
The first link states that the text “the W3C” is linked to the URL http://www.w3.or g. How does the browser know? Simple. XPointer and XLink 87, An HTML browser knows that every element is a link because the browser has to handle only one document type. In XML, you can make up your own element type names, so the br owser needs some way of identifying links. XLink provides the xlink:type attribute for link identification. A br owser knows it has found a simple link when any element sets the xlink:type attribute to a value of simple. A simple link is like a link in HTML—one-way and beginning at the point in the document where it occurs. (In fact, HTML links can be recast as XLinks with minimal effort.) In other words, the con- tent of the link element can be selected for traversal at the other end. Returning to the source document is left to the browser. Once an XLink processor has found a simple link, it looks for other attributes that it knows: xlink:hr ef This attribute is deliberately named to be familiar to any- one who’s used the Web before. Its value is the URI of the other end of the link; it can refer to an entire docu- ment or to a point or element within that document. If the target is in an XML document, the fragment part of the URI is an XPointer. This attribute must be specified, since without it, the link is meaningless. It is an error not to include it. xlink:r ole This describes the nature of the object at the other end of the link. XLink doesn’t predefine any roles; you might use a small set to distinguish differ ent types of links in your documents, such as cross-r efer ences, additional reading, and contact information. A stylesheet might take a dif ferent action (such as presenting the link in a differ- ent color) based on the role, but the application won’t do anything automatically. 88 XML Pocket Reference, xlink:title A title for the resource at the other end of the link can be pr ovided, identical to HTML’s title attribute for the element. A GUI browser might display the title as a tool tip; an aural browser might read the title when the user pauses at the link before selecting it. A stylesheet might also make use of the information, perhaps to build a list of refer ences for a document. xlink:show This attribute suggests what to do when the link is tra- versed. It can take the following values: embed The content at the other end of the link should be retrieved and displayed where the link is. An exam- ple of this behavior in HTML is the element, whose target is usually displayed within the docu- ment. replace When the link is activated, the browser should replace the current view with a view of the resource targeted by the link. This is what happens with the element in HTML: the new page replaces the curr ent one. new The browser should somehow create a new context, if possible, such as opening a new window. other This value specifies behavior that isn’t described by the other values. It is up to the application to deter- mine how to display the link. none This specifies no behavior. You do not need to give a value for this attribute. Remember that a link primarily asserts a relationship between data; behavior is best left to a stylesheet. So XPointer and XLink 89, unless the behavior is paramount (as it might be in some cases of embed, it is best not to use this attribute. xlink:actuate The second of the behavioral attributes specifies when the link should be activated. It can take the following val- ues: onRequest The application waits until the user requests that the link be followed, as the element in HTML does. onLoad The link should be followed immediately when it is encounter ed by the application; this is what most HTML browsers do with elements, unless the user has turned off image loading. other The link is activated by other means, not specified by XLink. This is usually defined by other markup in the document. none This indicates no information about the activation of the link and may be used when the link has no cur- rent meaningful target or action.

Building Extended Links

XLink has much more to offer, including links to multiple doc- uments and links between disparate documents (where the XML document creating the links does not even contain any links). Extended links An XLink application recognizes extended links by the pres- ence of an xlink:type="extended" attribute that distinguishes it fr om a simple link (such as those used in HTML). An extended link may have semantic attributes (xlink:r ole and xlink:title) that function just as they do for a simple link. 90 XML Pocket Reference, In addition, an extended link may be one of four types as defined by its xlink:type="type" attribute: resour ce Supplies the local resource for the link (generally the text used to materialize the link) locator Supplies a URI for the remote document participating in the link ar c Supplies a description of the potential paths among the documents participating in the extended link title Supplies a label for the link Consider this example of an extended link supplying an XML bibliography: XML Bibliography The extended link will probably be repr esented graphically as a menu with an entry for each element, except for the last one (arc), which has no graphical repr esentation. However, the graphical repr esentation of the link is the application’s responsibility. Let’s look at the role of each of the elements. XPointer and XLink 91,

Resource elements

Resource elements, which include the xlink:type="r esource" attribute, define a local resource that participates in a link. An extended link that includes a resource is considered inline because the file in which it is found participates in a link. A link that has no resource is called out-of-line. XLink applications use the following attributes: Attr ibute Descr iption xlink:type resource (fixed value) xlink:r ole Role of this resource in the link (used by arcs) xlink:title Text used by the XLink application to repr esent this resource In our example, the element supplies the text to be dis- played to repr esent the link.

Locator elements

Locator elements have the xlink:type="locator" attribute and use a URI to point to a remote resource. XLink applications use the following locator attributes: Attr ibute Descr iption xlink:type locator (fixed value) xlink:hr ef URI of the resource pointed to xlink:role Role resource pointed to (used by arcs) xlink:title Text the XLink application uses to graphically repr esent the resource In our example, we use two kinds of locators: those with a role of book that point to documents describing publications, and those with a role of author that point to a biography. Her e, the role is important because it tells the XLink applica- tion the potential traversals among resources. 92 XML Pocket Reference,

Arc elements

Arc elements have the xlink:type="arc" attribute and determine the potential traversals among resources, as well as the behav- ior of the XLink application during such traversals. Arc ele- ments may be repr esented as arrows in a diagram, linking resources that participate in an extended link. XLink applications use the following arc attributes: Attr ibute Descr iption xlink:type arc (fixed value) xlink:fr om Indicates the role of the resource of the originating arc xlink:to Indicates the role of the resource of the destination arc xlink:show new, replace, embed, other, or none: tells the XLink application how to display the resource to which the arc is pointing xlink:actuate onLoad, onRequest, other, or none: tells the XLink appli- cation the circumstances under which the traversal is made xlink:arcr ole Role of the arc xlink:title Text that may be used to repr esent the arc The values of the xlink:show and xlink:actuate attributes have the same meaning as they do with simple links. Let’s go back to our example of the bibliography, where we could define the following arc: The arc creates a link from the text displayed by the navigator (a resource where the role is text) to the descriptive page from the book (remote resource where the role is book). It also indicates that the page must be displayed in a new window (xlink:show="new") when the user clicks the mouse button (xlink:actuate="onRequest"). XPointer and XLink 93, To include the author’s biography in the card for the book, we will define the following arc: xlink:show="embed" indicates that the destination of the arc (the biography) must be included in the card for the book (origin of the arc) and that the destination must be included when the book page is loaded (xlink:actuate="onLoad"). Finally, we need to indicate that the absence of the xlink:fr om or xlink:to attribute indicates that the origin or destination of the arc corr esponds to all the roles defined in the link. Thus, the arc in our example () authorizes all the traversals possible among the resources of the extended link.

Title elements

Elements with a type of tell the XLink application the title of the extended link. This element is needed when you want titles to have markers (for example, to put the text in bold) or if you want to provide titles in multiple languages. A <title> element must have the xlink:type="title" attribute. As there may be a large number of attributes for the elements participating in an extended link, we recommend using the default values in the DTD. This eliminates the need to include fixed-value attributes for an element. For example, because the xlink:type attribute of the <biblio> element always has extended as the value, we could declare the <biblio> element in the DTD as follows: <!ELEMENT biblio (text, book+, author+, arc+)> <!ATTLIST biblio xlink:type (extended) #FIXED "extended"> We would not need to indicate the type, and if we proceed the same way for the other elements in the extended link, we could write the following link: 94 XML Pocket Reference, <biblio> <text>XML Bibliography</text> <book xlink:href="xmlgf.xml" xlink:title="XML Pocket Reference"/> <book xlink:href="lxml.xml" xlink:title="Learning XML"/> <author xlink:href="robert-eckstein.xml" xlink:title="Robert Eckstein"/> <author xlink:href="erik-ray.xml" xlink:title="Erik Ray"/> <arc/> </biblio> By limiting ourselves to the strict minimum (attributes where the value is fixed do not need to be written), we gain read- ability. <h2>Linkbases</h2> As indicated earlier, an extended link with no resource-type element (local resource) is described as being out-of-line. Ther efor e, this type of link is not defined in any files to which it points. It may be convenient to regro up extended links in XML files called linkbases. This raises the question as to the location of such XML files. If we have no way of finding the linkbases associated with a given file (not provided in the W3C specification), we must indicate the URI in one of the files participating in the link. This is possible thanks to the xlink:r ole attribute with the value xlink:extended-linkset. The XLink application recognizes the attribute and can look for the associated linkbase where the URI is indicated by the xlink:hr ef attribute. For example, to link the linkbase of the URI linkbase.xml to an XML file, we could use an element with the following syntax: <linkbase> <uri xlink:role="XLink:extended-linkset" xlink:href="linkbase.xml"/> </linkbase> XPointer and XLink 95, We can indicate as many linkbases in a file as we want. A linkbase can itself contain a refer ence to another linkbase. It is up to the XLink application to manage circular refer ences and limit the depth of the search for linkbases. <h2>XBase</h2> XBase is a W3C specification currently in development. XBase can be used to change the base of URIs in an XML document (which, by default, is the document’s directory). XLink proces- sors take XBase into consideration in order to manage URIs, using the xml:base="URI" attribute as follows: <base xml:base=""/> <linkbase> <uri xlink:role="xlink:extended-linkset" xlink:href="linkbase.xml"/> </linkbase> The linkbase.xml linkbase is searched for in the http://www. or dir ectory, not in the directory of the docu- ment where the request was made to load the linkbase. Loading of the base continues in the nodes that descend from the node in which the base is defined (this is the same behav- ior as the xml:lang and xml:space attributes). 96 XML Pocket Reference]</div> <div>15</div> </div> <h2>Similar documents</h2> <div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/11/2711/1228042833-2711-100.jpg" alt="XMP Custom Panels b bc September 2003"></a> <div class="preview-title"><a href="">XMP Custom Panels b bc September 2003</a></div> <div class="preview-text">XMP Custom Panels b bc ADOBE SYSTEMS INCORPORATED Corporate Headquarters 345 Park Avenue San Jose, CA 95110-2704 (408) 536-6000 September 2003 Copyright 2003 Adobe Systems Incorporated. All rights reserved. NOTICE: All information contained herein is the property of Adobe S</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/12/2712/3959264462-2712-100.jpg" alt="Beginning ASP.NET 1.1 with Visual C#® .NET 2003 Chris Ullman John Kauffman Chris Hart Dave Sussman Daniel Maharry Wiley Publishing, Inc."></a> <div class="preview-title"><a href="">Beginning ASP.NET 1.1 with Visual C#® .NET 2003 Chris Ullman John Kauffman Chris Hart Dave Sussman Daniel Maharry Wiley Publishing, Inc.</a></div> <div class="preview-text">Beginning ASP.NET 1.1 with Visual C#® .NET 2003 Chris Ullman John Kauffman Chris Hart Dave Sussman Daniel Maharry Wiley Publishing, Inc. Beginning ASP.NET 1.1 with Visual C#® .NET 2003 Beginning ASP.NET 1.1 with Visual C#® .NET 2003 Chris Ullman John Kauffman Chris Hart Dave Sussman Daniel Maharry W</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/13/2713/2454385464-2713-100.jpg" alt="Powered by TCPDF ("></a> <div class="preview-title"><a href="">Powered by TCPDF (</a></div> <div class="preview-text">Powered by TCPDF (</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/14/2714/3970325038-2714-100.jpg" alt="XMPP: The Definitive Guide"></a> <div class="preview-title"><a href="">XMPP: The Definitive Guide</a></div> <div class="preview-text">XMPP: The Definitive Guide XMPP: The Definitive Guide Building Real-Time Applications with Jabber Technologies Peter Saint-Andre, Kevin Smith, and Remko Tronçon Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo XMPP: The Definitive Guide by Peter Saint-Andre, Kevin Smith, and Remko </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/16/2716/92572332-2716-100.jpg" alt="Writ for Habeas Corpus"></a> <div class="preview-title"><a href="">Writ for Habeas Corpus</a></div> <div class="preview-text">Dave Thomas c/o 45 Main Anytown, Utah state non domestic united States of America without the UNITED STATES/STATE OF UTAH Fifth District Court sitting in Washington and Iron county, Utah state Writ for Habeas Corpus In re: Restraint of Liberty by James L. Jones and Bill Smith, d/b/a JUDGE JONES and </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/17/2717/3950474697-2717-100.jpg" alt="OPTIMIZING THE DESKTOP USING SUN™ XVM VIRTUALBOX Ulrich Möller, VirtualBox Software Team Sun BluePrints™ Online"></a> <div class="preview-title"><a href="">OPTIMIZING THE DESKTOP USING SUN™ XVM VIRTUALBOX Ulrich Möller, VirtualBox Software Team Sun BluePrints™ Online</a></div> <div class="preview-text">OPTIMIZING THE DESKTOP USING SUN™ XVM VIRTUALBOX Ulrich Möller, VirtualBox Software Team Sun BluePrints™ Online Part No 820-7121-10 Revision 1.0, 11/25/08 Sun Microsystems, Inc. Table of Contents Optimizing the Desktop Using Sun™ xVM VirtualBox ..1 Sun xVM VirtualBox and Desktop Virtualization .1 Ea</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/18/2718/2243174950-2718-100.jpg" alt="MICROSOFT WEB SERVICES ENHANCEMENTS 2.0 SP3 RUNTIME"></a> <div class="preview-title"><a href="">MICROSOFT WEB SERVICES ENHANCEMENTS 2.0 SP3 RUNTIME</a></div> <div class="preview-text">MICROSOFT WEB SERVICES ENHANCEMENTS 2.0 SP3 RUNTIME END-USER LICENSE AGREEMENT FOR MICROSOFT SOFTWARE IMPORTANT—READ CAREFULLY: This End-User License Agreement (“EULA”) is a legal agreement between you (either an individual or a single entity) and Microsoft Corporation (“Microsoft”) for the Microsof</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/20/2720/1466390993-2720-100.jpg" alt="ProductK009166 DATA Trailer Information Module (TIM G2)"></a> <div class="preview-title"><a href="">ProductK009166 DATA Trailer Information Module (TIM G2)</a></div> <div class="preview-text">ProductK009166 DATA Trailer Information Module (TIM G2) Function The Trailer Information Module (TIM G2) is a trailer mounted display for direct reading of diagnostic and trailer related information. It may also be used as a hand held diagnostic tool. It enables access to information available withi</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/24/2724/2406527869-2724-100.jpg" alt="Yammer Starter"></a> <div class="preview-title"><a href="">Yammer Starter</a></div> <div class="preview-text">Yammer Starter A concise, enjoyable look at using Yammer, the secure, fun-to-use private social network for your company, now from Microsoft Ralph Roberts BIRMINGHAM - MUMBAI Yammer Starter Copyright © 2012 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a ret</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/32/2732/1844151259-2732-100.jpg" alt="You Taste Like Sugar"></a> <div class="preview-title"><a href="">You Taste Like Sugar</a></div> <div class="preview-text">You Taste Like Sugar Count: 64 Wall: 4 Level: Improver Choreographer: Wil Bos – Dec. 2015 Music: "Expandable Time" by Danny Vera (album: Expandable Time) 120 bpm Intro: 16 counts S1: Dorothy x2, Pivot ½ L, ¼ L Chassé 1-2& RF step right forward, LF lock behind, RF step forward 3-4& LF step left forwa</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/33/2733/1699356169-2733-100.jpg" alt="XZ Utils"></a> <div class="preview-title"><a href="">XZ Utils</a></div> <div class="preview-text">XZ Utils XZ Utils is free general-purpose data compression software with high compression ratio. XZ Utils were written for POSIX-like systems, but also work on some not-so-POSIX systems. XZ Utils are the successor to LZMA Utils. The core of the XZ Utils compression code is based on LZMA SDK, but it </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/34/2734/3828139923-2734-100.jpg" alt=""></a> <div class="preview-title"><a href=""></a></div> <div class="preview-text">Yii Rapid Application Development Hotsh t Become a RAD hotshot with Yii, the world's most popular PHP framework Lauren J. O'Meara James R. Hamilton III BIRMINGHAM - MUMBAI Yii Rapid Application Development Hotsh t Copyright © 2012 Packt Publishing All rights reserved. No part of this book may be rep</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/35/2735/1388293283-2735-100.jpg" alt=""></a> <div class="preview-title"><a href=""></a></div> <div class="preview-text">01_598007 ffirs.qxd 8/25/05 8:35 PM Page iii Yahoo!® SiteBuilder FOR ‰ DUMmIES Richard Wagner 01_598007 ffirs.qxd 8/25/05 8:35 PM Page ii 01_598007 ffirs.qxd 8/25/05 8:35 PM Page i Yahoo!® SiteBuilder FOR ‰ DUMmIES 01_598007 ffirs.qxd 8/25/05 8:35 PM Page ii 01_598007 ffirs.qxd 8/25/05 8:35 PM Page </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/36/2736/436113750-2736-100.jpg" alt="Mark Lauren is a certified Military Physical Training Specialist, Special Op- erations Combat Controller, triathlete, and champion Thai boxer. He has ef-"></a> <div class="preview-title"><a href="">Mark Lauren is a certified Military Physical Training Specialist, Special Op- erations Combat Controller, triathlete, and champion Thai boxer. He has ef-</a></div> <div class="preview-text">Mark Lauren is a certified Military Physical Training Specialist, Special Op- erations Combat Controller, triathlete, and champion Thai boxer. He has ef- fectively prepared nearly a thousand trainees for the extreme demands of the most elite levels of the Special Operations community. As an experien</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/38/2738/587287424-2738-100.jpg" alt="Ilyushin 76 T"></a> <div class="preview-title"><a href="">Ilyushin 76 T</a></div> <div class="preview-text">About the aircraft: This aircraft is built to be as close to the real thing both in performance and look. The performance was designed using the original Pilot’s Handbook which can be found at The real aircraft is still handles a little better at high weights which I am not </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/40/2740/917722286-2740-100.jpg" alt="InterBase 6 Getting Started Installation and Migration Borland/INPRISE"></a> <div class="preview-title"><a href="">InterBase 6 Getting Started Installation and Migration Borland/INPRISE</a></div> <div class="preview-text">InterBase 6 Getting Started Installation and Migration Borland/INPRISE 100 Enterprise Way, Scotts Valley, CA 95066 November 12, 1999 (D:\60DocSet\Doc\GetStart\GetStartedTitle.fm5) Inprise/Borland may have patents and/or pending patent applications covering subject matter in </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/42/2742/2710547363-2742-100.jpg" alt="The Virevent is both complex and simple to make. Center frequency shift with change in wires"></a> <div class="preview-title"><a href="">The Virevent is both complex and simple to make. Center frequency shift with change in wires</a></div> <div class="preview-text">The Virevent is both complex and simple to make. Center frequency shift with change in wires diameter, so dimensions cannot be a simple Freq./x.xx equation. There's a mathematical equation that can take wire diameter into account, but the goal of this tutorial is to be simple. Let's use 0.8mm copper</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/46/2746/892206271-2746-100.jpg" alt="䄀. 䅀䍐䏐䏐䎀䏐䌰. ActiveX 䍀䎰䓰 䏰䐀䏠䑀䍐䐐䐐䎀䏠䏐䌀䎰䏠䌠 ActiveX 䍀䎰䓰 䏰䐀䏠䑀䍐䐐䐐䎀䏠䏐䌀䎰䏠䌠 䈐䏠䍀䍐䐀䍠䌀䏐䎀䍐 䇰䐀䍐䍀䎀䐐䎰䏠䌠䎀䍐 䄠䒰䐀䌀䍠䍐䏐䎀䍐 䏰䐀䎀䍰䏐䌀䐠䍐䎰䓀䏐䏠䐐䐠䎀 䄠䌠䍐䍀䍐䏐䎀䍐 䇠 䎠䏐䎀䌰䍐 䅀䎰䓰 䎠䏠䌰䏠 䏐䌀䏰䎀䐐䌀䏐䌀 䓐䐠䌀 䎠䏐䎀䌰䌀?"></a> <div class="preview-title"><a href="">䄀. 䅀䍐䏐䏐䎀䏐䌰. ActiveX 䍀䎰䓰 䏰䐀䏠䑀䍐䐐䐐䎀䏠䏐䌀䎰䏠䌠 ActiveX 䍀䎰䓰 䏰䐀䏠䑀䍐䐐䐐䎀䏠䏐䌀䎰䏠䌠 䈐䏠䍀䍐䐀䍠䌀䏐䎀䍐 䇰䐀䍐䍀䎀䐐䎰䏠䌠䎀䍐 䄠䒰䐀䌀䍠䍐䏐䎀䍐 䏰䐀䎀䍰䏐䌀䐠䍐䎰䓀䏐䏠䐐䐠䎀 䄠䌠䍐䍀䍐䏐䎀䍐 䇠 䎠䏐䎀䌰䍐 䅀䎰䓰 䎠䏠䌰䏠 䏐䌀䏰䎀䐐䌀䏐䌀 䓐䐠䌀 䎠䏐䎀䌰䌀?</a></div> <div class="preview-text">䄀. 䅀䍐䏐䏐䎀䏐䌰. ActiveX 䍀䎰䓰 䏰䐀䏠䑀䍐䐐䐐䎀䏠䏐䌀䎰䏠䌠 ActiveX 䍀䎰䓰 䏰䐀䏠䑀䍐䐐䐐䎀䏠䏐䌀䎰䏠䌠 䈐䏠䍀䍐䐀䍠䌀䏐䎀䍐 䇰䐀䍐䍀䎀䐐䎰䏠䌠䎀䍐 䄠䒰䐀䌀䍠䍐䏐䎀䍐 䏰䐀䎀䍰䏐䌀䐠䍐䎰䓀䏐䏠䐐䐠䎀 䄠䌠䍐䍀䍐䏐䎀䍐 䇠 䎠䏐䎀䌰䍐 䅀䎰䓰 䎠䏠䌰䏠 䏐䌀䏰䎀䐐䌀䏐䌀 䓐䐠䌀 䎠䏐䎀䌰䌀? 䇐䌀䑰䌀䎰䓀䏐䒰䍐 䐠䐀䍐䌐䏠䌠䌀䏐䎀䓰 䈀䌀䌐䏠䐠䌀 䐐 䐐䏠䏰䐀䏠䌠䏠䍀䎀䐠䍐䎰䓀䏐䒰䏀 CD-ROM 䈐䐠䎀䎰䓀 䏰䐀䏠䌰䐀䌀䏀䏀䎀䐀䏠䌠䌀䏐䎀䓰 䇐䍐䎠䏠䐠䏠䐀䒰䍐 䏠䌐䒐䎀䍐 䍰䌀䏀䍐䑰䌀䏐䎀䓰 䉰䌀䐐䐠䓀 I. 䄠䐐䐠䐰䏰䎰䍐䏐䎀䍐 䄰䎰䌀䌠䌀 1 «䆠䏠䏀䏰䏠䏐䍐</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/47/2747/2249452393-2747-100.jpg" alt="O6qecreo c orpaHil.{eHFofi oTBercrBeH4gqTbq (KoHca4rrFroPar fpvnna l,lHlgaqnrr,rp"></a> <div class="preview-title"><a href="">O6qecreo c orpaHil.{eHFofi oTBercrBeH4gqTbq (KoHca4rrFroPar fpvnna l,lHlgaqnrr,rp</a></div> <div class="preview-text">O6qecreo c orpaHil.{eHFofi oTBercrBeH4gqTbq (KoHca4rrFroPar fpvnna l,lHlgaqnrr,rp Aapqc: 9441:12. r.9Mcf. v+. Fvnu,eap ApxrrerrgpoBr a,4.,nou,1, l. rqn.8 (381) 248-71-07. flonyvarenu UHH 5507248880 Knn550701 001 p/cver Ne 4070281 0004000009327 OOO (Kf Hnrencnrn> 6anr nonyvarenn 514K 045004816 Cu6rpc</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/50/2750/3439432667-2750-100.jpg" alt="Amazing Sex"></a> <div class="preview-title"><a href="">Amazing Sex</a></div> <div class="preview-text">Amazing Sex by Sari Locker A Division of Macmillan General Reference A Pearson Education Macmillan Company 1633 Broadway, New York, NY 10019-6785 Page ii Copyright © 1999 by Sari Locker All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/54/2754/1840006459-2754-100.jpg" alt="Radlagersätze Lenkungsteile Stoßdämpfer Bremssysteme Wheel Bearing Kits Steering and Suspension Parts Shock Absorbers Brake Systems Kits de Roulements de Roues Pièces de Direction et Suspension Amortisseurs Systèmes de Freinage"></a> <div class="preview-title"><a href="">Radlagersätze Lenkungsteile Stoßdämpfer Bremssysteme Wheel Bearing Kits Steering and Suspension Parts Shock Absorbers Brake Systems Kits de Roulements de Roues Pièces de Direction et Suspension Amortisseurs Systèmes de Freinage</a></div> <div class="preview-text">Radlagersätze Lenkungsteile Stoßdämpfer Bremssysteme Wheel Bearing Kits Steering and Suspension Parts Shock Absorbers Brake Systems Kits de Roulements de Roues Pièces de Direction et Suspension Amortisseurs Systèmes de Freinage Zestawy łożyskowe do kół Elementy zawieszenia Amortyzatory Systemy hamul</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/57/2757/3418260387-2757-100.jpg" alt="BABOTbr O ffiTIBHI,I HAPOIA,"></a> <div class="preview-title"><a href="">BABOTbr O ffiTIBHI,I HAPOIA,</a></div> <div class="preview-text">BABOTbr O ffiTIBHI,I HAPOIA, EOJIETIIE BHtrMAHr{,fl METO,4AU PABOT.6I" (PZ nmoa,pa tr934. ao|a') * tr[a aanttootumertbH,oeo cnoea moeapuu+d Mao llae-lyua na II Bcenumaficrou czeade pa- 6ortux u npecrnb&Hctiufr 1engmamoe, cocnxoee- urc.u,ca s e. )Itgilt4euue npoauHyuu lleaucu e rlHldpe 1934 eo?a, lBa</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/58/2758/545107651-2758-100.jpg" alt="Ta 6Au~a KaAop JiOCmu OC1-l061-lblX Coaep>Kauue"></a> <div class="preview-title"><a href="">Ta 6Au~a KaAop JiOCmu OC1-l061-lblX Coaep>Kauue</a></div> <div class="preview-text">Ta 6Au~a KaAop JiOCmu OC1-l061-lblX Coaep>Kauue npooyKm numaHufl IIep6bte 6;uooa Kl1PHM 490 Xap.,0. ... 9 KapTocpeAbHaJJ 3aneKaHKa c MJJCOM ... 24 CBttHttHa He>KttpHM 355 y xa Vl3 AOCOOI ... 10 TeAJITttHa rrapHM ( ¢l1Ae) 158 Aecepmbt u 6btnettKa MoAO'IHbIH cyn c nep Ml1IUeAhJ0 ... 10 lJbIIIA5!Ta 6po</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/59/2759/800243969-2759-100.jpg" alt="1 2 There is one musical contribution to The Dark Knight Rises that clearly demonstrates the amongst others- Hans sets creative goals for a project"></a> <div class="preview-title"><a href="">1 2 There is one musical contribution to The Dark Knight Rises that clearly demonstrates the amongst others- Hans sets creative goals for a project</a></div> <div class="preview-text">There is one musical contribution to The Dark Knight Rises that clearly demonstrates the amongst others- Hans sets creative goals for a project higher than you ever thought possible or importance of Hans Zimmer as a creative collaborator. It explains why, eight years ago, as a first practical. He to</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/60/2760/2452953799-2760-100.jpg" alt="The MathWorks MATLAB® and Adobe® Photoshop® Read Me"></a> <div class="preview-title"><a href="">The MathWorks MATLAB® and Adobe® Photoshop® Read Me</a></div> <div class="preview-text">The MathWorks MATLAB® and Adobe® Photoshop® Read Me The MATLAB files in this folder create a Photoshop Toolbox in MATLAB. This toolbox creates an easy to use workflow for scientist and researchers using MATLAB and Photoshop in combination. This is a set of MATLAB m files that expand MATLAB functions</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/61/2761/1713534174-2761-100.jpg" alt="И.В. орловская, Л.С. Самсонова, А.И. Скубриева Учебник английского языка ДЛЯ технических университетов и вузов Издание шестое, стереотипное Допущено Учебно-методическим объединением вузов"></a> <div class="preview-title"><a href="">И.В. орловская, Л.С. Самсонова, А.И. Скубриева Учебник английского языка ДЛЯ технических университетов и вузов Издание шестое, стереотипное Допущено Учебно-методическим объединением вузов</a></div> <div class="preview-text">И.В. орловская, Л.С. Самсонова, А.И. Скубриева Учебник английского языка ДЛЯ технических университетов и вузов Издание шестое, стереотипное Допущено Учебно-методическим объединением вузов по машиностроительным и приборостроительным специальностям в качестве учебника для студентов технических универс</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/64/2764/3326586669-2764-100.jpg" alt="PROFORMA INVOICE"></a> <div class="preview-title"><a href="">PROFORMA INVOICE</a></div> <div class="preview-text">PROFORMA INVOICE Invoice No.:DG-RU0145 Date: 22 SEP, 2017 From: Changchun Weihong Dongguang Electronics Equipment Co., Ltd.(State-own 793 Factory) To: Address: No.215 Chuangxin Street High-Tech Saint Petersburg Factory Industrial Development Zone Changchun City Jilin Province 130012 P.R. CHINA TEL: </div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/65/2765/3973873814-2765-100.jpg" alt="Министерство образования Республики Беларусь"></a> <div class="preview-title"><a href="">Министерство образования Республики Беларусь</a></div> <div class="preview-text">Министерство образования Республики Беларусь УЧРЕЖДЕНИЕ ОБРАЗОВАНИЯ «ГРОДНЕНСКИЙ ГОСУДАРСТВЕННЫЙ УНИВЕРСИТЕТ ИМЕНИ ЯНКИ КУПАЛЫ» Учебное издание Калита Елена Владимировна Черниговская Анжелика Игоревна ENGLISH GRAMMAR IN PRACTICE Саввова Раиса Николаевна Карпюк Инна Владимировна ПРАКТИЧЕСКАЯ ГРАММАТИ</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/67/2767/1293795689-2767-100.jpg" alt="a NffArt flporo xol paccMorpeHlrr, o UeHKH H corrocraBneHr,r, 3afl BoK IPOTOKOJI J\t 37 (r,rrOfOBbII,I) l. 3arasqux 2. HannreuosaHrre H cfloco6 flpoBeAerrur 3aryrrKrr"></a> <div class="preview-title"><a href="">a NffArt flporo xol paccMorpeHlrr, o UeHKH H corrocraBneHr,r, 3afl BoK IPOTOKOJI J\t 37 (r,rrOfOBbII,I) l. 3arasqux 2. HannreuosaHrre H cfloco6 flpoBeAerrur 3aryrrKrr</a></div> <div class="preview-text">..: AO . 2. HannreuosaHrre H cfloco6 flpoBeAerrur 3aryrrKrr CocrqsarerbHar 3aKynra Ha npaBo 3aKJrrorreHr{s AoroBopa noAprAa Ha pa6or tro peMoHTy KpoBnr.r Ha3IiaHuu TexHr.rqecKr{x cnyx6 c noABiuIoM. 3. CneAenug o rpeAMere AoroBopa (c yrasaHrreM o6rervra BbrnoJrHfleMbrx pa6or), qeHe rr c</div> </div> </div> <div class="preview-item-container" onclick="window.location.href=''"> <div class="preview-item"> <a href="" class="preview-item-image"><img src="/i/68/2768/3595612737-2768-100.jpg" alt="Piezoelectric Vibrating Gyroscopes (GYROSTARr) 1 Piezoelectric Vibrating Gyroscopes (GYROSTARr)"></a> <div class="preview-title"><a href="">Piezoelectric Vibrating Gyroscopes (GYROSTARr) 1 Piezoelectric Vibrating Gyroscopes (GYROSTARr)</a></div> <div class="preview-text">sales repres•e Tnthaisti vceast aolor gp rhoadsu cotn elyn tgyipniecearl ss pbeecfoifricea otirodnesr ibnegc. ause there is no space for detailed specifications. Therefore, please approve our product specifications or transact the approval sheet for product specifications before ordering. Piezoelect</div> </div> </div> </div> </div> </div> <div class="modal fade" id="modal-download" tabindex="-1" role="dialog" aria-labelledby="download-label"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="download-label">Download Document</h4> </div> <div class="download-form"> <form id="download-form" class="form-horizontal" action="/site/download" method="post" data-onsubmit="app.hideModals();window.location.href='/site/file/2710?crc32=4042975837&type=';" data-onajax="$('#downloadform-verifycode-image').yiiCaptcha('refresh')"> <input type="hidden" name="_csrf" value="GWHxw24aJVnqiJZ1S1FC9epiWgxCwM1TK1mQQQxyAw5fD4b7FFIRCITv9UwnKSzMpk8dSBGZrzZyb9cxWChnXw=="> <input type="hidden" id="downloadform-doc_id" name="DownloadForm[doc_id]" value="2710"> <div class="modal-body"> <div class="modal-description">Please enter verification code to start downloading!</div> <div class="form-group field-downloadform-verifycode"> <div><label class="control-label" for="downloadform-verifycode">Verification code</label></div><div><div class="row"><div class="col-lg-3"><img id="downloadform-verifycode-image" src="/site/captcha?v=64738b8408cb80.08884379" alt=""></div><div class="col-lg-6"><input type="text" id="downloadform-verifycode" class="form-control" name="DownloadForm[verifyCode]"></div></div></div><div><p class="help-block help-block-error "></p></div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" name="submit">Download</button> </div> </form> </div> </div> </div> </div><div class="modal fade" id="modal-abuse" tabindex="-1" role="dialog" aria-labelledby="abuse-label"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="abuse-label">Report a violation</h4> </div> <form id="contact-form" class="form-horizontal" action="/site/abuse" method="post" data-onsubmit="alert("Thank you! Your message has been successfully sent and we will take action as soon as possible!");window.location.href=window.location.href" data-onajax="$('#contactform-verifycode-image').yiiCaptcha('refresh')"> <input type="hidden" name="_csrf" value="GWHxw24aJVnqiJZ1S1FC9epiWgxCwM1TK1mQQQxyAw5fD4b7FFIRCITv9UwnKSzMpk8dSBGZrzZyb9cxWChnXw=="> <div class="modal-body"> <div class="modal-description">We will delete the document within 24 hours after receiving the information about the violation, if the information you provided is enough to make a decision. Spam and messages without sufficient information will be ignored. </div> <div class="form-group field-contactform-name required not-validated"> <div><label class="control-label" for="contactform-doc_id">Document</label></div> <div><a href="">XML Pocket Reference</a></div> </div> <input type="hidden" id="contactform-doc_id" name="ContactForm[doc_id]" value="2710"> <div class="form-group field-contactform-name required"> <div><label class="control-label" for="contactform-name">Your name or company name</label></div><div><input type="text" id="contactform-name" class="form-control" name="ContactForm[name]" autofocus aria-required="true"></div><div><p class="help-block help-block-error "></p></div> </div> <div class="form-group field-contactform-email required"> <div><label class="control-label" for="contactform-email">Email</label></div><div><input type="text" id="contactform-email" class="form-control" name="ContactForm[email]" aria-required="true"></div><div><p class="help-block help-block-error "></p></div> </div> <div class="form-group field-contactform-subject required"> <div><label class="control-label" for="contactform-subject">Subject</label></div><div><select id="contactform-subject" class="form-control" name="ContactForm[subject]" aria-required="true"> <option value="Adult or abusive content">Adult or abusive content</option> <option value="Spam">Spam</option> <option value="Illegal content, you don't have rights to publish this document">Illegal content, you don't have rights to publish this document</option> <option value="Malware content">Malware content</option> <option value="Something else (please provide additional information)">Something else (please provide additional information)</option> </select></div><div><p class="help-block help-block-error "></p></div> </div> <div class="form-group field-contactform-body required"> <div><label class="control-label" for="contactform-body">Additional information</label></div><div><textarea id="contactform-body" class="form-control" name="ContactForm[body]" rows="6" aria-required="true"></textarea></div><div><p class="help-block help-block-error "></p></div> </div> <div class="form-group field-contactform-verifycode"> <div><label class="control-label" for="contactform-verifycode">Verification code</label></div><div><div class="row"><div class="col-lg-3"><img id="contactform-verifycode-image" src="/site/captcha?v=64738b84091792.51051052" alt=""></div><div class="col-lg-6"><input type="text" id="contactform-verifycode" class="form-control" name="ContactForm[verifyCode]"></div></div></div><div><p class="help-block help-block-error "></p></div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" name="contact-button">Report</button> </div> </form> </div> </div> </div> </div> </div> </div> <footer class="footer"> <div class="container"> <p>© DownloadDoc 2023</p> <span> <a href="/terms">Terms and conditions</a> | <a href="/privacy">Privacy policy</a> | <a href="/m/1">Sitemap</a> </span> <p> <!--LiveInternet counter--><script type="text/javascript"> document.write('<a href="//" ' + 'target="_blank"><img src="//;r' + escape(document.referrer) + ((typeof(screen) == 'undefined') ? '' : ';s' + screen.width + '*' + screen.height + '*' + (screen.colorDepth ? screen.colorDepth : screen.pixelDepth)) + ';u' + escape(document.URL) + ';h' + escape(document.title.substring(0, 150)) + ';' + Math.random() + '" alt="" title="LiveInternet" ' + 'border="0" width="31" height="31"><\/a>') </script><!--/LiveInternet--> </p> </div> </footer> <script src="/assets/7a7a083c96a24dbb92f0158cfa976cbb.js"></script> <script>jQuery(function ($) { app.incViews(2710,4042975837); jQuery('#downloadform-verifycode-image').yiiCaptcha({"refreshUrl":"\/site\/captcha?refresh=1","hashKey":"yiiCaptcha\/site\/captcha"}); jQuery('#download-form').yiiActiveForm([{"id":"downloadform-verifycode","name":"verifyCode","container":".field-downloadform-verifycode","input":"#downloadform-verifycode","error":"","enableAjaxValidation":true,"validateOnChange":false,"validateOnBlur":false}], {"validationUrl":"\/site\/download"}); jQuery('#contactform-verifycode-image').yiiCaptcha({"refreshUrl":"\/site\/captcha?refresh=1","hashKey":"yiiCaptcha\/site\/captcha"}); jQuery('#contact-form').yiiActiveForm([{"id":"contactform-name","name":"name","container":".field-contactform-name","input":"#contactform-name","error":"","enableAjaxValidation":true,"validateOnChange":false,"validateOnBlur":false},{"id":"contactform-email","name":"email","container":".field-contactform-email","input":"#contactform-email","error":"","enableAjaxValidation":true,"validateOnChange":false,"validateOnBlur":false},{"id":"contactform-subject","name":"subject","container":".field-contactform-subject","input":"#contactform-subject","error":"","enableAjaxValidation":true,"validateOnChange":false,"validateOnBlur":false},{"id":"contactform-body","name":"body","container":".field-contactform-body","input":"#contactform-body","error":"","enableAjaxValidation":true,"validateOnChange":false,"validateOnBlur":false},{"id":"contactform-verifycode","name":"verifyCode","container":".field-contactform-verifycode","input":"#contactform-verifycode","error":"","enableAjaxValidation":true,"validateOnChange":false,"validateOnBlur":false}], {"validationUrl":"\/site\/abuse"}); jQuery('#search-form').yiiActiveForm([{"id":"searchform-search","name":"search","container":".field-searchform-search","input":"#searchform-search","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"Search cannot be blank."});yii.validation.string(value, messages, {"message":"Search must be a string.","min":2,"tooShort":"Search should contain at least 2 characters.","max":1000,"tooLong":"Search should contain at most 1,000 characters.","skipOnEmpty":1});}}], []); });</script> <script type="text/javascript" src="//"></script> </body> </html>