/** * Attempt to create a dynamic context on which to evaluate the {@link #xpathExpression}. * * @param elementNode the node on which to create the context; generally this node is the root node of the Saxon * Tree * @return the dynamic context on which to run the query * @throws XPathException if the supplied value does not conform to the required type of the * variable, when setting up the dynamic context; or if the supplied value contains a node that does not belong to * this Configuration (or another Configuration that shares the same namePool) */ private XPathDynamicContext createDynamicContext(final ElementNode elementNode) throws XPathException { final XPathDynamicContext dynamicContext = xpathExpression.createDynamicContext(elementNode); // Set variable values on the dynamic context for (final XPathVariable xpathVariable : xpathVariables) { final String variableName = xpathVariable.getVariableQName().getLocalName(); for (final Map.Entry<PropertyDescriptor<?>, Object> entry : super.properties.entrySet()) { if (variableName.equals(entry.getKey().name())) { final ValueRepresentation valueRepresentation = getRepresentation(entry.getKey(), entry.getValue()); dynamicContext.setVariable(xpathVariable, valueRepresentation); } } } return dynamicContext; }
/** * Get the local part */ public final String getLocalName() { return qName.getLocalName(); }
/** * Get the local part */ public final String getLocalName() { return qName.getLocalName(); }
/** * The local part of the QName * @return the local part of the QName */ public String getLocalName() { return sqName.getLocalName(); }
/** * Test whether a Saxon function with a given name and arity is available. This supports * the function-available() function in XSLT. This method may be called either at compile time * or at run time. * @param functionName the name of the function * @param arity The number of arguments. This is set to -1 in the case of the single-argument * function-available() function; in this case the method should return true if there is some */ public boolean isAvailable(StructuredQName functionName, int arity) { if (functionName.getNamespaceURI().equals(NamespaceConstant.SAXON)) { StandardFunction.Entry entry = (StandardFunction.Entry)functionTable.get(functionName.getLocalName()); return entry != null && (arity == -1 || (arity >= entry.minArguments && arity <= entry.maxArguments)); } else { return false; } }
/** * Test whether a Saxon function with a given name and arity is available. This supports * the function-available() function in XSLT. This method may be called either at compile time * or at run time. * @param functionName the name of the function * @param arity The number of arguments. This is set to -1 in the case of the single-argument * function-available() function; in this case the method should return true if there is some */ public boolean isAvailable(StructuredQName functionName, int arity) { if (functionName.getNamespaceURI().equals(NamespaceConstant.SAXON)) { StandardFunction.Entry entry = (StandardFunction.Entry)functionTable.get(functionName.getLocalName()); return entry != null && (arity == -1 || (arity >= entry.minArguments && arity <= entry.maxArguments)); } else { return false; } }
/** * preEvaluate: this method performs compile-time evaluation for properties in the XSLT namespace only * @param visitor an expression visitor */ public Expression preEvaluate(ExpressionVisitor visitor) throws XPathException { if (propertyName != null && NamespaceConstant.XSLT.equals(propertyName.getNamespaceURI())) { return new StringLiteral( getProperty(NamespaceConstant.XSLT, propertyName.getLocalName(), visitor.getConfiguration())); } else { return this; } }
/** * preEvaluate: this method performs compile-time evaluation for properties in the XSLT namespace only * @param visitor an expression visitor */ public Expression preEvaluate(ExpressionVisitor visitor) throws XPathException { if (propertyName != null && NamespaceConstant.XSLT.equals(propertyName.getNamespaceURI())) { return new StringLiteral( getProperty(NamespaceConstant.XSLT, propertyName.getLocalName(), visitor.getConfiguration())); } else { return this; } }
/** * preEvaluate: this method performs compile-time evaluation for properties in the XSLT namespace only * @param visitor an expression visitor */ public Expression preEvaluate(ExpressionVisitor visitor) throws XPathException { if (propertyName != null && NamespaceConstant.XSLT.equals(propertyName.getNamespaceURI())) { return new StringLiteral( getProperty(NamespaceConstant.XSLT, propertyName.getLocalName(), visitor.getConfiguration())); } else { return this; } }
/** * Attempt to create a dynamic context on which to evaluate the {@link #xpathExpression}. * * @param elementNode the node on which to create the context; generally this node is the root node of the Saxon * Tree * @return the dynamic context on which to run the query * @throws XPathException if the supplied value does not conform to the required type of the * variable, when setting up the dynamic context; or if the supplied value contains a node that does not belong to * this Configuration (or another Configuration that shares the same namePool) */ private XPathDynamicContext createDynamicContext(final ElementNode elementNode) throws XPathException { final XPathDynamicContext dynamicContext = xpathExpression.createDynamicContext(elementNode); // Set variable values on the dynamic context for (final XPathVariable xpathVariable : xpathVariables) { final String variableName = xpathVariable.getVariableQName().getLocalName(); for (final Map.Entry<PropertyDescriptor<?>, Object> entry : super.properties.entrySet()) { if (variableName.equals(entry.getKey().name())) { final ValueRepresentation valueRepresentation = getRepresentation(entry.getKey(), entry.getValue()); dynamicContext.setVariable(xpathVariable, valueRepresentation); } } } return dynamicContext; }
/** * Make a key that will uniquely identify a function * @param functionName the name of the function * @param arity the number of arguments * @return the constructed key. This is of the form {uri}local/arity */ private String makeKey(StructuredQName functionName, int arity) { String uri = functionName.getNamespaceURI(); String local = functionName.getLocalName(); FastStringBuffer sb = new FastStringBuffer(uri.length() + local.length() + 8); sb.append('{'); sb.append(uri); sb.append('}'); sb.append(local); sb.append("/" + arity); return sb.toString(); }
/** * Make a key that will uniquely identify a function * @param functionName the name of the function * @param arity the number of arguments * @return the constructed key. This is of the form {uri}local/arity */ private String makeKey(StructuredQName functionName, int arity) { String uri = functionName.getNamespaceURI(); String local = functionName.getLocalName(); FastStringBuffer sb = new FastStringBuffer(uri.length() + local.length() + 8); sb.append('{'); sb.append(uri); sb.append('}'); sb.append(local); sb.append("/" + arity); return sb.toString(); }
/** * Construct what the identification key would be for a function with given URI, local name, and arity * @param qName the name of the function * @param arity the number of arguments * @return an identifying key */ public static String getIdentificationKey(StructuredQName qName, int arity) { String uri = qName.getNamespaceURI(); String localName = qName.getLocalName(); FastStringBuffer sb = new FastStringBuffer(uri.length() + localName.length() + 8); sb.append('{'); sb.append(uri); sb.append('}'); sb.append(localName); sb.append('/'); sb.append(arity+""); return sb.toString(); }
/** * Construct what the identification key would be for a function with given URI, local name, and arity * @param qName the name of the function * @param arity the number of arguments * @return an identifying key */ public static String getIdentificationKey(StructuredQName qName, int arity) { String uri = qName.getNamespaceURI(); String localName = qName.getLocalName(); FastStringBuffer sb = new FastStringBuffer(uri.length() + localName.length() + 8); sb.append('{'); sb.append(uri); sb.append('}'); sb.append(localName); sb.append('/'); sb.append(arity+""); return sb.toString(); }
/** * Get the display name, that is the lexical QName in the form [prefix:]local-part * @return the lexical QName */ public String getDisplayName() { if (prefixStart == content.length) { return getLocalName(); } else { FastStringBuffer buff = new FastStringBuffer(content.length - localNameStart + 1); buff.append(content, prefixStart, content.length - prefixStart); buff.append(':'); buff.append(content, localNameStart, prefixStart - localNameStart); return buff.toString(); } }
/** * Get the display name, that is the lexical QName in the form [prefix:]local-part * @return the lexical QName */ public String getDisplayName() { if (prefixStart == content.length) { return getLocalName(); } else { FastStringBuffer buff = new FastStringBuffer(content.length - localNameStart + 1); buff.append(content, prefixStart, content.length - prefixStart); buff.append(':'); buff.append(content, localNameStart, prefixStart - localNameStart); return buff.toString(); } }
private Receiver makeValidator(Receiver receiver, String systemId, ParseOptions options) { Configuration config = pipe.getConfiguration(); int schemaValidation = options.getSchemaValidationMode(); if ((schemaValidation & Validation.VALIDATION_MODE_MASK) != Validation.PRESERVE) { // Add a document validator to the pipeline int stripSpace = options.getStripSpace(); SchemaType topLevelType = options.getTopLevelType(); StructuredQName topLevelElement = options.getTopLevelElement(); int topLevelElementCode = -1; if (topLevelElement != null) { topLevelElementCode = config.getNamePool().allocate( topLevelElement.getPrefix(), topLevelElement.getNamespaceURI(), topLevelElement.getLocalName()); } receiver = config.getDocumentValidator( receiver, systemId, schemaValidation, stripSpace, topLevelType, topLevelElementCode); } return receiver; }
/** * Evaluate the function at run-time */ public Item evaluateItem(XPathContext context) throws XPathException { StructuredQName qName = propertyName; if (qName == null) { CharSequence name = argument[0].evaluateItem(context).getStringValueCS(); try { qName = StructuredQName.fromLexicalQName(name, false, context.getConfiguration().getNameChecker(), nsContext); } catch (XPathException err) { dynamicError("Invalid system property name. " + err.getMessage(), "XTDE1390", context); return null; } } return new StringValue(getProperty( qName.getNamespaceURI(), qName.getLocalName(), context.getConfiguration())); }
/** * Evaluate the function at run-time */ public Item evaluateItem(XPathContext context) throws XPathException { StructuredQName qName = propertyName; if (qName == null) { CharSequence name = argument[0].evaluateItem(context).getStringValueCS(); try { qName = StructuredQName.fromLexicalQName(name, false, context.getConfiguration().getNameChecker(), nsContext); } catch (XPathException err) { dynamicError("Invalid system property name. " + err.getMessage(), "XTDE1390", context); return null; } } return new StringValue(getProperty( qName.getNamespaceURI(), qName.getLocalName(), context.getConfiguration())); }
/** * Evaluate the function at run-time */ public Item evaluateItem(XPathContext context) throws XPathException { StructuredQName qName = propertyName; if (qName == null) { CharSequence name = argument[0].evaluateItem(context).getStringValueCS(); try { qName = StructuredQName.fromLexicalQName(name, false, context.getConfiguration().getNameChecker(), nsContext); } catch (XPathException err) { dynamicError("Invalid system property name. " + err.getMessage(), "XTDE1390", context); return null; } } return new StringValue(getProperty( qName.getNamespaceURI(), qName.getLocalName(), context.getConfiguration())); }