Source for org.w3c.dom.TypeInfo

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