XML technologies / XML / XML in a Nutshell / DOM reference / Object reference / TypeInfo

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

Starting with DOM Level 3, Element and Attr nodes include a schemaTypeInfo attribute that can reference a TypeInfo object. For valid XML documents, it provides information about an element’s or attribute’s declared datatype. Since DOM is intended to be parser-independent, the object’s contents depend on the schema validation performed, such as XML DTD, XML Schema, RELAX NG and so on. The DOM Level 3 Core specification details the meaning of the typeName and typeNamespace attributes for DTDs and XML schemas.

 

Attributes

The object TypeInfo has the following attributes:

 

typeName: DOMString (3)

Returns the declared type name of the element or attribute, depending on the validation method. Returns null, if the type name is unknown. Read-only.

Java binding
public String getTypeName( );

 

typeNamespace: DOMString (3)

Returns the namespace URI of the type specified by the typeName attribute. An attribute validated against the type xs:date has, for example, the namespace "http://www.w3.org/2001/XMLSchema". Read-only.

Java binding
public String getTypeNamespace( );

 

Method

The following method is defined for this object:

 

isDerivedFrom: typeNamespaceArg, typeNameArg, derivationMethod (3)

This method determines the relationship between the target datatype and another datatype, specified by the arguments typeNameArg and typeNamespaceArg. The method returns true, if the target datatype is derived from another datatype by a method specified in the bitmask argument derivationMethod. Otherwise, it returns false. Currently, this method is defined only for validation using an XML schema.

Arguments

  • typeNamespaceArg: DOMString

    The namespace associated with the argument typeNameArg.

  • typeNameArg: DOMString

    The type name to compare with the target type.

  • derivationMethod: unsigned long

    A bitmask specifying the derivation kinds recognized by the method. Valid bitmask values are listed below:

Konstantenname

Wert

Bedeutung

DERIVATION_RESTRICTION

0x00000001

Der Zieltyp ist vom anderen Typ durch Einschränkung der möglichen Werte abgeleitet. (Ein positiver Integer wurde z.B. von einem vorzeichenbehafteten Integer abgeleitet, indem er auf nicht-negative Werte beschränkt wurde.)

DERIVATION_EXTENSION

0x00000002

Der Zieltyp ist vom anderen Typ durch Erweiterung der möglichen Werte abgeleitet. (So wäre ein vorzeichenbehafteter Integer eine Erweiterung eines vorzeichenlosen Integers.)

DERIVATION_UNION

0x00000004

Der Zieltyp ist durch Einschluss in eine Union teilweise vom anderen Typ abgeleitet.

DERIVATION_LIST

0x00000008

Der Zieltyp ist eine Liste mit Elementen des anderen Typs.

Java binding
public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod);

  

 

 

 

back to top