public String toShortString() { switch (nodeKind) { case Type.ELEMENT: return getNamespaceURI().isEmpty() ? namePool.getLocalName(getFingerprint()) : toString(); case Type.ATTRIBUTE: return "@" + (getNamespaceURI().isEmpty() ? namePool.getLocalName(getFingerprint()) : toString()); default: return toString(); } }
/** * Make a NameTest, using the static context for namespace resolution * * @param nodeType the type of node required (identified by a constant in * class Type) * @param qname the lexical QName of the required node * @param useDefault true if the default namespace should be used when * the QName is unprefixed * @throws XPathException if the QName is invalid * @return a NameTest, representing a pattern that tests for a node of a * given node kind and a given name */ public NameTest makeNameTest(short nodeType, String qname, boolean useDefault) throws XPathException { int nameCode = makeNameCode(qname, useDefault); return new NameTest(nodeType, nameCode, env.getNamePool()); }
public String generateJavaScriptItemTypeTest(ItemType knownToBe, int targetVersion) { boolean knownKind = knownToBe.getUType() == this.getUType(); if (nodeKind == Type.ATTRIBUTE && getNamespaceURI().equals("")) { String nt = "item.name==='" + getLocalPart() + "'"; return "return " + (knownKind ? nt : "SaxonJS.U.isAttr(item) && " + nt); 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,'" +
public PrecedingAxisIterator(XOMNodeWrapper start, boolean includeAncestors, NodeTest test) { this.start = start; this.includeAncestors = includeAncestors; currNode = start.node; nextAncestor = includeAncestors ? null : start.node.getParent(); if (test == AnyNodeTest.getInstance()) { // performance hack test = null; // mark as AnyNodeTest } else if (test instanceof NameTest) { NameTest nt = (NameTest) test; if (nt.getPrimitiveType() == Type.ELEMENT) { // performance hack // mark as element name test NamePool pool = getNamePool(); testLocalName = pool.getLocalName(nt.getFingerprint()); testURI = pool.getURI(nt.getFingerprint()); } } else if (test instanceof NodeKindTest) { if (test.getPrimitiveType() == Type.ELEMENT) { // performance hack // mark as element type test testLocalName = ""; testURI = null; } } nodeTest = test; position = 0; }
index = attlist.getIndexByFingerprint(test.getFingerprint());
NameTest nt = (NameTest) test; if (start.hasFingerprint()) { stepper = new FollowingFingerprintedElementStepper<>(start, nt.getFingerprint()); } else { stepper = new FollowingElementStepper<>(start, nt.getNamespaceURI(), nt.getLocalPart());
QName childName = getQualifiedName(nameTest.getFingerprint(), namePool, contextUris); if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) { break; if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) { break;
/** * Get the namespace URI matched by this nametest * * @return the namespace URI (using "" for the "null namepace") */ public String getNamespaceURI() { computeUriAndLocal(); return uri; }
public SymbolicName getSymbolicNameIfExplicit() { if (nameTest instanceof NameTest) { if (componentKind == StandardNames.XSL_FUNCTION) { return new SymbolicName.F(((NameTest)nameTest).getMatchingNodeName(), arity); } else { return new SymbolicName(componentKind, ((NameTest) nameTest).getMatchingNodeName()); } } else { return null; } }
public String toString() { return toString(namePool); }
public void addRule(NodeTestPattern pattern, Stripper.StripRuleTarget action, int precedence, int minImportPrecedence) throws XPathException { NodeTest test = pattern.getNodeTest(); double priority = test.getDefaultPriority(); Rule newRule = new Rule(pattern, action, precedence, minImportPrecedence, priority, sequence++); int prio = priority == 0 ? 2 : priority == -0.25 ? 1 : 0; newRule.setRank((precedence << 18) + (prio << 16) + sequence); if (test instanceof NodeKindTest) { newRule.setAlwaysMatches(true); anyElementRule = addRuleToList(newRule, anyElementRule, true); } else if (test instanceof NameTest) { newRule.setAlwaysMatches(true); int fp = test.getFingerprint(); CodedName key = new CodedName(fp, "", ((NameTest) test).getNamePool()); Rule chain = namedElementRules.get(key); namedElementRules.put(key, addRuleToList(newRule, chain, true)); } else { unnamedElementRuleChain = addRuleToList(newRule, unnamedElementRuleChain, false); } }
index = attlist.getIndexByFingerprint(test.getFingerprint());
NameTest nt = (NameTest) test; if (start.hasFingerprint()) { stepper = new FollowingFingerprintedElementStepper<>(start, nt.getFingerprint()); } else { stepper = new FollowingElementStepper<>(start, nt.getNamespaceURI(), nt.getLocalPart());
/** * Get the local name matched by this nametest * * @return the local name */ public String getLocalPart() { computeUriAndLocal(); return localName; }
public SymbolicName getSymbolicNameIfExplicit() { if (nameTest instanceof NameTest) { if (componentKind == StandardNames.XSL_FUNCTION) { return new SymbolicName.F(((NameTest)nameTest).getMatchingNodeName(), arity); } else { return new SymbolicName(componentKind, ((NameTest) nameTest).getMatchingNodeName()); } } else { return null; } }
public String toString() { return toString(namePool); }
public void addRule(NodeTestPattern pattern, Stripper.StripRuleTarget action, int precedence, int minImportPrecedence) throws XPathException { NodeTest test = pattern.getNodeTest(); double priority = test.getDefaultPriority(); Rule newRule = new Rule(pattern, action, precedence, minImportPrecedence, priority, sequence++); int prio = priority == 0 ? 2 : priority == -0.25 ? 1 : 0; newRule.setRank((precedence << 18) + (prio << 16) + sequence); if (test instanceof NodeKindTest) { newRule.setAlwaysMatches(true); anyElementRule = addRuleToList(newRule, anyElementRule, true); } else if (test instanceof NameTest) { newRule.setAlwaysMatches(true); int fp = test.getFingerprint(); NamePool pool = ((NameTest) test).getNamePool(); FingerprintedQName key = new FingerprintedQName(pool.getUnprefixedQName(fp), pool); Rule chain = namedElementRules.get(key); namedElementRules.put(key, addRuleToList(newRule, chain, true)); } else { unnamedElementRuleChain = addRuleToList(newRule, unnamedElementRuleChain, false); } }
/** * Make a NameTest, using the static context for namespace resolution * * @param nodeType the type of node required (identified by a constant in * class Type) * @param qname the lexical QName of the required node * @param useDefault true if the default namespace should be used when * the QName is unprefixed * @throws XPathException if the QName is invalid * @return a NameTest, representing a pattern that tests for a node of a * given node kind and a given name */ public NameTest makeNameTest(short nodeType, String qname, boolean useDefault) throws XPathException { int nameCode = makeNameCode(qname, useDefault); return new NameTest(nodeType, nameCode, env.getNamePool()); }
private FunctionDefinition[] getFunctionDefinitions() { ArrayList<FunctionDefinition> functionDefinitions = new ArrayList<FunctionDefinition>(); Iterator<XQueryFunction> functions = queryModule.getLocalFunctionLibrary().getFunctionDefinitions(); while (functions.hasNext()) { XQueryFunction function = functions.next(); UserFunctionParameter[] params = function.getParameterDefinitions(); Variable[] args = new Variable[params.length]; for (int i = 0; i < params.length; i++) { QName argname = qnameFor (params[i].getVariableQName()); addNamespaceDeclaration(argname); args[i] = new Variable (argname, getTypeDescription(params[i].getRequiredType())); } QName fname = qnameFor(function.getFunctionName()); addNamespaceDeclaration(fname); SequenceType resultType = function.getResultType(); ItemType returnType = resultType.getPrimaryType(); QName returnTypeName = null; if (returnType instanceof NameTest) { returnTypeName = qnameForNameCode (((NameTest) returnType).getFingerprint()); } FunctionDefinition fdef = new FunctionDefinition(fname, valueTypeForItemType(resultType.getPrimaryType()), cardinalityOf(resultType), returnTypeName, args, exprFor (function.getBody())); functionDefinitions.add (fdef); } return functionDefinitions.toArray(new FunctionDefinition[0]); }
public String generateJavaScriptItemTypeTest(ItemType knownToBe, int targetVersion) { boolean knownKind = knownToBe.getUType() == this.getUType(); if (nodeKind == Type.ATTRIBUTE && getNamespaceURI().equals("")) { String nt = "item.name==='" + getLocalPart() + "'"; return "return " + (knownKind ? nt : "SaxonJS.U.isAttr(item) && " + nt); 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,'" +