xsi:nil |
The xsi:nil attribute indicates that a certain element does not have a value or that the value is unknown. This is not the same as having a value that is zero or the empty string. Semantically, it is equivalent to SQL's null. For example, in this full_name element, the last_name child has a nil value:
<full_name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <first_name>Cher</first_name> <last_name xsi:nil="true"/> </full_name>
<xs:element name="last_name" type="xs:string" nillable="true"/>
xsi:noNamespaceSchemaLocation |
The xsi:noNamespaceSchemaLocation attribute locates the schema for elements that are not in any namespace. (Attributes that are not in any namespace are assumed to be declared in the same schema as their parent element.) Its value is a relative or absolute URL where the schema document can be found. It is most commonly attached to the root element but can appear further down the tree. For example, this person element claims that it should be validated against the schema found at the URL http://www.elharo.com/person.xs:
<person xsi:noNamespaceSchemaLocation="http://www.elharo.com/person.xs"> <name> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person>
xsi:schemaLocation |
The xsi:schemaLocation attribute locates schemas for elements and attributes that are in a specified namespace. Its value is a namespace URI followed by a relative or absolute URL where the schema for that namespace can be found. It is most commonly attached to the root element but can appear further down the tree. For example, this person element in the http://www.cafeconleche.org/namespaces/person namespace claims that it should be validated against the schema found at the URL http://www.elharo.com/person.xs:
<person xmlns="http://www.cafeconleche.org/namespaces/person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cafeconleche.org/namespaces/person http://www.elharo.com/person.xs"> <name> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person>
<person xmlns="http://www.cafeconleche.org/namespaces/person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cafeconleche.org/namespaces/person http://www.elharo.com/person.xs http://www.cafeconleche.org/namespaces/names names.xs"> <name xmlns="http://www.cafeconleche.org/namespaces/names"> <first_name>Alan</first_name> <last_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person>
xsi:type |
The xsi:type attribute may be used in instance documents to indicate the type of an element, even when a full schema is not available. For example, this length element has type xs:decimal:
<length xsi:type="xs:decimal">23.5</length>
<transport> <airplane xsi:type="airplane">Boeing 767</airplane> </transport> <transport> <bus xsi:type="bus">Greyhound</bus> </transport>
However, when the xsi:type attributes are removed, these are no longer valid transport elements:
<transport> <airplane>Boeing 767</airplane> </transport> <transport> <bus>Greyhound</bus> </transport>
Copyright © 2002 O'Reilly & Associates. All rights reserved.