Package net.sf.saxon.style
Class StyleElement
java.lang.Object
net.sf.saxon.tree.linked.NodeImpl
net.sf.saxon.tree.linked.ParentNodeImpl
net.sf.saxon.tree.linked.ElementImpl
net.sf.saxon.style.StyleElement
- All Implemented Interfaces:
Source
,SourceLocator
,ActiveSource
,GroundedValue
,Item
,MutableNodeInfo
,NamespaceResolver
,NodeInfo
,Sequence
,Location
,SteppingNode
,SiblingCountingNode
,Locator
- Direct Known Subclasses:
AbsentExtensionElement
,ExtensionInstruction
,IXSLPromise
,IXSLRemoveAttribute
,IXSLRemoveProperty
,IXSLScheduleAction
,IXSLSetAttribute
,IXSLSetProperty
,IXSLSetStyle
,LiteralResultElement
,SaxonImportQuery
,SQLColumn
,XSLAcceptExpose
,XSLAccumulator
,XSLAccumulatorRule
,XSLAnalyzeString
,XSLApplyImports
,XSLApplyTemplates
,XSLAssert
,XSLAttributeSet
,XSLBreakOrContinue
,XSLCallTemplate
,XSLCatch
,XSLCharacterMap
,XSLChooseOrSwitch
,XSLContextItem
,XSLCopy
,XSLCopyOf
,XSLDecimalFormat
,XSLDocument
,XSLElement
,XSLEvaluate
,XSLFallback
,XSLForEach
,XSLForEachGroup
,XSLFork
,XSLFunction
,XSLGeneralIncorporate
,XSLGeneralVariable
,XSLGlobalVariable
,XSLIf
,XSLImportSchema
,XSLItemType
,XSLIterate
,XSLKey
,XSLLeafNodeConstructor
,XSLMap
,XSLMapEntry
,XSLMatchingSubstring
,XSLMerge
,XSLMergeAction
,XSLMergeSource
,XSLMessage
,XSLMode
,XSLModuleRoot
,XSLNamespaceAlias
,XSLNextMatch
,XSLNumber
,XSLOnCompletion
,XSLOtherwise
,XSLOutput
,XSLOutputCharacter
,XSLOverride
,XSLPerformSort
,XSLPreserveSpace
,XSLResultDocument
,XSLSequence
,XSLSortOrMergeKey
,XSLSourceDocument
,XSLTemplate
,XSLTry
,XSLUsePackage
,XSLWhen
,XSLWherePopulated
Abstract superclass for all element nodes in the stylesheet.
Note: this class implements Locator. The element retains information about its own location in the stylesheet, which is useful when an XSLT static error is found.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
protected int
protected String
protected StructuredQName
protected NamespaceUri
protected boolean
protected NamespaceUri[]
protected StyleElement.OnFailure
protected ExpressionContext
protected XmlProcessingIncident
protected int
static final String[]
Fields inherited from class net.sf.saxon.tree.linked.NodeImpl
NODE_LETTER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Location
Allocate a locationbindLocalVariable
(StructuredQName variableName, StructuredQName attributeName) Bind a variable reference used in this element to the compiled form of the XSLVariable element in which it is declared, considering only local variables and paramsbindVariable
(StructuredQName variableName, StructuredQName attributeName) Bind a variable used in this element to the compiled form of the XSLVariable element in which it is declaredvoid
Convenience method to check that the stylesheet element is emptyvoid
checkTopLevel
(String errorCode, boolean allowOverride) Convenience method to check that the stylesheet element is at the top level (that is, as a child of xsl:stylesheet or xsl:transform)protected void
Check whether an unknown attribute is permitted.compile
(Compilation compilation, ComponentDeclaration decl) Compile the instruction on the stylesheet tree into an executable instruction for use at run-time.void
compileDeclaration
(Compilation compilation, ComponentDeclaration decl) Compile a declaration in the stylesheet tree for use at run-time.void
compileError
(String message) Report a static error in the stylesheetvoid
compileError
(String message, String errorCode) Compile time error, specifying an error codevoid
compileError
(String message, String errorCode, Location loc) void
compileError
(String message, StructuredQName errorCode) Compile time error, specifying an error codevoid
compileError
(XmlProcessingError error) Report an error with diagnostic informationvoid
void
compileErrorInAttribute
(String message, String errorCode, String attributeName) Compile time error, specifying an error code and the name of the attribute that is in error.void
compileErrorInAttribute
(XPathException ex, String attributeName) compileSequenceConstructor
(Compilation compilation, ComponentDeclaration decl, boolean includeParams) Compile the children of this instruction on the stylesheet tree, adding the subordinate instructions to the parent instruction on the execution tree.compileSequenceConstructor
(Compilation compilation, ComponentDeclaration decl, 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.void
compileWarning
(String message, String errorCode) void
compileWarning
(String message, StructuredQName errorCode) void
Fix up references from XPath expressions.protected String
getAttributeValue
(String clarkName) Get an attribute value given the Clark name of the attribute (that is, the name in {uri}local format).Get the base URI of the element, which acts as the static base URI for XPath expressions defined on this element.Ask whether this element contains a binding for a variable with a given name; and if it does, return the source binding informationGet the configurationGet the containing package (the principal stylesheet module of the package in which this XSLT element appears)Get the SlotManager for the containing Procedure definitionGet the visibility of the component.protected String
Get the default collation for this stylesheet element.Get the default XPath namespace for elements and typesGet the namespace context of the instruction.Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.Get the principal stylesheet module of the package in which this XSLT element appearsGet an iterator over all the properties available.getSchemaType
(String typeAtt) Get the Schema type definition for a type named in the stylesheet (in a "type" attribute).Get the static context for expressions on this elementgetStaticContext
(StructuredQName attributeName) getTypeAnnotation
(SchemaType schemaType) Get the type annotation to use for a given schema typeAssuming this is an xsl:use-package element, find the package to which it refers.Get the visibility of the component.getWithParamInstructions
(Expression parent, Compilation compilation, ComponentDeclaration decl, boolean tunnel) Get the list of xsl:with-param elements for a calling element (apply-templates, call-template, apply-imports, next-match).getXslOriginal
(int componentKind) Check that a reference to xsl:original appears within an xsl:override element, and that the name of the containing component matches the name of a component in the used stylesheet package; return the component in that package with matching symbolic nameprotected SourceBinding
hasImplicitBinding
(StructuredQName variableName, StructuredQName attributeName) Ask whether this particular element implicitly binds a given variable (used for xsl:accumulator-rule)void
index
(ComponentDeclaration decl, PrincipalStylesheetModule top) Method supplied by declaration elements to add themselves to a stylesheet-level indexprotected void
invalidAttribute
(String attributeName, String allowedValues) boolean
Ask whether this node is a declaration, that is, a permitted child of xsl:stylesheet (including xsl:include and xsl:import).protected boolean
isExtensionAttributeAllowed
(String attribute) Ask if an extension attribute is allowed; if no Professional Edition license is available, issue a warning saying the attribute is ignored, and return falseboolean
Check whether a namespace uri defines an extension element.boolean
Ask whether this node is an instruction.boolean
Ask whether the element is in the XSLT namespacestatic boolean
Ask whether an attribute is "no" or one of its accepted synonymsprotected boolean
isPermittedChild
(StyleElement child) Check whether a given child is permitted for this element.boolean
Ask whether the code is compiled in schema-aware modevoid
issueWarning
(String message, String errorCode) void
issueWarning
(String message, String errorCode, Location locator) Report a warning to the error listenerboolean
Test whether this is a top-level elementprotected boolean
static boolean
Ask whether an attribute is "yes" or one of its accepted synonymsprotected Expression
makeAttributeValueTemplate
(String expression, AttributeInfo att) Make an attribute value template in the context of this stylesheet elementmakeExpression
(String expression, AttributeInfo att) Compile an XPath expression in the context of this stylesheet elementMake an expression visitorfinal StructuredQName
Make a structured QName, using this Element as the context for namespace resolution.makeSequenceType
(String sequenceType) Process an attribute whose value is a SequenceTypeprotected Expression
mapToSequence
(Expression mapExpr) Adapt an expression that returns a map to one that returns a representation of the map as a sequence of two-entry maps containing the "key" and "value" fields, as required for the proposed XSLT 4.0 xsl:for-each/iterate instructions with a "map" attributeprotected boolean
Mark tail-recursive calls on templates and functions.protected boolean
Determine whether this type of element is allowed to contain an xsl:fallback instruction.protected boolean
Determine whether this type of element is allowed to contain an xsl:param elementprotected boolean
Determine whether this type of element is allowed to contain a sequence constructorvoid
Hook to allow additional validation of a parent element immediately after its children have been validated.protected abstract void
Set the attribute list for the element.void
Process the attributes of this element and all its childrenprotected final void
Process the attribute list for the element.boolean
processBooleanAttribute
(String name, String value) Process an attribute whose value is yes, no, true, false, 1, or 0; returning true or false.void
processStandardAttributes
(NamespaceUri namespace) Process the standard attributes such as[xsl:]expand-text
.protected void
Process the [xsl:]version attribute if there is onevoid
reportAbsence
(String attribute) Convenience method to report the absence of a mandatory attributeprotected boolean
requireXslt40Attribute
(String attributeName) Report an error unless XSLT 4.0 syntax is enabled in the XSLT compilerprotected void
Report an error unless XSLT 4.0 syntax is enabled in the XSLT compilerprotected boolean
Ask whether variables declared in an "uncle" element are visible.void
setCompilation
(Compilation compilation) protected static void
setInstructionLocation
(StyleElement source, Expression child) Set location information on a compiled instructionvoid
setObjectName
(StructuredQName qName) Set the object name, for example the name of a function, variable, or template declared on this elementvoid
setValidationError
(XmlProcessingIncident reason, StyleElement.OnFailure circumstances) Set a validation error.void
substituteFor
(StyleElement temp) Make this node a substitute for a temporary one previously added to the tree.typeCheck
(String name, Expression exp) Type-check an expression.Type-check a pattern.void
validate
(ComponentDeclaration decl) Check that the stylesheet element is valid.protected void
validateChildren
(ComponentDeclaration decl, boolean excludeStylesheet) Validate the children of this node, recursively.void
validateSubtree
(ComponentDeclaration decl, boolean excludeStylesheet) Recursive walk through the stylesheet to validate all nodesprotected int
Validate the value of the [xsl:]validation attributeMethods inherited from class net.sf.saxon.tree.linked.ElementImpl
addAttribute, addNamespace, addNamespace, attributes, checkNotNamespaceSensitiveElement, copy, delete, fixupInsertedNamespaces, generateId, getAllNamespaces, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getLineNumber, getNodeKind, getNodeName, getRoot, getSchemaType, getSystemId, getURIForPrefix, initialise, isId, isIdref, isIdRefNode, isInScopeNamespace, isNilled, iteratePrefixes, removeAttribute, removeNamespace, removeTypeAnnotation, rename, replaceStringValue, setAttributeInfo, setAttributes, setLocation, setNamespaceMap, setNilled, setNodeName, setSystemId, setTypeAnnotation
Methods inherited from class net.sf.saxon.tree.linked.ParentNodeImpl
addChild, compact, getFirstChild, getLastChild, getNthChild, getNumberOfChildren, getRawSequenceNumber, getSequenceNumber, getUnicodeStringValue, hasChildNodes, insertChildren, insertChildrenAt, iterateChildren, removeChild, replaceChildrenAt, setChildren, setRawSequenceNumber
Methods inherited from class net.sf.saxon.tree.linked.NodeImpl
atomize, compareOrder, effectiveBooleanValue, equals, getDisplayName, getFingerprint, getLocalPart, getNamePool, getNamespaceUri, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getRawParent, getSiblingPosition, getSuccessorElement, getTreeInfo, hasFingerprint, hashCode, head, insertSiblings, isDeleted, iterateAxis, iterateAxis, newBuilder, replace, saveLocation, setRawParent, setSiblingPosition
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.NodeInfo
asActiveSource, children, children, deliver, getAttributeValue, getGenre, getPublicId, getURI, isSameNodeInfo, isStreamed, toShortString
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Field Details
-
extensionNamespaces
-
version
protected int version -
staticContext
-
validationError
-
reportingCircumstances
-
defaultXPathNamespace
-
defaultCollationName
-
defaultMode
-
expandText
protected boolean expandText -
actionsCompleted
protected int actionsCompleted -
ACTION_VALIDATE
public static final int ACTION_VALIDATE- See Also:
-
ACTION_COMPILE
public static final int ACTION_COMPILE- See Also:
-
ACTION_TYPECHECK
public static final int ACTION_TYPECHECK- See Also:
-
ACTION_OPTIMIZE
public static final int ACTION_OPTIMIZE- See Also:
-
ACTION_FIXUP
public static final int ACTION_FIXUP- See Also:
-
ACTION_PROCESS_ATTRIBUTES
public static final int ACTION_PROCESS_ATTRIBUTES- See Also:
-
YES_NO
-
-
Constructor Details
-
StyleElement
public StyleElement()Constructor
-
-
Method Details
-
getCompilation
-
setCompilation
-
getPackageData
-
getConfiguration
Description copied from class:NodeImpl
Get the configuration- Specified by:
getConfiguration
in interfaceNodeInfo
- Overrides:
getConfiguration
in classNodeImpl
- Returns:
- the Configuration to which the tree belongs. The default implementation invokes
getTreeInfo().getConfiguration()
.
-
getStaticContext
Get the static context for expressions on this element- Returns:
- the static context
-
getStaticContext
-
isInXsltNamespace
public boolean isInXsltNamespace()Ask whether the element is in the XSLT namespace- Returns:
- true if the element is in the XSLT namespace
-
getBaseURI
Get the base URI of the element, which acts as the static base URI for XPath expressions defined on this element. This is an expensive operation so the result is cached- Specified by:
getBaseURI
in interfaceNodeInfo
- Overrides:
getBaseURI
in classElementImpl
- Returns:
- the base URI
-
makeExpressionVisitor
Make an expression visitor- Returns:
- the expression visitor
-
isSchemaAware
public boolean isSchemaAware()Ask whether the code is compiled in schema-aware mode- Returns:
- true if the compilation is schema-aware
-
substituteFor
Make this node a substitute for a temporary one previously added to the tree. See StyleNodeFactory for details. "A node like the other one in all things but its class". Note that at this stage, the node will not yet be known to its parent, though it will contain a reference to its parent; and it will have no children.- Parameters:
temp
- the element which this one is substituting for
-
setValidationError
Set a validation error. This is an error detected during construction of this element on the stylesheet, but which is not to be reported until later.- Parameters:
reason
- the details of the errorcircumstances
- a code identifying the circumstances under which the error is to be reported
-
isInstruction
public boolean isInstruction()Ask whether this node is an instruction. The default implementation says it isn't.- Returns:
- true if this element is an instruction
-
isDeclaration
public boolean isDeclaration()Ask whether this node is a declaration, that is, a permitted child of xsl:stylesheet (including xsl:include and xsl:import). The default implementation returns false- Returns:
- true if the element is a permitted child of xsl:stylesheet or xsl:transform
-
getVisibility
Get the visibility of the component. Returns the actual value of the visibility attribute, after validation, unless this is absent, in which case it returns the default value of PRIVATE. InvokesinvalidAttribute(String, String)
if the value is invalid.- Returns:
- the declared visibility of the component, or
Visibility.PRIVATE
if the visibility attribute is absent.
-
getDeclaredVisibility
Get the visibility of the component. Returns the actual value of the visibility attribute, after validation, unless this is absent, in which case it returns null.- Returns:
- the declared visibility of the component, or null if the visibility attribute is absent.
-
markTailCalls
protected boolean markTailCalls()Mark tail-recursive calls on templates and functions. For most instructions, this returns false.- Returns:
- true if one or more tail calls were identified
-
mayContainSequenceConstructor
protected boolean mayContainSequenceConstructor()Determine whether this type of element is allowed to contain a sequence constructor- Returns:
- true if this instruction is allowed to contain a sequence constructor
-
mayContainFallback
protected boolean mayContainFallback()Determine whether this type of element is allowed to contain an xsl:fallback instruction. Note that this is only relevant if the element is an instruction.- Returns:
- true if this element is allowed to contain an xsl:fallback
-
mayContainParam
protected boolean mayContainParam()Determine whether this type of element is allowed to contain an xsl:param element- Returns:
- true if this element is allowed to contain an xsl:param
-
makeQName
Make a structured QName, using this Element as the context for namespace resolution. If the name is unprefixed, the default namespace is not used. If the name is not valid, then a compileError is reported, and the value saxon:error-name is returned.- Parameters:
lexicalQName
- The lexical QName as written, in the form "[prefix:]localname". Leading and trailing whitespace will be trimmed. The EQName syntax "Q{uri}local" is also accepted.errorCode
- The error code to be used if the QName is not valid. If this is set to null, then the code used is XTSE0280 for an undeclared prefix, and XTSE0020 for all other errors. The code XTSE0080 is used if the URI is a reserved namespace, regardless of the supplied error code.attributeName
- EQName of the attribute containing the QName, for use in error reporting. May be null.- Returns:
- the StructuredQName representation of this lexical QName
-
getUsedPackage
Assuming this is an xsl:use-package element, find the package to which it refers.- Returns:
- the package referenced by this xsl:use-package element; or null if this is not an xsl:use-package element
-
getXslOriginal
Check that a reference to xsl:original appears within an xsl:override element, and that the name of the containing component matches the name of a component in the used stylesheet package; return the component in that package with matching symbolic name- Parameters:
componentKind
- the kind of component required, e.g. StandardNames.XSL_TEMPLATE- Returns:
- the component with matching name in the used stylesheet
- Throws:
XPathException
- if the xsl:original reference appears in an invalid context
-
makeRetainedStaticContext
-
getNamespaceResolver
Get the namespace context of the instruction.- 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.
-
processAllAttributes
Process the attributes of this element and all its children- Throws:
XPathException
- in the event of a static error being detected
-
processStandardAttributes
Process the standard attributes such as[xsl:]expand-text
. InvokescompileError(String)
or similar if the value of any of these attributes is invalid.The method processes:
extension-element-prefixes
exclude-result-prefixes
version
default-xpath-namespace
default-validation
expand-text
but not:
default-collation
default-mode
- Parameters:
namespace
- either "" to find the attributes in the null namespace, or NamespaceConstant.XSLT to find them in the XSLT namespace
-
getAttributeValue
Get an attribute value given the Clark name of the attribute (that is, the name in {uri}local format).- Parameters:
clarkName
- the name of the attribute in {uri}local format- Returns:
- the value of the attribute if it exists, or null otherwise
-
processAttributes
protected final void processAttributes()Process the attribute list for the element. This is a wrapper method that calls prepareAttributes (provided in the subclass) and traps any exceptions -
checkUnknownAttribute
Check whether an unknown attribute is permitted.- Parameters:
nc
- The name code of the attribute name
-
prepareAttributes
protected abstract void prepareAttributes()Set the attribute list for the element. This is called to process the attributes (note the distinction from processAttributes in the superclass). Must be supplied in a subclass -
makeExpression
Compile an XPath expression in the context of this stylesheet element- Parameters:
expression
- the source text of the XPath expressionatt
- the attribute containing the XPath expression, or null if the expression is in a text node- Returns:
- the compiled expression tree for the XPath expression. In the case of an error, returns an ErrorExpression that will fail at run-time if executed.
-
makeAttributeValueTemplate
Make an attribute value template in the context of this stylesheet element- Parameters:
expression
- the source text of the attribute value templateatt
- the attribute containing the AVT, or null in the case of a text 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)
-
processBooleanAttribute
Process an attribute whose value is yes, no, true, false, 1, or 0; returning true or false.- Parameters:
name
- the name of the attribute (used for diagnostics)value
- the value of the attribute- Returns:
- the value of the attribute as a boolean
-
isYes
Ask whether an attribute is "yes" or one of its accepted synonyms- Parameters:
s
- the value to be tested. Whitespace should be trimmed by the caller- Returns:
- true if the value is "yes", "true", or "1"
-
isNo
Ask whether an attribute is "no" or one of its accepted synonyms- Parameters:
s
- the value to be tested. Whitespace should be trimmed by the caller- Returns:
- true if the value is "no", "false", or "0"
-
makeSequenceType
Process an attribute whose value is a SequenceType- 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
-
processVersionAttribute
Process the [xsl:]version attribute if there is one- Parameters:
ns
- the namespace URI of the attribute required, either the XSLT namespace or ""
-
validateValidationAttribute
Validate the value of the [xsl:]validation attribute- Parameters:
value
- the raw value of the attribute- Returns:
- the encoded value of the attribute
-
isExtensionAttributeAllowed
Ask if an extension attribute is allowed; if no Professional Edition license is available, issue a warning saying the attribute is ignored, and return false- Parameters:
attribute
- the name of the attribute- Returns:
- true if the extension attribute is allowed, false if not
-
getDefaultCollationName
Get the default collation for this stylesheet element. If no default collation is specified in the stylesheet, return the Unicode codepoint collation name.- Returns:
- the name of the default collation
-
isExtensionNamespace
Check whether a namespace uri defines an extension element. This checks whether the namespace is defined as an extension namespace on this or any ancestor node.- Parameters:
uri
- the namespace URI being tested- Returns:
- true if the URI is an extension element namespace URI
-
getDefaultXPathNamespace
Get the default XPath namespace for elements and types- Returns:
- the default namespace for elements and types.
Return
NamespaceConstant.NULL
for the non-namespace
-
getSchemaType
Get the Schema type definition for a type named in the stylesheet (in a "type" attribute).- Parameters:
typeAtt
- the value of the type attribute- Returns:
- the corresponding schema type
-
getTypeAnnotation
Get the type annotation to use for a given schema type- Parameters:
schemaType
- the schema type- Returns:
- the corresponding numeric type annotation
-
mapToSequence
Adapt an expression that returns a map to one that returns a representation of the map as a sequence of two-entry maps containing the "key" and "value" fields, as required for the proposed XSLT 4.0 xsl:for-each/iterate instructions with a "map" attribute- Parameters:
mapExpr
- the expression in the map attribute- Returns:
- a call on a function that converts the map to a sequence of key-value maps
-
validate
Check that the stylesheet element is valid. This is called once for each element, after the entire tree has been built. As well as validation, it can perform first-time initialisation. The default implementation does nothing; it is normally overriden in subclasses.- Parameters:
decl
- the declaration to be validated- Throws:
XPathException
- if any error is found during validation
-
postValidate
Hook to allow additional validation of a parent element immediately after its children have been validated.- Throws:
XPathException
- if any error is found during post-traversal validation
-
index
Method supplied by declaration elements to add themselves to a stylesheet-level index- Parameters:
decl
- the Declaration being indexed. (This corresponds to the StyleElement object except in cases where one module is imported several times with different precedence.)top
- represents the outermost XSLStylesheet or XSLPackage element- Throws:
XPathException
- if any error is encountered
-
typeCheck
Type-check an expression. This is called to check each expression while the containing instruction is being validated. It is not just a static type-check, it also adds code to perform any necessary run-time type checking and/or conversion.- 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
- Throws:
XPathException
- if type-checking fails statically, that is, if it can be determined that the supplied value for the expression cannot possibly be of the required type
-
typeCheck
Type-check a pattern. This is called to check each pattern while the containing instruction is being validated. It is not just a static type-check, it also adds code to perform any necessary run-time type checking and/or conversion.- Parameters:
name
- the name of the attribute holding the pattern, for example "match": used in diagnosticspattern
- the compiled pattern- Returns:
- the original pattern, or a substitute pattern if it has been rewritten. Returns null if and only if the supplied pattern is null.
- Throws:
XPathException
- if the pattern fails optimistic static type-checking
-
fixupReferences
Fix up references from XPath expressions. Overridden for function declarations and variable declarations- Throws:
XPathException
- if any references cannot be fixed up.
-
getContainingSlotManager
Get the SlotManager for the containing Procedure definition- Returns:
- the SlotManager associated with the containing Function, Template, etc, or null if there is no such containing Function, Template etc.
-
validateSubtree
public void validateSubtree(ComponentDeclaration decl, boolean excludeStylesheet) throws XPathException Recursive walk through the stylesheet to validate all nodes- Parameters:
decl
- the declaration to be validatedexcludeStylesheet
- true if the XSLStylesheet element is to be excluded- Throws:
XPathException
- if validation fails
-
validateChildren
protected void validateChildren(ComponentDeclaration decl, boolean excludeStylesheet) throws XPathException Validate the children of this node, recursively. Overridden for top-level data elements.- Parameters:
decl
- the declaration whose children are to be validatedexcludeStylesheet
- true if the xsl:stylesheet element is to be excluded- Throws:
XPathException
- if validation fails
-
isPermittedChild
Check whether a given child is permitted for this element. This method is used when a non-instruction child element such as xsl:sort is encountered in a context where instructions would normally be expected.- Parameters:
child
- the child that may or may not be permitted- Returns:
- true if the child is permitted.
-
getPrincipalStylesheetModule
Get the principal stylesheet module of the package in which this XSLT element appears- Returns:
- the containing package
-
getContainingPackage
Get the containing package (the principal stylesheet module of the package in which this XSLT element appears)- Returns:
- the containing package. May be null if the method is called during initialization.
-
checkTopLevel
Convenience method to check that the stylesheet element is at the top level (that is, as a child of xsl:stylesheet or xsl:transform)- Parameters:
errorCode
- the error to throw if it is not at the top level; defaults to XTSE0010 if the value is nullallowOverride
- true if the element is allowed to appear as a child of xsl:override
-
checkEmpty
public void checkEmpty()Convenience method to check that the stylesheet element is empty -
reportAbsence
Convenience method to report the absence of a mandatory attribute- Parameters:
attribute
- the name of the attribute whose absence is to be reported
-
compile
Compile the instruction on the stylesheet tree into an executable instruction for use at run-time.- Parameters:
compilation
- the compilation episodedecl
- the containing top-level declaration, for example xsl:function or xsl:template- 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.
- Throws:
XPathException
- if validation fails
-
isWithinDeclaredStreamableConstruct
protected boolean isWithinDeclaredStreamableConstruct() -
generateId
-
compileDeclaration
public void compileDeclaration(Compilation compilation, ComponentDeclaration decl) throws XPathException Compile a declaration in the stylesheet tree for use at run-time.- Parameters:
compilation
- the compilation episodedecl
- the containing top-level declaration, for example xsl:function or xsl:template- Throws:
XPathException
- if compilation fails
-
compileSequenceConstructor
public Expression compileSequenceConstructor(Compilation compilation, ComponentDeclaration decl, boolean includeParams) throws XPathException Compile the children of this instruction on the stylesheet tree, adding the subordinate instructions to the parent instruction on the execution tree.- Parameters:
compilation
- the Executabledecl
- the Declaration of the containing top-level stylesheet elementincludeParams
- true if xsl:param elements are to be treated as child instructions (true for templates but not for functions)- Returns:
- the compiled sequence constructor
- Throws:
XPathException
- if compilation fails
-
compileSequenceConstructor
public Expression compileSequenceConstructor(Compilation compilation, ComponentDeclaration decl, SequenceIterator iter, boolean includeParams) throws XPathException Compile the children of this instruction on the stylesheet tree, adding the subordinate instructions to the parent instruction on the execution tree.- Parameters:
compilation
- the Executabledecl
- the Declaration of the containing top-level stylesheet elementiter
- 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:
- the compiled sequence constructor
- Throws:
XPathException
- if compilation fails
-
setInstructionLocation
Set location information on a compiled instruction- Parameters:
source
- the parent elementchild
- the compiled expression tree for the instruction to be traced
-
allocateLocation
Allocate a location- Returns:
- an location which can be used to report the location of the instruction
-
getWithParamInstructions
public WithParam[] getWithParamInstructions(Expression parent, Compilation compilation, ComponentDeclaration decl, boolean tunnel) throws XPathException Get the list of xsl:with-param elements for a calling element (apply-templates, call-template, apply-imports, next-match). This method can be used to get either the tunnel parameters, or the non-tunnel parameters.- Parameters:
parent
- the compiled form of the parent instructioncompilation
- the compilation episodedecl
- the containing stylesheet declarationtunnel
- true if the tunnel="yes" parameters are wanted, false to get- Returns:
- an array of WithParam objects for either the ordinary parameters or the tunnel parameters, as an array containing the results of compiling the xsl:with-param children of this instruction (if any)
- Throws:
XPathException
- if any error is detected
-
compileError
Report an error with diagnostic information- Parameters:
error
- contains information about the error
-
compileError
-
compileError
Report a static error in the stylesheet- Parameters:
message
- the error message
-
compileError
Compile time error, specifying an error code- Parameters:
message
- the error messageerrorCode
- the error code. May be null if not known or not defined
-
compileError
Compile time error, specifying an error code- Parameters:
message
- the error messageerrorCode
- the error code. May be null if not known or not defined
-
compileError
-
compileErrorInAttribute
Compile time error, specifying an error code and the name of the attribute that is in error.- Parameters:
message
- the error messageerrorCode
- the error code. May be null if not known or not definedattributeName
- the name of the attribute. For attributes in no namespace this is the local part of the name; for namespaced attributes a name in Clark format may be supplied.
-
compileErrorInAttribute
-
invalidAttribute
-
requireXslt40Attribute
Report an error unless XSLT 4.0 syntax is enabled in the XSLT compiler- Parameters:
attributeName
- the name of the attribute- Returns:
- true if OK, false if the attribute should be ignored (in forwards compatibility mode)
-
requireXslt40Element
protected void requireXslt40Element()Report an error unless XSLT 4.0 syntax is enabled in the XSLT compiler -
compileWarning
-
compileWarning
-
issueWarning
Report a warning to the error listener- Parameters:
message
- the warning message texterrorCode
- error code identifying the conditionlocator
- the location of the problem in the source stylesheet
-
issueWarning
-
isTopLevel
public boolean isTopLevel()Test whether this is a top-level element- Returns:
- true if the element is a child of the xsl:stylesheet or xsl:package element
-
getBindingInformation
Ask whether this element contains a binding for a variable with a given name; and if it does, return the source binding information- Parameters:
name
- the variable name- Returns:
- the binding information if this element binds a variable of this name; otherwise null
-
bindVariable
Bind a variable used in this element to the compiled form of the XSLVariable element in which it is declared- Parameters:
variableName
- The name of the variableattributeName
- The name of the attribute containing the variable reference- 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
-
bindLocalVariable
Bind a variable reference used in this element to the compiled form of the XSLVariable element in which it is declared, considering only local variables and params- Parameters:
variableName
- The name of the variableattributeName
- The name of the attribute containing the variable reference- Returns:
- the XSLVariableDeclaration (that is, an xsl:variable or xsl:param instruction) for the variable, or null if no local declaration of the variable can be found
-
seesAvuncularVariables
protected boolean seesAvuncularVariables()Ask whether variables declared in an "uncle" element are visible.- Returns:
- true for all elements except xsl:fallback and xsl:catch
-
hasImplicitBinding
protected SourceBinding hasImplicitBinding(StructuredQName variableName, StructuredQName attributeName) Ask whether this particular element implicitly binds a given variable (used for xsl:accumulator-rule)- Parameters:
variableName
- the name of the variableattributeName
- the name of the attribute containing the variable reference, or null if it appears in a contained sequence constructor- Returns:
- a
SourceBinding
object representing the binding of this variable if it exists; otherwise null;
-
getObjectName
Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically. If there is no name, the value will be null.- Returns:
- the name of the object declared in this element, if any
-
setObjectName
Set the object name, for example the name of a function, variable, or template declared on this element- Parameters:
qName
- the object name as a QName
-
getProperties
Get an iterator over all the properties available. The values returned by the iterator will be of type String, and each string can be supplied as input to the getProperty() method to retrieve the value of the property.- Returns:
- an iterator over the available property names
-