| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.type; |
| 9 | |
| 10 | import com.saxonica.ee.schema.UserSchemaComponent; |
| 11 | import net.sf.saxon.om.Function; |
| 12 | import net.sf.saxon.value.SequenceType; |
| 13 | |
| 14 | /** |
| 15 | * This is a marker interface that represents any "schema component" as defined in the XML Schema |
| 16 | * specification. This may be a user-defined schema component or a built-in schema component. Since |
| 17 | * all built-in schema components are types, every SchemaComponent in practice is either a |
| 18 | * {@link UserSchemaComponent} or a {@link SchemaType} or both. |
| 19 | */ |
| 20 | public interface SchemaComponent { |
| 21 | |
| 22 | enum ValidationStatus {UNVALIDATED, FIXED_UP, VALIDATING, VALIDATED, INVALID, INCOMPLETE} |
| 23 | |
| 24 | /** |
| 25 | * Get the validation status of this component. |
| 26 | * |
| 27 | * @return one of the values {@link ValidationStatus#UNVALIDATED}, {@link ValidationStatus#VALIDATING}, |
| 28 | * {@link ValidationStatus#VALIDATED}, {@link ValidationStatus#INVALID}, {@link ValidationStatus#INCOMPLETE} |
| 29 | */ |
| 30 | |
| 31 | ValidationStatus getValidationStatus(); |
| 32 | |
| 33 | /** |
| 34 | * Get the redefinition level. This is zero for a component that has not been redefined; |
| 35 | * for a redefinition of a level-0 component, it is 1; for a redefinition of a level-N |
| 36 | * component, it is N+1. This concept is used to support the notion of "pervasive" redefinition: |
| 37 | * if a component is redefined at several levels, the top level wins, but it is an error to have |
| 38 | * two versions of the component at the same redefinition level. |
| 39 | * |
| 40 | * @return the redefinition level |
| 41 | */ |
| 42 | |
| 43 | int getRedefinitionLevel(); |
| 44 | |
| 45 | //#ifdefined SCHEMA |
| 46 | |
| 47 | /** |
| 48 | * Get the schema component in the form of a function item. This allows schema information |
| 49 | * to be made visible to XSLT or XQuery code. The function makes available the contents of the |
| 50 | * schema component as defined in the XSD specification. The function takes a string as argument |
| 51 | * representing a property name, and returns the corresponding property of the schema component. |
| 52 | * There is also a property "class" which returns the kind of schema component, for example |
| 53 | * "Attribute Declaration". |
| 54 | * |
| 55 | * @return the schema component represented as a function from property names to property values. |
| 56 | */ |
| 57 | |
| 58 | Function getComponentAsFunction(); |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * The function type of the function returned by getComponentAsFunction() |
| 63 | */ |
| 64 | |
| 65 | FunctionItemType COMPONENT_FUNCTION_TYPE = |
| 66 | new SpecificFunctionType(new SequenceType[]{SequenceType.SINGLE_STRING}, SequenceType.ANY_SEQUENCE); |
| 67 | //#endif |
| 68 | |
| 69 | } |
| 70 |