/** * Get the namespace URI matched by this nametest * * @return the namespace URI (using "" for the "null namepace") */ public String getNamespaceURI() { computeUriAndLocal(); return uri; }
/** * Get the local name matched by this nametest * * @return the local name */ public String getLocalPart() { computeUriAndLocal(); return localName; }
/** * Get the namespace URI matched by this nametest * * @return the namespace URI (using "" for the "null namepace") */ public String getNamespaceURI() { computeUriAndLocal(); return uri; }
/** * Get the local name matched by this nametest * * @return the local name */ public String getLocalPart() { computeUriAndLocal(); return localName; }
/** * Get the name of the nodes matched by this nodetest, if it matches a specific name. * Return null if the node test matches nodes of more than one name */ @Override public StructuredQName getMatchingNodeName() { computeUriAndLocal(); return new StructuredQName("", uri, localName); }
/** * Get the name of the nodes matched by this nodetest, if it matches a specific name. * Return null if the node test matches nodes of more than one name */ @Override public StructuredQName getMatchingNodeName() { computeUriAndLocal(); return new StructuredQName("", uri, localName); }
/** * Generate Javascript code to test if a name matches the test. * * @return JS code as a string. The generated code will be used * as the body of a JS function in which the argument name "q" is an * XdmQName object holding the name. The XdmQName object has properties * uri and local. * @param targetVersion the version of Saxon-JS being targeted */ public String generateJavaScriptNameTest(int targetVersion) { computeUriAndLocal(); return "q.uri==='" + ExpressionPresenter.jsEscape(uri) + "'&&q.local==='" + localName + "'"; }
/** * Generate Javascript code to test if a name matches the test. * * @return JS code as a string. The generated code will be used * as the body of a JS function in which the argument name "q" is an * XdmQName object holding the name. The XdmQName object has properties * uri and local. * @param targetVersion the version of Saxon-JS being targeted */ public String generateJavaScriptNameTest(int targetVersion) { computeUriAndLocal(); return "q.uri==='" + ExpressionPresenter.jsEscape(uri) + "'&&q.local==='" + localName + "'"; }
/** * Test whether the NameTest matches a given QName * * @param qname the QName to be matched * @return true if the name matches */ public boolean matches(StructuredQName qname) { computeUriAndLocal(); return qname.getLocalPart().equals(localName) && qname.hasURI(uri); }
/** * Test whether the NameTest matches a given QName * * @param qname the QName to be matched * @return true if the name matches */ public boolean matches(StructuredQName qname) { computeUriAndLocal(); return qname.getLocalPart().equals(localName) && qname.hasURI(uri); }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. * * @param node the node to be matched */ public boolean matchesNode(NodeInfo node) { if (node.getNodeKind() != nodeKind) { return false; } // Two different algorithms are used for name matching. If the fingerprint of the node is readily // available, we use it to do an integer comparison. Otherwise, we do string comparisons on the URI // and local name. In practice, Saxon's native node implementations use fingerprint matching, while // DOM and JDOM nodes use string comparison of names if (node.hasFingerprint()) { return node.getFingerprint() == fingerprint; } else { computeUriAndLocal(); return localName.equals(node.getLocalPart()) && uri.equals(node.getURI()); } }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. * * @param node the node to be matched */ public boolean matchesNode(NodeInfo node) { if (node.getNodeKind() != nodeKind) { return false; } // Two different algorithms are used for name matching. If the fingerprint of the node is readily // available, we use it to do an integer comparison. Otherwise, we do string comparisons on the URI // and local name. In practice, Saxon's native node implementations use fingerprint matching, while // DOM and JDOM nodes use string comparison of names if (node.hasFingerprint()) { return node.getFingerprint() == fingerprint; } else { computeUriAndLocal(); return localName.equals(node.getLocalPart()) && uri.equals(node.getURI()); } }
/** * Test whether this node test is satisfied by a given node. This method is only * fully supported for a subset of NodeTests, because it doesn't provide all the information * needed to evaluate all node tests. In particular (a) it can't be used to evaluate a node * test of the form element(N,T) or schema-element(E) where it is necessary to know whether the * node is nilled, and (b) it can't be used to evaluate a node test of the form * document-node(element(X)). This in practice means that it is used (a) to evaluate the * simple node tests found in the XPath 1.0 subset used in XML Schema, and (b) to evaluate * node tests where the node kind is known to be an attribute. * * @param nodeKind The kind of node to be matched * @param name identifies the expanded name of the node to be matched. * The value should be null for a node with no name. * @param annotation The actual content type of the node */ @Override public boolean matches(int nodeKind, NodeName name, SchemaType annotation) { if (nodeKind != this.nodeKind) { return false; } if (name.hasFingerprint()) { return name.getFingerprint() == this.fingerprint; } else { computeUriAndLocal(); return name.hasURI(uri) && name.getLocalPart().equals(localName); } }
/** * Test whether this node test is satisfied by a given node. This method is only * fully supported for a subset of NodeTests, because it doesn't provide all the information * needed to evaluate all node tests. In particular (a) it can't be used to evaluate a node * test of the form element(N,T) or schema-element(E) where it is necessary to know whether the * node is nilled, and (b) it can't be used to evaluate a node test of the form * document-node(element(X)). This in practice means that it is used (a) to evaluate the * simple node tests found in the XPath 1.0 subset used in XML Schema, and (b) to evaluate * node tests where the node kind is known to be an attribute. * * @param nodeKind The kind of node to be matched * @param name identifies the expanded name of the node to be matched. * The value should be null for a node with no name. * @param annotation The actual content type of the node */ @Override public boolean matches(int nodeKind, NodeName name, SchemaType annotation) { if (nodeKind != this.nodeKind) { return false; } if (name.hasFingerprint()) { return name.getFingerprint() == this.fingerprint; } else { computeUriAndLocal(); return name.hasURI(uri) && name.getLocalPart().equals(localName); } }
return "var q=SaxonJS.U.nameOfNode(item); return " + instNode + generateJavaScriptNameTest(targetVersion) + ";"; } else { computeUriAndLocal(); return "return " + instNode + "SaxonJS.U.hasLocalName(item,'" + localName + "')&&SaxonJS.U.hasURI(item,'" +
return "var q=SaxonJS.U.nameOfNode(item); return " + instNode + generateJavaScriptNameTest(targetVersion) + ";"; } else { computeUriAndLocal(); return "return " + instNode + "SaxonJS.U.hasLocalName(item,'" + localName + "')&&SaxonJS.U.hasURI(item,'" +