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