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