001 /*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003 *
004 * This code is free software; you can redistribute it and/or modify it
005 * under the terms of the GNU General Public License version 2 only, as
006 * published by the Free Software Foundation. Sun designates this
007 * particular file as subject to the "Classpath" exception as provided
008 * by Sun in the LICENSE file that accompanied this code.
009 *
010 * This code is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
013 * version 2 for more details (a copy is included in the LICENSE file that
014 * accompanied this code).
015 *
016 * You should have received a copy of the GNU General Public License version
017 * 2 along with this work; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019 *
020 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021 * CA 95054 USA or visit www.sun.com if you need additional information or
022 * have any questions.
023 */
024
025 /*
026 * This file is available under and governed by the GNU General Public
027 * License version 2 only, as published by the Free Software Foundation.
028 * However, the following notice accompanied the original version of this
029 * file and, per its terms, should not be removed:
030 *
031 * Copyright (c) 2004 World Wide Web Consortium,
032 *
033 * (Massachusetts Institute of Technology, European Research Consortium for
034 * Informatics and Mathematics, Keio University). All Rights Reserved. This
035 * work is distributed under the W3C(r) Software License [1] in the hope that
036 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
037 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
038 *
039 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
040 */
041
042 package org.w3c.dom;
043
044 /**
045 * The <code>TypeInfo</code> interface represents a type referenced from
046 * <code>Element</code> or <code>Attr</code> nodes, specified in the schemas
047 * associated with the document. The type is a pair of a namespace URI and
048 * name properties, and depends on the document's schema.
049 * <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
050 * are computed as follows:
051 * <ul>
052 * <li> If this type is referenced from an
053 * <code>Attr</code> node, <code>typeNamespace</code> is
054 * <code>"http://www.w3.org/TR/REC-xml"</code> and <code>typeName</code>
055 * 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>]
056 * . If there is no declaration for the attribute, <code>typeNamespace</code>
057 * and <code>typeName</code> are <code>null</code>.
058 * </li>
059 * <li> If this type is
060 * referenced from an <code>Element</code> node, <code>typeNamespace</code>
061 * and <code>typeName</code> are <code>null</code>.
062 * </li>
063 * </ul>
064 * <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>]
065 * , the values are computed as follows using the post-schema-validation
066 * infoset contributions (also called PSVI contributions):
067 * <ul>
068 * <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
069 * available, otherwise <code>null</code>.
070 * <p ><b>Note:</b> At the time of writing, the XML Schema specification does
071 * not require exposing the declared type. Thus, DOM implementations might
072 * choose not to provide type information if validity is not valid.
073 * </li>
074 * <li> If the <b>[validity]</b> property exists and is <em>"valid"</em>:
075 * <ol>
076 * <li> If <b>[member type definition]</b> exists:
077 * <ol>
078 * <li>If {name} is not absent, then expose {name} and {target
079 * namespace} properties of the <b>[member type definition]</b> property;
080 * </li>
081 * <li>Otherwise, expose the namespace and local name of the
082 * corresponding anonymous type name.
083 * </li>
084 * </ol>
085 * </li>
086 * <li> If the <b>[type definition]</b> property exists:
087 * <ol>
088 * <li>If {name} is not absent, then expose {name} and {target
089 * namespace} properties of the <b>[type definition]</b> property;
090 * </li>
091 * <li>Otherwise, expose the namespace and local name of the
092 * corresponding anonymous type name.
093 * </li>
094 * </ol>
095 * </li>
096 * <li> If the <b>[member type definition anonymous]</b> exists:
097 * <ol>
098 * <li>If it is false, then expose <b>[member type definition name]</b> and <b>[member type definition namespace]</b> properties;
099 * </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, int derivationMethod);
212
213 }
|