7.10. The notation Element

A notation provides a mechanism for an XML validator to locate external programs or processing instructions. An XML validator does not intrinsically validate notations. However, during validation of a corresponding XML instance, a notation must exist for each reference from an element or attribute whose corresponding structure type specifies an enumeration of the built-in notation datatype. While there are no specific requirements, the intention of a notation is that the value for a notation in an XML instance is somehow relevant to URIs specified by the notation.

Each notation must specify a system attribute, a public attribute, or both. The value of a system attribute frequently identifies a file, which might be a program. There is no requirement that the file exists on the parsing machine, or that the file exists at all. The value of a public attribute frequently identifies an external HTTP address. This URI might likewise represent a document or a program such as an Active Server Page (ASP) or JavaServer Page (JSP). Conversely, there is no requirement that the URI can be dereferenced. Note that “public” is relative to the current system: A URI could point to another machine accessible only within the same company.

Listing 7.4 is the XML representation of two notation elements, which specify the location of a Perl and a Python interpreter.

Listing 7.4. A notation Element (built-in.xsd)
<xsd:notation name="perlCode" 
              system="/usr/bin/perl" 
              public="http://www.company.com/runPerl.pl" 
              id="notation.perl"> 
    <xsd:annotation> 
        <xsd:documentation xml:lang="en"> 
            value of corresponding element 
            should contain perl code to execute. 
        </xsd:documentation> 
    </xsd:annotation> 
</xsd:notation>  
<xsd:notation name="pythonCode" 
              system="/usr/bin/python" 
              public="http://www.company.com/runPython.py" 
              id="notation.companyMascot"> 
    <xsd:annotation> 
        <xsd:documentation xml:lang="en"> 
            value of corresponding element 
            should contain python code to execute. 
        </xsd:documentation> 
    </xsd:annotation> 
</xsd:notation> 

Typically, the value associated with a notation is an attribute; the value of the enclosing element is a value that applies to the notation. In the next example, the demoNotation element contains a source attribute. The value of source is ‘perlCode’; the value of the element is a line of Perl code:

<xsd:element name="demoNotation"> 
    <xsd:complexType> 
        <xsd:simpleContent> 
            <xsd:extension base="xsd:string"> 
                <xsd:attribute name="source"> 
                    <xsd:simpleType> 
                        <xsd:restriction base="xsd:notation"> 
                           <xsd:enumeration value="perlCode"/> 
                           <xsd:enumeration value="pythonCode"/> 
                        </xsd:restriction> 
                    </xsd:simpleType> 
                </xsd:attribute> 
            </xsd:extension> 
        </xsd:simpleContent> 
    </xsd:complexType> 
</xsd:element> 

Note

An attribute (the normal scenario) or an element cannot specify a notation as its structure type: The structure type must be a simple type that is an enumeration of other notation simple types.


Given the preceding element type, the following element is valid in a corresponding XML instance:

<demoNotation 
  source="perlCode">print "Hello, World
"</demoNotation> 

7.10.1. Attributes of a notation Element

The attributes of a notation element must specify a name and a way to obtain the corresponding processing instructions. Table 7.11 provides a summary of the attributes for a notation element.

Table 7.11. Attribute Summary for a notation Element
Attribute Description
id The value of an id attribute uniquely identifies an element within the set of schema documents that comprise an XML schema.
name The value of the name attribute is the name of the notation.
public The value of the public attribute is a character string; it may be a URI that represents the location of a corresponding document or program. While by no means a requirement, there is some expectation that the dereferenced URI is available on a system other than the one upon which the XML validator runs.
system The value of the system attribute is a URI that represents the location of a corresponding document or program. While by no means a requirement, there is some expectation that the dereferenced URI is available locally—perhaps a local file.

7.10.1.1. The id Attribute of a notation Element

The value of an id attribute uniquely identifies an element within the set of schema documents that comprise an XML schema.

Attribute Overview

notation: id

Value: An ID.
Default: None.
Constraints: In general, the value of an id must be unique within an XML document. The XML Schema Recommendation further constrains this uniqueness to the entire XML schema.
Required: No.


7.10.1.2. The name Attribute of a notation Element

An XML validator places the value of the name of a notation element in the target namespace. An element or attribute in an XML instance refers to the notation with this name. The element or attribute must have a corresponding element type or attribute type whose structure type specifies an enumeration of built-in notation datatypes. An application that interacts with an XML validator may do anything—or nothing—with the data from the corresponding notation.

Attribute Overview

notation: name

Value: An NCName.
Default: None.
Constraints: No intrinsic constraints. However, there must be a corresponding notation element for each name referenced in an XML instance.
Required: Yes.


7.10.1.3. The public Attribute of a notation Element

The value of the public attribute may be a URI that the XML validator may use as a processing instruction. For example, this URI might be the address of an HTML file or a Java servlet. The schema does not guarantee that the URI can be dereferenced.

Attribute Overview

notation: public

Value: A character string; often a URI.
Default: None.
Constraints: None. In fact, there is no requirement that the URI can be dereferenced.
Required: A notation element must specify either or both of the system or public attributes.


7.10.1.4. The system Attribute of a notation Element

The value of a system attribute is a URI. For example, the path might point to a program to render a graphics file or any other executable program. The schema does not guarantee that the URI can be dereferenced, or if it can, that the dereferenced string has any meaning.

Attribute Overview

notation: system

Value: A URI.
Default: None.
Constraints: None. In fact, the representative file may not exist or may not be accessible on the validating machine.
Required: A notation element must specify either or both of the system or public attributes.


7.10.2. Content Options for a notation Element

Table 7.12 identifies the only content option available to a notation: the ubiquitous annotation element.

Table 7.12. Content Options for a notation Element
Element Description
annotation Provides a way to document schema elements. Section 7.5 demonstrates how to apply annotations.

The content pattern for the notation element follows:

annotation? 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.50.185