/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p>For a node other than an element, the method returns null.</p> */ public NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer) { return node.getDeclaredNamespaces(buffer); }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { return original.getDeclaredNamespaces(buffer); }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p>For a node other than an element, the method returns null.</p> */ public NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer) { return node.getDeclaredNamespaces(buffer); }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { return node.getDeclaredNamespaces(buffer); }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { return node.getDeclaredNamespaces(buffer); }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { return original.getDeclaredNamespaces(buffer); }
/** * Get the number of declared namespaces */ private int getNumberOfNamespaces() { if (numberOfNamespaces == -1) { int[] buffer = new int[8]; int[] nsList = parent.getDeclaredNamespaces(buffer); int count = nsList.length; for (int i=0; i<count; i++) { if (nsList[i] == -1) { count = i; break; } } numberOfNamespaces = count+1; //+1 for the XML namespace } return numberOfNamespaces; }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { return node.getDeclaredNamespaces(buffer); }
private NamespaceIterator(/*@NotNull*/ NodeInfo element) { this.element = element; undeclaredPrefixes = new HashSet<>(8); index = 0; localDeclarations = element.getDeclaredNamespaces(null); }
private NamespaceIterator(/*@NotNull*/ NodeInfo element) { this.element = element; undeclaredPrefixes = new HashSet<String>(8); index = 0; localDeclarations = element.getDeclaredNamespaces(null); }
private NamespaceCodeIterator(NodeInfo element) { this.element = element; undeclared = new IntHashSet(8); index = 0; localDeclarations = element.getDeclaredNamespaces(null); }
private NamespaceCodeIterator(NodeInfo element) { this.element = element; undeclared = new IntHashSet(8); index = 0; localDeclarations = element.getDeclaredNamespaces(null); }
/** * Get the number of declared namespaces * * @return the number of namespaces declared on the parent element */ private int getNumberOfNamespaces() { if (numberOfNamespaces == -1) { NamespaceBinding[] nsList = removeUndeclarations(parent.getDeclaredNamespaces(null)); int count = nsList.length; for (int i = 0; i < count; i++) { if (nsList[i] == null) { count = i; break; } } numberOfNamespaces = count + 1; //+1 for the XML namespace } return numberOfNamespaces; }
/** * Get the number of declared namespaces * * @return the number of namespaces declared on the parent element */ private int getNumberOfNamespaces() { if (numberOfNamespaces == -1) { NamespaceBinding[] nsList = removeUndeclarations(parent.getDeclaredNamespaces(null)); int count = nsList.length; for (int i = 0; i < count; i++) { if (nsList[i] == null) { count = i; break; } } numberOfNamespaces = count + 1; //+1 for the XML namespace } return numberOfNamespaces; }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { if (node == null) { tryToConstruct(); } return node.getDeclaredNamespaces(buffer); }
/** * Get all namespace undeclarations and undeclarations defined on this element. * * @param buffer If this is non-null, and the result array fits in this buffer, then the result * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap. * @return An array of integers representing the namespace declarations and undeclarations present on * this element. For a node other than an element, return null. Otherwise, the returned array is a * sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The * top half word of each namespace code represents the prefix, the bottom half represents the URI. * If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. * The XML namespace is never included in the list. If the supplied array is larger than required, * then the first unused entry will be set to -1. * <p/> * <p>For a node other than an element, the method returns null.</p> */ public int[] getDeclaredNamespaces(int[] buffer) { if (node == null) { tryToConstruct(); } return node.getDeclaredNamespaces(buffer); }
public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException { NodeInfo val = (NodeInfo) arguments[0].head(); NodeInfo parent = val.getParent(); return BooleanValue.get( parent == null || parent.getNodeKind() == Type.DOCUMENT || val.getDeclaredNamespaces(NamespaceBinding.EMPTY_ARRAY).length > 0); }
} else { return new NamespaceDeclarationsImpl(getNamePool(), currentNode.getDeclaredNamespaces(nsBuffer));
/** * Send all the in-scope namespaces for a node (except the XML namespace) to a specified receiver * * @param element the element in question (the method does nothing if this is not an element) * @param receiver the receiver to which the namespaces are notified * @throws XPathException if a failure is reported by the downstream Receiver */ public static void sendNamespaces(/*@NotNull*/ NodeInfo element, /*@NotNull*/ Receiver receiver) throws XPathException { if (element instanceof TinyNodeImpl && !((TinyNodeImpl)element).getTree().isUsesNamespaces()) { return; } while (element != null && element.getNodeKind() == Type.ELEMENT) { // find the first ancestor-or-self element that has namespace declarations, and send all its in-scope // namespaces to the receiver. The significance of this is that with shallow copy, the namespace set // will usually be the same as the parent element's namespace set, and will then be quickly discarded // by the ComplexContentOutputter. NamespaceBinding[] localNamespaces = element.getDeclaredNamespaces(null); if (localNamespaces.length > 0) { receiver.namespace(new InScopeNamespaces(element), 0); return; } element = element.getParent(); } // for (Iterator<NamespaceBinding> iter = iterateNamespaces(element); iter.hasNext(); ) { // NamespaceBinding nb = iter.next(); // receiver.namespace(nb, 0); // } }
/** * Send all the in-scope namespaces for a node (except the XML namespace) to a specified receiver * * @param element the element in question (the method does nothing if this is not an element) * @param receiver the receiver to which the namespaces are notified * @throws XPathException if a failure is reported by the downstream Receiver */ public static void sendNamespaces(/*@NotNull*/ NodeInfo element, /*@NotNull*/ Receiver receiver) throws XPathException { if (element instanceof TinyNodeImpl && !((TinyNodeImpl)element).getTree().isUsesNamespaces()) { return; } while (element != null && element.getNodeKind() == Type.ELEMENT) { // find the first ancestor-or-self element that has namespace declarations, and send all its in-scope // namespaces to the receiver. The significance of this is that with shallow copy, the namespace set // will usually be the same as the parent element's namespace set, and will then be quickly discarded // by the ComplexContentOutputter. NamespaceBinding[] localNamespaces = element.getDeclaredNamespaces(null); if (localNamespaces.length > 0) { receiver.namespace(new InScopeNamespaces(element), 0); return; } element = element.getParent(); } // for (Iterator<NamespaceBinding> iter = iterateNamespaces(element); iter.hasNext(); ) { // NamespaceBinding nb = iter.next(); // receiver.namespace(nb, 0); // } }