001: package net.sf.saxon.expr;
002:
003: import net.sf.saxon.Configuration;
004: import net.sf.saxon.type.AtomicType;
005: import net.sf.saxon.functions.FunctionLibrary;
006: import net.sf.saxon.instruct.LocationMap;
007: import net.sf.saxon.om.NamePool;
008: import net.sf.saxon.om.NamespaceResolver;
009: import net.sf.saxon.trans.StaticError;
010: import net.sf.saxon.trans.XPathException;
011:
012: import javax.xml.transform.SourceLocator;
013: import java.util.Comparator;
014: import java.util.Set;
015:
016: /**
017: * A StaticContext contains the information needed while an expression or pattern
018: * is being parsed. The information is also sometimes needed at run-time.
019: */
020:
021: public interface StaticContext {
022:
023: /**
024: * Get the system configuration
025: */
026:
027: public Configuration getConfiguration();
028:
029: /**
030: * Construct a dynamic context for early evaluation of constant subexpressions
031: */
032:
033: public XPathContext makeEarlyEvaluationContext();
034:
035: /**
036: * Get the location map. This is a mapping from short location ids held with each expression or
037: * subexpression, to a fully-resolved location in a source stylesheet or query.
038: */
039:
040: public LocationMap getLocationMap();
041:
042: /**
043: * Issue a compile-time warning
044: */
045:
046: public void issueWarning(String s, SourceLocator locator);
047:
048: /**
049: * Get the System ID of the container of the expression. This is the containing
050: * entity (file) and is therefore useful for diagnostics. Use getBaseURI() to get
051: * the base URI, which may be different.
052: */
053:
054: public String getSystemId();
055:
056: /**
057: * Get the line number of the expression within its containing entity
058: * Returns -1 if no line number is available
059: */
060:
061: public int getLineNumber();
062:
063: /**
064: * Get the Base URI of the stylesheet element, for resolving any relative URI's used
065: * in the expression.
066: * Used by the document(), doc(), resolve-uri(), and base-uri() functions.
067: * May return null if the base URI is not known.
068: */
069:
070: public String getBaseURI();
071:
072: /**
073: * Get the URI for a namespace prefix. The default namespace is NOT used
074: * when the prefix is empty.
075: * @param prefix The prefix
076: * @throws XPathException if the prefix is not declared
077: */
078:
079: public String getURIForPrefix(String prefix) throws XPathException;
080:
081: /**
082: * Get the NamePool used for compiling expressions
083: */
084:
085: public NamePool getNamePool();
086:
087: /**
088: * Bind a variable used in this element to the XSLVariable element in which it is declared
089: * @param fingerprint the name of the variable
090: * @return a VariableReference representing the variable reference, suitably initialized
091: * to refer to the corresponding variable declaration
092: */
093:
094: public VariableReference bindVariable(int fingerprint)
095: throws StaticError;
096:
097: /**
098: * Get the function library containing all the in-scope functions available in this static
099: * context
100: */
101:
102: public FunctionLibrary getFunctionLibrary();
103:
104: /**
105: * Get a named collation.
106: * @param name The name of the required collation. Supply null to get the default collation.
107: * @return the collation; or null if the required collation is not found.
108: */
109:
110: public Comparator getCollation(String name);
111:
112: /**
113: * Get the name of the default collation.
114: * @return the name of the default collation; or the name of the codepoint collation
115: * if no default collation has been defined
116: */
117:
118: public String getDefaultCollationName();
119:
120: /**
121: * Get the default XPath namespace, as a namespace code that can be looked up in the NamePool
122: */
123:
124: public short getDefaultElementNamespace();
125:
126: /**
127: * Get the default function namespace
128: */
129:
130: public String getDefaultFunctionNamespace();
131:
132: /**
133: * Determine whether Backwards Compatible Mode is used
134: */
135:
136: public boolean isInBackwardsCompatibleMode();
137:
138: /**
139: * Determine whether a Schema for a given target namespace has been imported. Note that the
140: * in-scope element declarations, attribute declarations and schema types are the types registered
141: * with the (schema-aware) configuration, provided that their namespace URI is registered
142: * in the static context as being an imported schema namespace. (A consequence of this is that
143: * within a Configuration, there can only be one schema for any given namespace, including the
144: * null namespace).
145: */
146:
147: public boolean isImportedSchema(String namespace);
148:
149: /**
150: * Get the set of imported schemas
151: * @return a Set, the set of URIs representing the names of imported schemas
152: */
153:
154: public Set getImportedSchemaNamespaces();
155:
156: /**
157: * Determine whether a built-in type is available in this context. This method caters for differences
158: * between host languages as to which set of types are built in.
159: * @param type the supposedly built-in type. This will always be a type in the
160: * XS or XDT namespace.
161: * @return true if this type can be used in this static context
162: */
163:
164: public boolean isAllowedBuiltInType(AtomicType type);
165:
166: /**
167: * Get a namespace resolver to resolve the namespaces declared in this static context.
168: * @return a namespace resolver.
169: */
170:
171: NamespaceResolver getNamespaceResolver();
172:
173: }
174:
175: //
176: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
177: // you may not use this file except in compliance with the License. You may obtain a copy of the
178: // License at http://www.mozilla.org/MPL/
179: //
180: // Software distributed under the License is distributed on an "AS IS" basis,
181: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
182: // See the License for the specific language governing rights and limitations under the License.
183: //
184: // The Original Code is: all this file.
185: //
186: // The Initial Developer of the Original Code is Michael H. Kay.
187: //
188: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
189: //
190: // Contributor(s): none.
191: //
|