net.sf.saxon.style
public abstract class StyleElement extends ElementImpl implements Locator, Container, InstructionInfo
Field Summary | |
---|---|
protected String | defaultCollationName |
protected String | defaultXPathNamespace |
protected short[] | extensionNamespaces |
protected int | reportingCircumstances |
static int | REPORT_ALWAYS |
static int | REPORT_IF_INSTANTIATED |
static int | REPORT_UNLESS_FALLBACK_AVAILABLE |
static int | REPORT_UNLESS_FORWARDS_COMPATIBLE |
protected StaticContext | staticContext |
protected XPathException | validationError |
protected BigDecimal | version |
Constructor Summary | |
---|---|
StyleElement()
Constructor |
Method Summary | |
---|---|
protected int | allocateLocationId(String systemId, int lineNumber)
Allocate a location identifier |
void | allocatePatternSlots(int slots)
Allocate space for range variables within predicates in the match pattern. |
void | allocateSlots(Expression exp)
Allocate slots in the local stack frame to range variables used in an XPath expression
|
boolean | backwardsCompatibleModeIsEnabled()
Determine whether backwards-compatible mode is enabled for this element |
XSLVariableDeclaration | bindVariable(StructuredQName qName)
Bind a variable used in this element to the compiled form of the XSLVariable element in which it is
declared |
void | checkEmpty()
Convenience method to check that the stylesheet element is empty
|
protected void | checkSortComesFirst(boolean sortRequired)
Check that among the children of this element, any xsl:sort elements precede any other elements
|
void | checkTopLevel(String errorCode)
Convenience method to check that the stylesheet element is at the top level |
protected void | checkUnknownAttribute(int nc)
Check whether an unknown attribute is permitted.
|
void | checkWithinTemplate()
Check that the stylesheet element is within a sequence constructor
|
abstract Expression | compile(Executable exec)
Compile the instruction on the stylesheet tree into an executable instruction
for use at run-time. |
protected void | compileError(XPathException error)
Report an error with diagnostic information |
protected void | compileError(String message)
Report a static error in the stylesheet |
protected void | compileError(String message, StructuredQName errorCode)
Compile time error, specifying an error code
|
protected void | compileError(String message, String errorCode)
Compile time error, specifying an error code
|
Expression | compileSequenceConstructor(Executable exec, SequenceIterator iter, boolean includeParams)
Compile the children of this instruction on the stylesheet tree, adding the
subordinate instructions to the parent instruction on the execution tree. |
protected void | compileWarning(String message, StructuredQName errorCode) |
protected void | compileWarning(String message, String errorCode) |
protected boolean | definesExcludedNamespace(short uriCode)
Check whether this node excludes a particular namespace from the result.
|
protected boolean | definesExtensionElement(short uriCode)
Check whether a particular extension element namespace is defined on this node.
|
protected Expression | fallbackProcessing(Executable exec, StyleElement instruction)
Perform fallback processing. |
void | fixupReferences()
Fix up references from XPath expressions. |
boolean | forwardsCompatibleModeIsEnabled()
Determine whether forwards-compatible mode is enabled for this element |
List | getAllStylesheetFunctions()
Get a list of all stylesheet functions, excluding any that are masked by one of higher precedence |
protected AttributeSet[] | getAttributeSets(String use, List list)
Get the list of attribute-sets associated with this element.
|
String | getAttributeValue(String clarkName)
Get an attribute value given the Clark name of the attribute (that is,
the name in {uri}local format). |
int | getColumnNumber(long locationId) |
protected ItemType | getCommonChildItemType()
Get the most general type of item returned by the children of this instruction
|
int | getConstructType()
Get the type of construct. |
int | getContainerGranularity()
Get the granularity of the container. |
SlotManager | getContainingSlotManager()
Get the SlotManager for the containing Procedure definition
|
XSLStylesheet | getContainingStylesheet()
Get the containing XSLStylesheet element |
protected String | getDefaultCollationName()
Get the default collation for this stylesheet element. |
protected String | getDefaultXPathNamespace()
Get the default XPath namespace for elements and types |
Executable | getExecutable() |
int | getHostLanguage()
Get the host language (XSLT, XQuery, XPath) used to implement the code in this container |
protected StyleElement | getLastChildInstruction()
Find the last child instruction of this instruction. |
int | getLineNumber(long locationId) |
LocationProvider | getLocationProvider()
Get the LocationProvider allowing location identifiers to be resolved. |
NamespaceResolver | getNamespaceResolver()
Get the namespace context of the instruction. |
StructuredQName | getObjectName()
Get a name identifying the object of the expression, for example a function name, template name,
variable name, key name, element name, etc. |
int | getPrecedence()
Get the import precedence of this stylesheet element. |
PreparedStylesheet | getPreparedStylesheet()
Get the PreparedStylesheet object.
|
XSLStylesheet | getPrincipalStylesheet()
Get the principal XSLStylesheet node. |
Iterator | getProperties()
Get an iterator over all the properties available. |
Object | getProperty(String name)
Get the value of a particular property of the instruction. |
protected ItemType | getReturnedItemType()
Determine the type of item returned by this instruction (only relevant if
it is an instruction). |
SchemaType | getSchemaType(String typeAtt)
Get the Schema type definition for a type named in the stylesheet (in a
"type" attribute). |
StaticContext | getStaticContext()
Get the static context for expressions on this element
|
XSLFunction | getStylesheetFunction(StructuredQName qName, int arity)
Get a FunctionCall declared using an xsl:function element in the stylesheet
|
String | getSystemId(long locationId) |
int | getTypeAnnotation(SchemaType schemaType)
Get the type annotation to use for a given schema type |
BigDecimal | getVersion()
Get the numeric value of the version number on this element,
or inherited from its ancestors |
protected WithParam[] | getWithParamInstructions(Executable exec, boolean tunnel, Instruction caller)
Get the list of xsl:with-param elements for a calling element (apply-templates,
call-template, apply-imports, next-match). |
protected void | index(XSLStylesheet top)
Method supplied by declaration elements to add themselves to a stylesheet-level index |
boolean | isExcludedNamespace(short uriCode)
Check whether a namespace uri defines an namespace excluded from the result.
|
protected boolean | isExplaining()
Determine whether saxon:explain has been set to "yes" |
boolean | isExtensionNamespace(short uriCode)
Check whether a namespace uri defines an extension element. |
boolean | isInstruction()
Determine whether this node is an instruction. |
protected boolean | isPermittedChild(StyleElement child)
Check whether a given child is permitted for this element. |
protected void | issueWarning(TransformerException error)
Report a warning to the error listener |
protected void | issueWarning(String message, SourceLocator locator)
Report a warning to the error listener |
boolean | isTopLevel()
Test whether this is a top-level element |
protected Expression | makeAttributeValueTemplate(String expression)
Make an attribute value template in the context of this stylesheet element |
Expression | makeExpression(String expression)
Compile an XPath expression in the context of this stylesheet element |
ExpressionVisitor | makeExpressionVisitor()
Make an expression visitor |
SavedNamespaceContext | makeNamespaceContext()
Make a NamespaceContext object representing the list of in-scope namespaces. |
Pattern | makePattern(String pattern)
Make a pattern in the context of this stylesheet element |
StructuredQName | makeQName(String lexicalQName)
Make a structured QName, using this Element as the context for namespace resolution, and
registering the code in the namepool. |
SequenceType | makeSequenceType(String sequenceType)
Process an attribute whose value is a SequenceType |
protected SortKeyDefinition[] | makeSortKeys()
Construct sort keys for a SortedIterator
|
protected static TraceWrapper | makeTraceInstruction(StyleElement source, Expression child)
Create a trace instruction to wrap a real instruction |
protected boolean | markTailCalls()
Mark tail-recursive calls on templates and functions.
|
protected boolean | mayContainFallback()
Determine whether this type of element is allowed to contain an xsl:fallback
instruction. |
protected boolean | mayContainParam(String attName)
Determine whether this type of element is allowed to contain an xsl:param element |
protected boolean | mayContainSequenceConstructor()
Determine whether this type of element is allowed to contain a sequence constructor |
void | postValidate()
Hook to allow additional validation of a parent element immediately after its
children have been validated. |
protected abstract void | prepareAttributes()
Set the attribute list for the element. |
protected void | processAllAttributes()
Process the attributes of this element and all its children |
protected void | processAttributes()
Process the attribute list for the element. |
protected void | processDefaultCollationAttribute(String ns)
Process the [xsl:]default-xpath-namespace attribute if there is one
|
protected void | processDefaultXPathNamespaceAttribute(String ns)
Process the [xsl:]xpath-default-namespace attribute if there is one
|
protected void | processExcludedNamespaces(String ns)
Process the [xsl:]exclude-result-prefixes attribute if there is one
|
protected void | processExtensionElementAttribute(String ns)
Process the [xsl:]extension-element-prefixes attribute if there is one |
void | processStandardAttributes(String namespace)
Process the standard attributes such as [xsl:]default-collation |
protected void | processVersionAttribute(String ns)
Process the [xsl:]version attribute if there is one
|
boolean | replaceSubExpression(Expression original, Expression replacement)
Replace one subexpression by a replacement subexpression |
void | reportAbsence(String attribute)
Convenience method to report the absence of a mandatory attribute |
protected boolean | seesAvuncularVariables()
Ask whether variables declared in an "uncle" element are visible. |
void | setObjectName(StructuredQName qName)
Set the object name, for example the name of a function, variable, or template declared on this element |
void | setValidationError(TransformerException reason, int circumstances)
Set a validation error. |
void | substituteFor(StyleElement temp)
Make this node a substitute for a temporary one previously added to the tree. |
Expression | typeCheck(String name, Expression exp)
Type-check an expression. |
Pattern | typeCheck(String name, Pattern pattern)
Type-check a pattern. |
protected void | undeclaredNamespaceError(String prefix, String errorCode) |
void | validate()
Check that the stylesheet element is valid. |
protected void | validateChildren()
Validate the children of this node, recursively. |
void | validateSubtree()
Recursive walk through the stylesheet to validate all nodes |
Parameters: systemId identifies the module containing the instruction lineNumber the line number of the instruction
Returns: an integer location ID which can be used to report the location of the instruction, by reference to a LocationProvider
Parameters: slots the number of slots required
Parameters: exp the XPath expression for which slots are to be allocated
Returns: true if backwards compatable mode is enabled, that is, if this or an enclosing element specifies [xsl:]version="1.0"
Parameters: qName The name of the variable
Returns: the XSLVariableDeclaration (that is, an xsl:variable or xsl:param instruction) for the variable, or null if no declaration of the variable can be found
Throws: XPathException if it is not empty
Parameters: sortRequired true if there must be at least one xsl:sort element
Throws: XPathException if invalid
Parameters: errorCode the error to throw if it is not at the top level; defaults to XTSE0010 if the value is null
Throws: XPathException if not at top level
Parameters: nc The name code of the attribute name
Throws: XPathException (and reports the error) if this is an attribute that is not permitted on the containing element
Throws: XPathException if not within a sequence constructor
Parameters: exec the Executable
Returns: either a ComputedExpression, or null. The value null is returned when compiling an instruction that returns a no-op, or when compiling a top-level object such as an xsl:template that compiles into something other than an instruction.
Parameters: error contains information about the error
Throws: XPathException always, after reporting the error to the ErrorListener
Parameters: message the error message
Throws: XPathException always, after reporting the error to the ErrorListener
Parameters: message the error message errorCode the error code. May be null if not known or not defined
Throws: XPathException
Parameters: message the error message errorCode the error code. May be null if not known or not defined
Throws: XPathException
Parameters: exec the Executable iter Iterator over the children. This is used in the case where there are children that are not part of the sequence constructor, for example the xsl:sort children of xsl:for-each; the iterator can be positioned past such elements. includeParams true if xsl:param elements are to be treated as child instructions (true for templates but not for functions)
Returns: an Expression tree representing the children of this instruction
Parameters: uriCode the code of the namespace URI being tested
Returns: true if the namespace is excluded by virtue of an [xsl:]exclude-result-prefixes attribute
Parameters: uriCode the namespace URI code being tested
Returns: true if this namespace is defined on this element as an extension element namespace
Parameters: exec the Executable instruction The unknown extension instruction
Returns: the expression tree representing the fallback code
Returns: true if forwards-compatible mode is enabled
Returns: a list of all stylesheet functions. The members of the list are instances of class XSLFunction
Parameters: use the original value of the [xsl:]use-attribute-sets attribute list an empty list to hold the list of XSLAttributeSet elements in the stylesheet tree. Or null, if these are not required.
Returns: an array of AttributeList instructions representing the compiled attribute sets
Parameters: clarkName the name of the attribute in {uri}local format
Returns: the value of the attribute if it exists, or null otherwise
Returns: the lowest common supertype of the item types returned by the children
Returns: 0 for a temporary container created during parsing; 1 for a container that operates at the level of an XPath expression; 2 for a container at the level of a global function or template
Returns: the SlotManager associated with the containing Function, Template, etc, or null if there is no such containing Function, Template etc.
Returns: the XSLStylesheet element representing the outermost element of the containing stylesheet module. Exceptionally, return null if there is no containing XSLStylesheet element
Returns: the name of the default collation
Returns: the default namespace for elements and types. Return NULL for the non-namespace
Returns: the last child instruction, or null if there are no child instructions
Returns: the namespace context. This method does not make a copy of the namespace context, so a reference to the returned NamespaceResolver will lock the stylesheet tree in memory.
Returns: the name of the object declared in this element, if any
Returns: the import precedence. The actual numeric value is arbitrary, but a higher number indicates a higher precedence.
Returns: the PreparedStylesheet to which this stylesheet element belongs. Exceptionally (with early errors in a simplified stylesheet module) return null.
Returns: the xsl:stylesheet element at the root of the principal stylesheet module. Exceptionally (with early errors in a simplified stylesheet module) return null.
Parameters: name The name of the required property
Returns: The value of the requested property, or null if the property is not available
Returns: the item type returned
Parameters: typeAtt the value of the type attribute
Returns: the corresponding schema type
Throws: XPathException if the type is not declared in an imported schema, or is not a built-in type
Returns: the static context
Parameters: qName the name of the function arity the number of arguments in the function call. The value -1 indicates that any arity will do (this is used to support the function-available() function).
Returns: the XSLFunction object representing the function declaration in the stylesheet, or null if no such function is defined.
Parameters: schemaType the schema type
Returns: the corresponding numeric type annotation
Returns: the version number as a decimal
Parameters: exec the Executable tunnel true if the tunnel="yes" parameters are wanted, false to get caller the calling instruction (for example xsl:apply-templates
Returns: an array of WithParam objects for either the ordinary parameters or the tunnel parameters
Parameters: top the outermost XSLStylesheet element
Parameters: uriCode the code of the namespace URI being tested
Returns: true if this namespace URI is a namespace excluded by virtue of exclude-result-prefixes on this element or on an ancestor element
Returns: true if saxon:explain has been set to "yes" on this element
Parameters: uriCode the namespace URI code being tested
Returns: true if the URI is an extension element namespace URI
Returns: true if this element is an instruction
Parameters: child the child that may or may not be permitted
Returns: true if the child is permitted.
Parameters: error an exception containing the warning text
Parameters: message the warning message text locator the location of the problem in the source stylesheet
Returns: true if the element is a child of the xsl:stylesheet element
Parameters: expression the source text of the attribute value template
Returns: a compiled XPath expression that computes the value of the attribute (including concatenating the results of embedded expressions with any surrounding fixed text)
Parameters: expression the source text of the XPath expression
Returns: the compiled expression tree for the XPath expression
Returns: the expression visitor
Returns: a copy of the namespace context
Parameters: pattern the source text of the pattern
Returns: the compiled pattern
Parameters: lexicalQName The lexical QName as written, in the form "[prefix:]localname". The name must have already been validated as a syntactically-correct QName. Leading and trailing whitespace will be trimmed
Returns: the StructuredQName representation of this lexical QName
Throws: XPathException if the qname is not a lexically-valid QName, or if the name is in a reserved namespace. NamespaceException if the prefix of the qname has not been declared
Parameters: sequenceType the source text of the attribute
Returns: the processed sequence type
Throws: XPathException if the syntax is invalid or for example if it refers to a type that is not in the static context
Returns: an array of SortKeyDefinition objects if there are any sort keys; or null if there are none.
Parameters: source the parent element child the compiled expression tree for the instruction to be traced
Returns: a wrapper instruction that performs the tracing (if activated at run-time)
Returns: true if one or more tail calls were identified
Returns: true if this element is allowed to contain an xsl:fallback
Parameters: attName if null, the method tests whether an xsl:param child is allowed. If non-null, it tests whether an xsl:param child with the given attribute name is allowed
Returns: true if this element is allowed to contain an xsl:param
Returns: true if this instruction is allowed to contain a sequence constructor
Throws: XPathException in the event of a static error being detected
Parameters: ns the namespace of the attribute required, either the XSLT namespace or ""
Parameters: ns the namespace URI of the attribute required (the default namespace or the XSLT namespace.)
Parameters: ns the namespace URI of the attribute required, either the XSLT namespace or ""
Parameters: ns the namespace URI of the attribute - either the XSLT namespace or "" for the null namespace
Parameters: namespace either "" to find the attributes in the null namespace, or NamespaceConstant.XSLT to find them in the XSLT namespace
Parameters: ns the namespace URI of the attribute required, either the XSLT namespace or ""
Parameters: original the original subexpression replacement the replacement subexpression
Returns: true if the original subexpression is found
Parameters: attribute the name of the attribute whose absence is to be reported
Throws: XPathException if the attribute is missing
Returns: true for all elements except xsl:fallback and saxon:catch
Parameters: qName the object name as a QName
Parameters: reason the details of the error circumstances a code identifying the circumstances under which the error is to be reported
Parameters: temp the element which this one is substituting for
Parameters: name the name of the attribute containing the expression to be checked (used for diagnostics) exp the expression to be checked
Returns: the (possibly rewritten) expression after type checking
Parameters: name the name of the attribute holding the pattern, for example "match": used in diagnostics pattern the compiled pattern
Returns: the original pattern, or a substitute pattern if it has been rewritten