1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
/*
* Copyright (c) 2004 World Wide Web Consortium,
*
* (Massachusetts Institute of Technology, European Research Consortium for
* Informatics and Mathematics, Keio University). All Rights Reserved. This
* work is distributed under the W3C(r) Software License [1] in the hope that
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
*/
package org.w3c.dom;
/**
* The <code>TypeInfo</code> interface represents a type referenced from
* <code>Element</code> or <code>Attr</code> nodes, specified in the schemas
* associated with the document. The type is a pair of a namespace URI and
* name properties, and depends on the document's schema.
* <p> If the document's schema is an XML DTD [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>], the values
* are computed as follows:
* <ul>
* <li> If this type is referenced from an
* <code>Attr</code> node, <code>typeNamespace</code> is
* <code>"http://www.w3.org/TR/REC-xml"</code> and <code>typeName</code>
* represents the <b>[attribute type]</b> property in the [<a href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204/'>XML Information Set</a>]
* . If there is no declaration for the attribute, <code>typeNamespace</code>
* and <code>typeName</code> are <code>null</code>.
* </li>
* <li> If this type is
* referenced from an <code>Element</code> node, <code>typeNamespace</code>
* and <code>typeName</code> are <code>null</code>.
* </li>
* </ul>
* <p> If the document's schema is an XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
* , the values are computed as follows using the post-schema-validation
* infoset contributions (also called PSVI contributions):
* <ul>
* <li> If the <b>[validity]</b> property exists AND is <em>"invalid"</em> or <em>"notKnown"</em>: the {target namespace} and {name} properties of the declared type if
* available, otherwise <code>null</code>.
* <p ><b>Note:</b> At the time of writing, the XML Schema specification does
* not require exposing the declared type. Thus, DOM implementations might
* choose not to provide type information if validity is not valid.
* </li>
* <li> If the <b>[validity]</b> property exists and is <em>"valid"</em>:
* <ol>
* <li> If <b>[member type definition]</b> exists:
* <ol>
* <li>If {name} is not absent, then expose {name} and {target
* namespace} properties of the <b>[member type definition]</b> property;
* </li>
* <li>Otherwise, expose the namespace and local name of the
* corresponding anonymous type name.
* </li>
* </ol>
* </li>
* <li> If the <b>[type definition]</b> property exists:
* <ol>
* <li>If {name} is not absent, then expose {name} and {target
* namespace} properties of the <b>[type definition]</b> property;
* </li>
* <li>Otherwise, expose the namespace and local name of the
* corresponding anonymous type name.
* </li>
* </ol>
* </li>
* <li> If the <b>[member type definition anonymous]</b> exists:
* <ol>
* <li>If it is false, then expose <b>[member type definition name]</b> and <b>[member type definition namespace]</b> properties;
* </li>
* <li>Otherwise, expose the namespace and local name of the
* corresponding anonymous type name.
* </li>
* </ol>
* </li>
* <li> If the <b>[type definition anonymous]</b> exists:
* <ol>
* <li>If it is false, then expose <b>[type definition name]</b> and <b>[type definition namespace]</b> properties;
* </li>
* <li>Otherwise, expose the namespace and local name of the
* corresponding anonymous type name.
* </li>
* </ol>
* </li>
* </ol>
* </li>
* </ul>
* <p ><b>Note:</b> Other schema languages are outside the scope of the W3C
* and therefore should define how to represent their type systems using
* <code>TypeInfo</code>.
* <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.
* @since DOM Level 3
*/
public interface TypeInfo {
/**
* The name of a type declared for the associated element or attribute,
* or <code>null</code> if unknown.
*/
public String getTypeName();
/**
* The namespace of the type declared for the associated element or
* attribute or <code>null</code> if the element does not have
* declaration or if no namespace information is available.
*/
public String getTypeNamespace();
// DerivationMethods
/**
* If the document's schema is an XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
* , this constant represents the derivation by <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#key-typeRestriction'>
* restriction</a> if complex types are involved, or a <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-restriction'>
* restriction</a> if simple types are involved.
* <br> The reference type definition is derived by restriction from the
* other type definition if the other type definition is the same as the
* reference type definition, or if the other type definition can be
* reached recursively following the {base type definition} property
* from the reference type definition, and all the <em>derivation methods</em> involved are restriction.
*/
public static final int DERIVATION_RESTRICTION = 0x00000001;
/**
* If the document's schema is an XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
* , this constant represents the derivation by <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#key-typeExtension'>
* extension</a>.
* <br> The reference type definition is derived by extension from the
* other type definition if the other type definition can be reached
* recursively following the {base type definition} property from the
* reference type definition, and at least one of the <em>derivation methods</em> involved is an extension.
*/
public static final int DERIVATION_EXTENSION = 0x00000002;
/**
* If the document's schema is an XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
* , this constant represents the <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-union'>
* union</a> if simple types are involved.
* <br> The reference type definition is derived by union from the other
* type definition if there exists two type definitions T1 and T2 such
* as the reference type definition is derived from T1 by
* <code>DERIVATION_RESTRICTION</code> or
* <code>DERIVATION_EXTENSION</code>, T2 is derived from the other type
* definition by <code>DERIVATION_RESTRICTION</code>, T1 has {variety} <em>union</em>, and one of the {member type definitions} is T2. Note that T1 could be
* the same as the reference type definition, and T2 could be the same
* as the other type definition.
*/
public static final int DERIVATION_UNION = 0x00000004;
/**
* If the document's schema is an XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
* , this constant represents the <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-list'>list</a>.
* <br> The reference type definition is derived by list from the other
* type definition if there exists two type definitions T1 and T2 such
* as the reference type definition is derived from T1 by
* <code>DERIVATION_RESTRICTION</code> or
* <code>DERIVATION_EXTENSION</code>, T2 is derived from the other type
* definition by <code>DERIVATION_RESTRICTION</code>, T1 has {variety} <em>list</em>, and T2 is the {item type definition}. Note that T1 could be the same as
* the reference type definition, and T2 could be the same as the other
* type definition.
*/
public static final int DERIVATION_LIST = 0x00000008;
/**
* This method returns if there is a derivation between the reference
* type definition, i.e. the <code>TypeInfo</code> on which the method
* is being called, and the other type definition, i.e. the one passed
* as parameters.
* @param typeNamespaceArg the namespace of the other type definition.
* @param typeNameArg the name of the other type definition.
* @param derivationMethod the type of derivation and conditions applied
* between two types, as described in the list of constants provided
* in this interface.
* @return If the document's schema is a DTD or no schema is associated
* with the document, this method will always return <code>false</code>
* . If the document's schema is an XML Schema, the method will
* <code>true</code> if the reference type definition is derived from
* the other type definition according to the derivation parameter. If
* the value of the parameter is <code>0</code> (no bit is set to
* <code>1</code> for the <code>derivationMethod</code> parameter),
* the method will return <code>true</code> if the other type
* definition can be reached by recursing any combination of {base
* type definition}, {item type definition}, or {member type
* definitions} from the reference type definition.
*/
public boolean isDerivedFrom(String typeNamespaceArg,
String typeNameArg,
int derivationMethod);
}
|