/** * Make a NamespaceTest (name:*) * * @param nodeType integer code identifying the type of node required * @param prefix the namespace prefix * @return the NamespaceTest, a pattern that matches all nodes in this * namespace * @throws XPathException if the namespace prefix is not declared */ /*@NotNull*/ public NamespaceTest makeNamespaceTest(short nodeType, String prefix) throws XPathException { NamePool pool = env.getConfiguration().getNamePool(); if (scanOnly) { // return an arbitrary namespace if we're only doing a syntax check return new NamespaceTest(pool, nodeType, NamespaceConstant.SAXON); } if (prefix.startsWith("Q{")) { String uri = prefix.substring(2, prefix.length() - 2); return new NamespaceTest(pool, nodeType, uri); } try { StructuredQName sq = qNameParser.parse(prefix + ":dummy"); return new NamespaceTest(pool, nodeType, sq.getURI()); } catch (XPathException err) { grumble(err.getMessage(), err.getErrorCodeLocalPart()); return null; } }
/** * Make a NamespaceTest (name:*) * * @param nodeType integer code identifying the type of node required * @param prefix the namespace prefix * @return the NamespaceTest, a pattern that matches all nodes in this * namespace * @throws XPathException if the namespace prefix is not declared */ /*@NotNull*/ public NamespaceTest makeNamespaceTest(short nodeType, String prefix) throws XPathException { NamePool pool = env.getConfiguration().getNamePool(); if (scanOnly) { // return an arbitrary namespace if we're only doing a syntax check return new NamespaceTest(pool, nodeType, NamespaceConstant.SAXON); } if (prefix.startsWith("Q{")) { String uri = prefix.substring(2, prefix.length() - 2); return new NamespaceTest(pool, nodeType, uri); } try { StructuredQName sq = qNameParser.parse(prefix + ":dummy"); return new NamespaceTest(pool, nodeType, sq.getURI()); } catch (XPathException err) { grumble(err.getMessage(), err.getErrorCodeLocalPart()); return null; } }
/** * Make a NamespaceTest (name:*) * * @param nodeType integer code identifying the type of node required * @param prefix the namespace prefix * @throws XPathException if the namespace prefix is not declared * @return the NamespaceTest, a pattern that matches all nodes in this * namespace */ public NamespaceTest makeNamespaceTest(short nodeType, String prefix) throws XPathException { if (scanOnly) { // return an arbitrary namespace if we're only doing a syntax check return new NamespaceTest(env.getNamePool(), nodeType, NamespaceConstant.SAXON); } try { return new NamespaceTest(env.getNamePool(), nodeType, env.getURIForPrefix(prefix)); } catch (XPathException e) { // env.getURIForPrefix can return a dynamic error grumble(e.getMessage(), "XPST0081"); return null; } }
/** * Make a NamespaceTest (name:*) * * @param nodeType integer code identifying the type of node required * @param prefix the namespace prefix * @throws XPathException if the namespace prefix is not declared * @return the NamespaceTest, a pattern that matches all nodes in this * namespace */ public NamespaceTest makeNamespaceTest(short nodeType, String prefix) throws XPathException { if (scanOnly) { // return an arbitrary namespace if we're only doing a syntax check return new NamespaceTest(env.getNamePool(), nodeType, NamespaceConstant.SAXON); } try { return new NamespaceTest(env.getNamePool(), nodeType, env.getURIForPrefix(prefix)); } catch (XPathException e) { // env.getURIForPrefix can return a dynamic error grumble(e.getMessage(), "XPST0081"); return null; } }
nt = new NamespaceTest( getNamePool(), Type.ELEMENT,
nt = new NamespaceTest( getNamePool(), Type.ELEMENT,
/** * Helper method to construct a NodeTest for use with the {@link NodeInfo#iterateAxis} method * @param pool the NamePool. The relevant NamePool can be obtained by calling the method * {@link NodeInfo#getNamePool}. * @param nodeKind The kind of node required, for example {@link Type#ELEMENT} or {@link Type#ATTRIBUTE}. * To select nodes of any kind, use {@link Type#NODE}. * @param uri The namespace URI of the nodes to be selected. Supply null to selects nodes from any * namespace or none. Supply "" to select nodes that are not in a namespace. * @param localName The local name of the nodes to be selected. Supply null to select nodes irrespective * of their local name. * @return a NodeTest that matches the requested nodes * @since 9.0 */ public static NodeTest makeNodeTest(NamePool pool, int nodeKind, String uri, String localName) { if (uri == null && localName == null) { return NodeKindTest.makeNodeKindTest(nodeKind); } else if (uri == null) { return new LocalNameTest(pool, nodeKind, localName); } else if (localName == null) { return new NamespaceTest(pool, nodeKind, uri); } else { int fp = pool.allocate("", uri, localName); return new NameTest(nodeKind, fp, pool); } }
/** * Helper method to construct a NodeTest for use with the {@link NodeInfo#iterateAxis} method * @param pool the NamePool. The relevant NamePool can be obtained by calling the method * {@link NodeInfo#getNamePool}. * @param nodeKind The kind of node required, for example {@link Type#ELEMENT} or {@link Type#ATTRIBUTE}. * To select nodes of any kind, use {@link Type#NODE}. * @param uri The namespace URI of the nodes to be selected. Supply null to selects nodes from any * namespace or none. Supply "" to select nodes that are not in a namespace. * @param localName The local name of the nodes to be selected. Supply null to select nodes irrespective * of their local name. * @return a NodeTest that matches the requested nodes * @since 9.0 */ public static NodeTest makeNodeTest(NamePool pool, int nodeKind, String uri, String localName) { if (uri == null && localName == null) { return NodeKindTest.makeNodeKindTest(nodeKind); } else if (uri == null) { return new LocalNameTest(pool, nodeKind, localName); } else if (localName == null) { return new NamespaceTest(pool, nodeKind, uri); } else { int fp = pool.allocate("", uri, localName); return new NameTest(nodeKind, fp, pool); } }
/** * Helper method to construct a NodeTest for use with the {@link NodeInfo#iterateAxis} method * * @param pool the NamePool. * @param nodeKind The kind of node required, for example {@link Type#ELEMENT} or {@link Type#ATTRIBUTE}. * To select nodes of any kind, use {@link Type#NODE}. * @param uri The namespace URI of the nodes to be selected. Supply null to selects nodes from any * namespace or none. Supply "" to select nodes that are not in a namespace. * @param localName The local name of the nodes to be selected. Supply null to select nodes irrespective * of their local name. * @return a NodeTest that matches the requested nodes * @since 9.0 */ /*@Nullable*/ public static NodeTest makeNodeTest(/*@NotNull*/ NamePool pool, int nodeKind, /*@Nullable*/ String uri, /*@Nullable*/ String localName) { if (uri == null && localName == null) { return NodeKindTest.makeNodeKindTest(nodeKind); } else if (uri == null) { return new LocalNameTest(pool, nodeKind, localName); } else if (localName == null) { return new NamespaceTest(pool, nodeKind, uri); } else { int fp = pool.allocateFingerprint(uri, localName); return new NameTest(nodeKind, fp, pool); } }
/** * Helper method to construct a NodeTest for use with the {@link NodeInfo#iterateAxis} method * * @param pool the NamePool. * @param nodeKind The kind of node required, for example {@link Type#ELEMENT} or {@link Type#ATTRIBUTE}. * To select nodes of any kind, use {@link Type#NODE}. * @param uri The namespace URI of the nodes to be selected. Supply null to selects nodes from any * namespace or none. Supply "" to select nodes that are not in a namespace. * @param localName The local name of the nodes to be selected. Supply null to select nodes irrespective * of their local name. * @return a NodeTest that matches the requested nodes * @since 9.0 */ /*@Nullable*/ public static NodeTest makeNodeTest(/*@NotNull*/ NamePool pool, int nodeKind, /*@Nullable*/ String uri, /*@Nullable*/ String localName) { if (uri == null && localName == null) { return NodeKindTest.makeNodeKindTest(nodeKind); } else if (uri == null) { return new LocalNameTest(pool, nodeKind, localName); } else if (localName == null) { return new NamespaceTest(pool, nodeKind, uri); } else { int fp = pool.allocateFingerprint(uri, localName); return new NameTest(nodeKind, fp, pool); } }
test = new NamespaceTest(getNamePool(), Type.ELEMENT, uri); addWildCardTest(componentTypeCode, test); } else if (tok.startsWith("Q{") && tok.endsWith("}*")) { final String uri = tok.substring(2, tok.length() - 2); test = new NamespaceTest(getNamePool(), Type.ELEMENT, uri); wildcardComponentTests.add(new ComponentTest(componentTypeCode, test, -1)); } else if (tok.startsWith("*:")) {
test = new NamespaceTest(getNamePool(), Type.ELEMENT, uri); addWildCardTest(componentTypeCode, test); } else if (tok.startsWith("Q{") && tok.endsWith("}*")) { final String uri = tok.substring(2, tok.length() - 2); test = new NamespaceTest(getNamePool(), Type.ELEMENT, uri); wildcardComponentTests.add(new ComponentTest(componentTypeCode, test, -1)); } else if (tok.startsWith("*:")) {
nt = new NamespaceTest( getNamePool(), Type.ELEMENT,
nt = new NamespaceTest( getNamePool(), Type.ELEMENT,
undeclaredNamespaceError(prefix, "XTSE0280", "elements"); nt = new NamespaceTest(getNamePool(), Type.ELEMENT, uri); rules.addRule(nt, preserve, decl.getModule(), decl.getSourceElement().getLineNumber());
undeclaredNamespaceError(prefix, "XTSE0280", "elements"); nt = new NamespaceTest(getNamePool(), Type.ELEMENT, uri); rules.addRule(nt, preserve, decl.getModule(), decl.getSourceElement().getLineNumber());