/** * Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver * * @param resolver the NamespaceResolver */ public SavedNamespaceContext(/*@NotNull*/ NamespaceResolver resolver) { Iterator iter = resolver.iteratePrefixes(); while (iter.hasNext()) { String prefix = (String) iter.next(); String uri = resolver.getURIForPrefix(prefix, true); bindings.put(prefix, uri); } }
/** * Get the namespace URI corresponding to a given prefix. Return null * if the prefix is not in scope. * @param prefix the namespace prefix * @param useDefault true if the default namespace is to be used when the * prefix is "" * @return the uri for the namespace, or null if the prefix is not in scope */ public String getURIForPrefix(String prefix, boolean useDefault) { return resolver.getURIForPrefix(prefix, useDefault); }
/** * Get an iterator over all the prefixes declared in this namespace context. This will include * the default namespace (prefix="") and the XML namespace where appropriate */ public Iterator iteratePrefixes() { return resolver.iteratePrefixes(); }
/** * Get the namespace URI corresponding to a given prefix. Return null * if the prefix is not in scope. * @param prefix the namespace prefix * @param useDefault true if the default namespace is to be used when the * prefix is "" * @return the uri for the namespace, or null if the prefix is not in scope */ public String getURIForPrefix(String prefix, boolean useDefault) { return resolver.getURIForPrefix(prefix, useDefault); }
/** * Get an iterator over all the prefixes declared in this namespace context. This will include * the default namespace (prefix="") and the XML namespace where appropriate */ public Iterator<String> iteratePrefixes() { return resolver.iteratePrefixes(); }
/** * Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver * * @param resolver the NamespaceResolver */ public SavedNamespaceContext(/*@NotNull*/ NamespaceResolver resolver) { Iterator iter = resolver.iteratePrefixes(); while (iter.hasNext()) { String prefix = (String) iter.next(); String uri = resolver.getURIForPrefix(prefix, true); bindings.put(prefix, uri); } }
/** * Get the namespace URI corresponding to a given prefix. Return null * if the prefix is not in scope. * * @param prefix the namespace prefix * @param useDefault true if the default namespace is to be used when the * prefix is "" * @return the uri for the namespace, or null if the prefix is not in scope */ /*@Nullable*/ public String getURIForPrefix(String prefix, boolean useDefault) { return resolver.getURIForPrefix(prefix, useDefault); }
/** * Get an iterator over all the prefixes declared in this namespace context. This will include * the default namespace (prefix="") and the XML namespace where appropriate */ public Iterator<String> iteratePrefixes() { return resolver.iteratePrefixes(); }
/** * Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver * @param resolver the NamespaceResolver * @param pool the NamePool */ public SavedNamespaceContext(NamespaceResolver resolver, NamePool pool) { namePool = pool; ArrayList list = new ArrayList(); Iterator iter = resolver.iteratePrefixes(); while (iter.hasNext()) { String prefix = (String)iter.next(); String uri = resolver.getURIForPrefix(prefix, true); int nscode = pool.getNamespaceCode(prefix, uri); list.add(new Integer(nscode)); } namespaceCodes = new int[list.size()]; for (int i=0; i<list.size(); i++) { namespaceCodes[i] = ((Integer)list.get(i)).intValue(); } }
/** * Get the namespace URI corresponding to a given prefix. Return null * if the prefix is not in scope. * * @param prefix the namespace prefix * @param useDefault true if the default namespace is to be used when the * prefix is "" * @return the uri for the namespace, or null if the prefix is not in scope */ /*@Nullable*/ public String getURIForPrefix(String prefix, boolean useDefault) { return resolver.getURIForPrefix(prefix, useDefault); }
/** * Get an iterator over all the prefixes declared in this namespace context. This will include * the default namespace (prefix="") and the XML namespace where appropriate */ public Iterator iteratePrefixes() { return resolver.iteratePrefixes(); }
/** * Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver * @param resolver the NamespaceResolver * @param pool the NamePool */ public SavedNamespaceContext(NamespaceResolver resolver, NamePool pool) { namePool = pool; ArrayList list = new ArrayList(); Iterator iter = resolver.iteratePrefixes(); while (iter.hasNext()) { String prefix = (String)iter.next(); String uri = resolver.getURIForPrefix(prefix, true); int nscode = pool.getNamespaceCode(prefix, uri); list.add(new Integer(nscode)); } namespaceCodes = new int[list.size()]; for (int i=0; i<list.size(); i++) { namespaceCodes[i] = ((Integer)list.get(i)).intValue(); } }
/** * Implement the JAXP getNamespaceURI() method in terms of the Saxon-specific methods * * @param prefix a namespace prefix * @return the corresponding URI, if the prefix is bound, or "" otherwise */ public String getNamespaceURI(String prefix) { if (prefix.equals("xmlns")) { return "http://www.w3.org/2000/xmlns/"; } return resolver.getURIForPrefix(prefix, true); }
/** * Get an iterator over all the prefixes declared in this namespace context. This will include * the default namespace (prefix="") and the XML namespace where appropriate */ public Iterator iteratePrefixes() { return baseResolver.iteratePrefixes(); } }
/** * Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver * @param resolver the NamespaceResolver * @param pool the NamePool */ public SavedNamespaceContext(NamespaceResolver resolver, NamePool pool) { namePool = pool; ArrayList list = new ArrayList(); Iterator iter = resolver.iteratePrefixes(); while (iter.hasNext()) { String prefix = (String)iter.next(); String uri = resolver.getURIForPrefix(prefix, true); int nscode = pool.getNamespaceCode(prefix, uri); list.add(new Integer(nscode)); } namespaceCodes = new int[list.size()]; for (int i=0; i<list.size(); i++) { namespaceCodes[i] = ((Integer)list.get(i)).intValue(); } }
public String getNamespaceURI(String prefix) { if (prefix.equals("xmlns")) { return NamespaceConstant.XMLNS; } return ((NamespaceResolver)provider).getURIForPrefix(prefix, true); }
/** * Get an iterator over all the prefixes declared in this namespace context. This will include * the default namespace (prefix="") and the XML namespace where appropriate */ public Iterator iteratePrefixes() { if (externalResolver != null) { return externalResolver.iteratePrefixes(); } else { return namespaces.keySet().iterator(); } }
private void initializeNamespaces(XQueryExpression saxonQuery) { namespaceDeclarations.clear(); NamespaceResolver ns = saxonQuery.getStaticContext().getNamespaceResolver(); Iterator<String> prefixes = ns.iteratePrefixes(); while (prefixes.hasNext()) { String prefix = prefixes.next(); String nsURI = ns.getURIForPrefix(prefix, false); if (!(NamespaceConstant.isReservedInQuery(nsURI) || (prefix.equals("saxon") && nsURI.equals(NamespaceConstant.SAXON)) || (prefix.equals("local") && nsURI.equals(NamespaceConstant.LOCAL)) || (prefix.equals("err") && nsURI.equals(NamespaceConstant.ERR)) || (prefix.equals("lux") && nsURI.equals(FunCall.LUX_NAMESPACE)))) { namespaceDeclarations.put(prefix, nsURI); } } }
/** * Get the namespace URI of the n'th declaration (or undeclaration) in the list, * counting from zero. * * @param index the index identifying which declaration is required. * @return the namespace URI. For a namespace undeclaration, this is the * zero-length string. * @throws IndexOutOfBoundsException if the index is out of range. */ public String getURI(int index) { return resolver.getURIForPrefix((String)prefixes.get(index), true); }
/** * Get an iterator over all the prefixes declared in this namespace context. This method is implemented * only in the case where the NamespaceContext supplied using {@link #setNamespaceContext} is an * instance of Saxon's {@link NamespaceResolver} class. In other cases the method throws an * UnsupportedOperationException * @return an iterator over all the inscope namespace prefixes, if available * @throws UnsupportedOperationException if the NamespaceContext object is not a NamespaceResolver. */ public Iterator iteratePrefixes() { if (namespaceContext instanceof NamespaceResolver) { return ((NamespaceResolver)namespaceContext).iteratePrefixes(); } else { throw new UnsupportedOperationException(); } }