/** * Get the static context for expressions on this element * * @return the static context */ public ExpressionContext getStaticContext() { if (staticContext == null) { staticContext = new ExpressionContext(this, null); } return staticContext; }
/** * Determine whether a built-in type is available in this context. This method caters for differences * between host languages as to which set of types are built in. * * @param type the supposedly built-in type. This will always be a type in the * XS or XDT namespace. * @return true if this type can be used in this static context */ public boolean isAllowedBuiltInType(BuiltInAtomicType type) { return getConfiguration().isSchemaAware(Configuration.XSLT) || type.isAllowedInBasicXSLT() || getXSLStylesheet().allowsAllBuiltInTypes(); }
/** * Get type alias. This is a Saxon extension. A type alias is a QName which can * be used as a shorthand for an itemtype, using the syntax ~typename anywhere that * an item type is permitted. * * @param typeName the name of the type alias * @return the corresponding item type, if the name is recognised; otherwise null. */ @Override public ItemType resolveTypeAlias(StructuredQName typeName) { return getPackageData().obtainTypeAliasManager().getItemType(typeName); }
/** * Determine if an extension element is available * @throws XPathException if the name is invalid or the prefix is not declared */ public boolean isElementAvailable(String qname) throws XPathException { try { String[] parts = getConfiguration().getNameChecker().getQNameParts(qname); String uri; if (parts[0].length() == 0) { uri = getDefaultElementNamespace(); } else { uri = getURIForPrefix(parts[0]); } return element.getPreparedStylesheet(). getStyleNodeFactory().isElementAvailable(uri, parts[1]); } catch (QNameException e) { XPathException err = new XPathException("Invalid element name. " + e.getMessage()); err.setErrorCode("XTDE1440"); throw err; } }
/** * Get a StructuredQName for a name, using this as the context for namespace resolution * @param qname The name as written, in the form "[prefix:]localname" * @param useDefault Defines the action when there is no prefix. If true, use * the default namespace URI (as for element names). If false, use no namespace URI * (as for attribute names). * @return -1 if the name is not already present in the name pool */ public StructuredQName getStructuredQName(String qname, boolean useDefault) throws XPathException { String[] parts; try { parts = getConfiguration().getNameChecker().getQNameParts(qname); } catch (QNameException err) { throw new XPathException(err.getMessage()); } String prefix = parts[0]; if (prefix.length() == 0) { String uri = ""; if (useDefault) { uri = getURIForPrefix(prefix); } return new StructuredQName("", uri, qname); } else { String uri = getURIForPrefix(prefix); return new StructuredQName(prefix, uri, parts[1]); } }
StructuredQName formatQName = null; if (formatString.length() != 0) { formatQName = ((ExpressionContext)env).getStructuredQName(formatString, false); outputProperties = ((ExpressionContext)env).getXSLStylesheet().gatherOutputProperties(formatQName); } else {
/** * Allocate slots to any variables used within the pattern * @param env the static context in the XSLT stylesheet * @param nextFree the next slot that is free to be allocated * @param stackFrame * @return the next slot that is free to be allocated */ public int allocateSlots(ExpressionContext env, int nextFree, SlotManager stackFrame) { // See tests cnfr23, idky239, match54, group018 SlotManager slotManager = env.getStyleElement().getContainingSlotManager(); if (variableBinding != null) { nextFree = ExpressionTool.allocateSlots(variableBinding, nextFree, slotManager); } for (int i = 0; i < numberOfFilters; i++) { nextFree = ExpressionTool.allocateSlots(filters[i], nextFree, slotManager); } if (parentPattern != null) { nextFree = parentPattern.allocateSlots(env, nextFree, stackFrame); } if (ancestorPattern != null) { nextFree = ancestorPattern.allocateSlots(env, nextFree, stackFrame); } env.getStyleElement().getPrincipalStylesheet().allocatePatternSlots(nextFree); return nextFree; }
/** * Get the XPath language level supported, as an integer (being the actual version * number times ten). In Saxon 9.9, for XSLT, the possible values are * 30 (XPath 3.0), 31 (XPath 3.1), and 305 (XPath 3.0 plus the extensions defined in XSLT 3.0). * * @return the XPath language level; the return value will be either 30, 305, or 31 * @since 9.7 */ public int getXPathVersion() { return getConfiguration().getConfigurationProperty(Feature.XPATH_VERSION_FOR_XSLT); }
/** * Process an attribute whose value is a SequenceType * * @param sequenceType the source text of the attribute * @return 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 */ public SequenceType makeSequenceType(String sequenceType) throws XPathException { ExpressionContext env = getStaticContext(); int languageLevel = env.getXPathVersion(); if (languageLevel == 30) { languageLevel = 305; // XPath 3.0 + XSLT extensions } XPathParser parser = getConfiguration().newExpressionParser("XP", false, languageLevel); QNameParser qp = new QNameParser(staticContext.getNamespaceResolver()); qp.setAcceptEQName(staticContext.getXPathVersion() >= 30); qp.setDefaultNamespace(""); qp.setErrorOnBadSyntax("XPST0003"); qp.setErrorOnUnresolvedPrefix("XPST0081"); parser.setQNameParser(qp); return parser.parseSequenceType(sequenceType, staticContext); }
/** * Test whether a schema has been imported for a given namespace * @param namespace the target namespace of the required schema * @return true if a schema for this namespace has been imported */ public boolean isImportedSchema(String namespace) { return getXSLStylesheet().isImportedSchema(namespace); }
/** * Determine if an extension element is available * * @throws XPathException if the name is invalid or the prefix is not declared */ public boolean isElementAvailable(String qname) throws XPathException { try { String[] parts = NameChecker.getQNameParts(qname); String uri; if (parts[0].isEmpty()) { uri = getDefaultElementNamespace(); } else { uri = element.getURIForPrefix(parts[0], false); } return element.getCompilation().getStyleNodeFactory(true).isElementAvailable(uri, parts[1], true); } catch (QNameException e) { XPathException err = new XPathException("Invalid element name. " + e.getMessage()); err.setErrorCode("XTDE1440"); throw err; } }
keyName = ((ExpressionContext)visitor.getStaticContext()).getStructuredQName( ((StringLiteral)argument[0]).getStringValue(), false); } catch (XPathException e) {
/** * Bind a variable to an object that can be used to refer to it * * @param qName the name of the variable * @return a VariableDeclaration object that can be used to identify it in the Bindery, * @throws net.sf.saxon.trans.XPathException * if the variable has not been declared */ @Override public Expression bindVariable(StructuredQName qName) throws XPathException { SourceBinding siblingVar = bindLocalVariable(qName); if (siblingVar == null) { return super.bindVariable(qName); } else { VariableReference var = new LocalVariableReference(qName); siblingVar.registerReference(var); return var; } }
NamespaceResolver namespaceResolver = getStaticContext().getNamespaceResolver(); for (StructuredQName property : serializationAttributes.keySet()) { Expression exp = serializationAttributes.get(property);
/** * Determine if an extension element is available * @throws XPathException if the name is invalid or the prefix is not declared */ public boolean isElementAvailable(String qname) throws XPathException { try { String[] parts = getConfiguration().getNameChecker().getQNameParts(qname); String uri; if (parts[0].length() == 0) { uri = getDefaultElementNamespace(); } else { uri = getURIForPrefix(parts[0]); } return element.getPreparedStylesheet(). getStyleNodeFactory().isElementAvailable(uri, parts[1]); } catch (QNameException e) { XPathException err = new XPathException("Invalid element name. " + e.getMessage()); err.setErrorCode("XTDE1440"); throw err; } }
/** * Get a fingerprint for a name, using this as the context for namespace resolution * @param qname The name as written, in the form "[prefix:]localname" * @param useDefault Defines the action when there is no prefix. If true, use * the default namespace URI (as for element names). If false, use no namespace URI * (as for attribute names). * @return -1 if the name is not already present in the name pool */ public int getFingerprint(String qname, boolean useDefault) throws XPathException { String[] parts; try { parts = getConfiguration().getNameChecker().getQNameParts(qname); } catch (QNameException err) { throw new XPathException(err.getMessage()); } String prefix = parts[0]; if (prefix.length() == 0) { String uri = ""; if (useDefault) { uri = getURIForPrefix(prefix); } return namePool.getFingerprint(uri, qname); } else { String uri = getURIForPrefix(prefix); return namePool.getFingerprint(uri, parts[1]); } }
StructuredQName formatQName = null; if (formatString.length() != 0) { formatQName = ((ExpressionContext)env).getStructuredQName(formatString, false); outputProperties = ((ExpressionContext)env).getXSLStylesheet().gatherOutputProperties(formatQName); } else {
last = parser.getTokenizer().currentTokenStartOffset + 1; if (env instanceof ExpressionContext && ((ExpressionContext)env).getStyleElement() instanceof XSLAnalyzeString && isIntegerOrIntegerPair(exp)) { env.issueWarning("Found {" + showIntegers(exp) + "} in regex attribute: perhaps {{" +
/** * Construct a dynamic context for early evaluation of constant subexpressions */ public XPathContext makeEarlyEvaluationContext() { return new EarlyEvaluationContext(getConfiguration()); }
/** * Process an attribute whose value is a SequenceType * * @param sequenceType the source text of the attribute * @return 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 */ public SequenceType makeSequenceType(String sequenceType) throws XPathException { ExpressionContext env = getStaticContext(); int languageLevel = env.getXPathVersion(); if (languageLevel == 30) { languageLevel = 305; // XPath 3.0 + XSLT extensions } XPathParser parser = getConfiguration().newExpressionParser("XP", false, languageLevel); QNameParser qp = new QNameParser(staticContext.getNamespaceResolver()); qp.setAcceptEQName(staticContext.getXPathVersion() >= 30); qp.setDefaultNamespace(""); qp.setErrorOnBadSyntax("XPST0003"); qp.setErrorOnUnresolvedPrefix("XPST0081"); parser.setQNameParser(qp); return parser.parseSequenceType(sequenceType, staticContext); }