public int evaluateNameCode(XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); return context.getNamePool().allocate("", "", prefix); }
public int evaluateNameCode(XPathContext context) throws XPathException { String expandedName = evaluateName(context); return context.getNamePool().allocate("", "", expandedName); }
public int evaluateNameCode(XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); return context.getNamePool().allocate("", "", prefix); }
public int evaluateNameCode(XPathContext context) throws XPathException { String expandedName = evaluateName(context); return context.getNamePool().allocate("", "", expandedName); }
/** * Get a rule chain for a particular node name without allocating a fingerprint from the name pool * * @param kind the kind of node (element or attribute) * @param uri the namespace URI of the node * @param local the local name of the node * @return the Rule at the head of the rule chain for nodes of this name, or null if there are no rules * to consider */ protected RuleChain getNamedRuleChain(XPathContext c, int kind, String uri, String local) { // If this is the first attempt to match a non-fingerprinted node, build indexes // to the rule chains based on StructuredQName rather than fingerprint synchronized(this) { if (qNamedElementRuleChains == null) { qNamedElementRuleChains = new HashMap<>(namedElementRuleChains.size()); qNamedAttributeRuleChains = new HashMap<>(namedAttributeRuleChains.size()); NamePool pool = c.getNamePool(); indexByQName(pool, namedElementRuleChains, qNamedElementRuleChains); indexByQName(pool, namedAttributeRuleChains, qNamedAttributeRuleChains); } } return (kind == Type.ELEMENT ? qNamedElementRuleChains : qNamedAttributeRuleChains) .get(new StructuredQName("", uri, local)); }
/** * Get a rule chain for a particular node name without allocating a fingerprint from the name pool * * @param kind the kind of node (element or attribute) * @param uri the namespace URI of the node * @param local the local name of the node * @return the Rule at the head of the rule chain for nodes of this name, or null if there are no rules * to consider */ protected RuleChain getNamedRuleChain(XPathContext c, int kind, String uri, String local) { // If this is the first attempt to match a non-fingerprinted node, build indexes // to the rule chains based on StructuredQName rather than fingerprint synchronized(this) { if (qNamedElementRuleChains == null) { qNamedElementRuleChains = new HashMap<>(namedElementRuleChains.size()); qNamedAttributeRuleChains = new HashMap<>(namedAttributeRuleChains.size()); NamePool pool = c.getNamePool(); indexByQName(pool, namedElementRuleChains, qNamedElementRuleChains); indexByQName(pool, namedAttributeRuleChains, qNamedAttributeRuleChains); } } return (kind == Type.ELEMENT ? qNamedElementRuleChains : qNamedAttributeRuleChains) .get(new StructuredQName("", uri, local)); }
/** * Display the value of the type annotation of a node or an atomic value * * @param context the XPath dynamic context * @param item the node or atomic value whose type annotation is required * @return the type annotation or type label as a QName */ public static QNameValue typeAnnotation(XPathContext context, Item item) { if (item == null) { return null; } else if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo)item; int code = node.getTypeAnnotation(); if ((code & NodeInfo.IS_DTD_TYPE) != 0) { code = StandardNames.XS_UNTYPED_ATOMIC; } if (code == -1) { int nodeKind = node.getNodeKind(); if (nodeKind == Type.ELEMENT || nodeKind == Type.DOCUMENT) { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untyped"); } else { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untypedAtomic"); } } return new QNameValue(context.getNamePool(), code); } else { AtomicType label = ((AtomicValue)item).getTypeLabel(); return new QNameValue(context.getNamePool(), label.getNameCode()); } }
private void checkNotTemporaryOutputState(XPathContext context) throws XPathException { if (context.getTemporaryOutputState() != 0) { XPathException err = new XPathException("Cannot execute xsl:result-document while evaluating xsl:" + context.getNamePool().getLocalName(context.getTemporaryOutputState())); err.setErrorCode("XTDE1480"); err.setLocation(getLocation()); throw err; } }
/** * Display the value of the type annotation of a node or an atomic value * * @param context the XPath dynamic context * @param item the node or atomic value whose type annotation is required * @return the type annotation or type label as a QName */ public static QNameValue typeAnnotation(XPathContext context, Item item) { if (item == null) { return null; } else if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo)item; int code = node.getTypeAnnotation(); if ((code & NodeInfo.IS_DTD_TYPE) != 0) { code = StandardNames.XS_UNTYPED_ATOMIC; } if (code == -1) { int nodeKind = node.getNodeKind(); if (nodeKind == Type.ELEMENT || nodeKind == Type.DOCUMENT) { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untyped"); } else { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untypedAtomic"); } } return new QNameValue(context.getNamePool(), code); } else { AtomicType label = ((AtomicValue)item).getTypeLabel(); return new QNameValue(context.getNamePool(), label.getNameCode()); } }
/** * Display the value of the type annotation of a node or an atomic value * * @param context the XPath dynamic context * @param item the node or atomic value whose type annotation is required * @return the type annotation or type label as a QName */ public static QNameValue typeAnnotation(XPathContext context, Item item) { if (item == null) { return null; } else if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo)item; int code = node.getTypeAnnotation(); if ((code & NodeInfo.IS_DTD_TYPE) != 0) { code = StandardNames.XS_UNTYPED_ATOMIC; } if (code == -1) { int nodeKind = node.getNodeKind(); if (nodeKind == Type.ELEMENT || nodeKind == Type.DOCUMENT) { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untyped"); } else { return new QNameValue("xs", NamespaceConstant.SCHEMA, "untypedAtomic"); } } return new QNameValue(context.getNamePool(), code); } else { AtomicType label = ((AtomicValue)item).getTypeLabel(); return new QNameValue(context.getNamePool(), label.getNameCode()); } }
private void checkNotTemporaryOutputState(XPathContext context) throws XPathException { if (context.getTemporaryOutputState() != 0) { XPathException err = new XPathException("Cannot execute xsl:result-document while evaluating xsl:" + context.getNamePool().getLocalName(context.getTemporaryOutputState())); err.setErrorCode("XTDE1480"); err.setLocation(getLocation()); throw err; } }
/** * Create a parentless namespace node. This function is useful in XQuery when namespaces need to be created * dynamically. The effect is the same as that of the xsl:namespace instruction in XSLT. * * @param context the dynamic evaluation context * @param prefix the name of the namespace node * @param uri the string value of the namespace node * @return the newly constructed namespace node */ public static NodeInfo namespaceNode(XPathContext context, String prefix, String uri) throws XPathException { if (prefix == null) { prefix = ""; } else if (!(prefix.length() == 0 || context.getConfiguration().getNameChecker().isValidNCName(prefix))) { throw new XPathException("Namespace prefix " + Err.wrap(prefix) + " is not a valid NCName"); } if (uri == null || uri.length() == 0) { throw new XPathException("URI of namespace node must not be empty"); } final NamePool namePool = context.getNamePool(); Orphan node = new Orphan(context.getConfiguration()); node.setNodeKind(Type.NAMESPACE); node.setNameCode(namePool.allocate("", "", prefix)); node.setStringValue(uri); return node; }
/** * Create a parentless namespace node. This function is useful in XQuery when namespaces need to be created * dynamically. The effect is the same as that of the xsl:namespace instruction in XSLT. * * @param context the dynamic evaluation context * @param prefix the name of the namespace node * @param uri the string value of the namespace node * @return the newly constructed namespace node */ public static NodeInfo namespaceNode(XPathContext context, String prefix, String uri) throws XPathException { if (prefix == null) { prefix = ""; } else if (!(prefix.length() == 0 || context.getConfiguration().getNameChecker().isValidNCName(prefix))) { throw new XPathException("Namespace prefix " + Err.wrap(prefix) + " is not a valid NCName"); } if (uri == null || uri.length() == 0) { throw new XPathException("URI of namespace node must not be empty"); } final NamePool namePool = context.getNamePool(); Orphan node = new Orphan(context.getConfiguration()); node.setNodeKind(Type.NAMESPACE); node.setNameCode(namePool.allocate("", "", prefix)); node.setStringValue(uri); return node; }
/** * Create a parentless namespace node. This function is useful in XQuery when namespaces need to be created * dynamically. The effect is the same as that of the xsl:namespace instruction in XSLT. * * @param context the dynamic evaluation context * @param prefix the name of the namespace node * @param uri the string value of the namespace node * @return the newly constructed namespace node */ public static NodeInfo namespaceNode(XPathContext context, String prefix, String uri) throws XPathException { if (prefix == null) { prefix = ""; } else if (!(prefix.length() == 0 || context.getConfiguration().getNameChecker().isValidNCName(prefix))) { throw new XPathException("Namespace prefix " + Err.wrap(prefix) + " is not a valid NCName"); } if (uri == null || uri.length() == 0) { throw new XPathException("URI of namespace node must not be empty"); } final NamePool namePool = context.getNamePool(); Orphan node = new Orphan(context.getConfiguration()); node.setNodeKind(Type.NAMESPACE); node.setNameCode(namePool.allocate("", "", prefix)); node.setStringValue(uri); return node; }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
/** * Return the type of the supplied value: "sequence", "string", "number", "boolean", * "external". (EXSLT spec not yet modified to cater for XPath 2.0 data model) */ public static String objectType(XPathContext context, Value value) { final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); ItemType type = value.getItemType(th); if (th.isSubType(type, AnyNodeTest.getInstance())) { return "node-set"; } else if (th.isSubType(type, BuiltInAtomicType.STRING)) { return "string"; } else if (th.isSubType(type, BuiltInAtomicType.NUMERIC)) { return "number"; } else if (th.isSubType(type, BuiltInAtomicType.BOOLEAN)) { return "boolean"; } else { return type.toString(context.getNamePool()); } }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
/** * Return the type of the supplied value: "sequence", "string", "number", "boolean", * "external". (EXSLT spec not yet modified to cater for XPath 2.0 data model) */ public static String objectType(XPathContext context, Value value) { final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); ItemType type = value.getItemType(th); if (th.isSubType(type, AnyNodeTest.getInstance())) { return "node-set"; } else if (th.isSubType(type, BuiltInAtomicType.STRING)) { return "string"; } else if (th.isSubType(type, BuiltInAtomicType.NUMERIC)) { return "number"; } else if (th.isSubType(type, BuiltInAtomicType.BOOLEAN)) { return "boolean"; } else { return type.toString(context.getNamePool()); } }
/** * Return the type of the supplied value: "sequence", "string", "number", "boolean", * "external". (EXSLT spec not yet modified to cater for XPath 2.0 data model) */ public static String objectType(XPathContext context, ValueRepresentation value) { final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); ItemType type = Value.asValue(value).getItemType(th); if (th.isSubType(type, AnyNodeTest.getInstance())) { return "node-set"; } else if (th.isSubType(type, BuiltInAtomicType.STRING)) { return "string"; } else if (th.isSubType(type, BuiltInAtomicType.NUMERIC)) { return "number"; } else if (th.isSubType(type, BuiltInAtomicType.BOOLEAN)) { return "boolean"; } else { return type.toString(context.getNamePool()); } }