/** * Get the value of the current attribute with a given name * * @param uri the uri of the name of the required attribute * @param local the local part of the name of the required attribute * @return the attribute value, or null if the attribute is not present */ public String getAttribute(String uri, String local) { return bufferedAttributes.getValue(uri, local); }
/** * Get the value of the current attribute with a given name * * @param uri the uri of the name of the required attribute * @param local the local part of the name of the required attribute * @return the attribute value, or null if the attribute is not present */ public String getAttribute(String uri, String local) { return bufferedAttributes.getValue(uri, local); }
/** * Get the value of an attribute (by lexnical QName). * * @param name The attribute name (a lexical QName). * The prefix must match the prefix originally used. This method is defined in SAX, but is * not recommended except where the prefix is null. */ /*@Nullable*/ public String getValue(/*@NotNull*/ String name) { int index = getIndex(name); return getValue(index); }
/** * Get the value of an attribute (by name). * * @param uri The namespace uri of the attribute. * @param localname The local name of the attribute. * @return The index position of the attribute */ /*@Nullable*/ public String getValue(String uri, String localname) { int index = findByName(uri, localname); return (index < 0 ? null : getValue(index)); }
/** * Get the attribute value using its fingerprint */ /*@Nullable*/ public String getValueByFingerprint(int fingerprint) { int index = findByFingerprint(fingerprint); return (index < 0 ? null : getValue(index)); }
/** * Get the value of an attribute (by name). * * @param uri The namespace uri of the attribute. * @param localname The local name of the attribute. * @return The index position of the attribute */ /*@Nullable*/ public String getValue(String uri, String localname) { int index = findByName(uri, localname); return (index < 0 ? null : getValue(index)); }
/** * Get the attribute value using its fingerprint */ /*@Nullable*/ public String getValueByFingerprint(int fingerprint) { int index = findByFingerprint(fingerprint); return (index < 0 ? null : getValue(index)); }
/** * Get the value of an attribute (by lexnical QName). * * @param name The attribute name (a lexical QName). * The prefix must match the prefix originally used. This method is defined in SAX, but is * not recommended except where the prefix is null. */ /*@Nullable*/ public String getValue(/*@NotNull*/ String name) { int index = getIndex(name); return getValue(index); }
/** * Index all the ID attributes. This is done the first time the id() function * is used on this document, or the first time that id() is called after a sequence of updates */ private void indexIDs() { if (idTable != null) { return; // ID's are already indexed } idTable = new HashMap<>(256); NodeImpl curr = this; NodeImpl root = curr; while (curr != null) { if (curr.getNodeKind() == Type.ELEMENT) { //noinspection ConstantConditions ElementImpl e = (ElementImpl) curr; if (e.isId()) { registerID(e, Whitespace.trim(e.getStringValueCS())); } AttributeCollectionImpl atts = (AttributeCollectionImpl) e.getAttributeList(); for (int i = 0; i < atts.getLength(); i++) { if (!atts.isDeleted(i) && atts.isId(i) && NameChecker.isValidNCName(Whitespace.trim(atts.getValue(i)))) { // don't index any invalid IDs - these can arise when using a non-validating parser registerID(e, Whitespace.trim(atts.getValue(i))); } } } curr = curr.getNextInDocument(root); } }
/** * Remove an attribute from this element node * <p>If this node is not an element, or if the specified node is not an attribute * of this element, this method takes no action.</p> * <p>The attribute object itself becomes unusable; any attempt to use this attribute object, * or any other object representing the same node, is likely to result in an exception.</p> * * @param attribute the attribute node to be removed */ public void removeAttribute(/*@NotNull*/ NodeInfo attribute) { if (!(attribute instanceof AttributeImpl)) { return; // no action } AttributeCollectionImpl atts = (AttributeCollectionImpl) getAttributeList(); int index = ((AttributeImpl) attribute).getSiblingPosition(); if (index >= 0 && atts.isId(index)) { DocumentImpl root = getPhysicalRoot(); root.deregisterID(atts.getValue(index)); } atts.removeAttribute(index); ((AttributeImpl) attribute).setRawParent(null); }
/** * Index all the ID attributes. This is done the first time the id() function * is used on this document, or the first time that id() is called after a sequence of updates */ private void indexIDs() { if (idTable != null) { return; // ID's are already indexed } idTable = new HashMap<>(256); NodeImpl curr = this; NodeImpl root = curr; while (curr != null) { if (curr.getNodeKind() == Type.ELEMENT) { //noinspection ConstantConditions ElementImpl e = (ElementImpl) curr; if (e.isId()) { registerID(e, Whitespace.trim(e.getStringValueCS())); } AttributeCollectionImpl atts = (AttributeCollectionImpl) e.getAttributeList(); for (int i = 0; i < atts.getLength(); i++) { if (!atts.isDeleted(i) && atts.isId(i) && NameChecker.isValidNCName(Whitespace.trim(atts.getValue(i)))) { // don't index any invalid IDs - these can arise when using a non-validating parser registerID(e, Whitespace.trim(atts.getValue(i))); } } } curr = curr.getNextInDocument(root); } }
/** * Remove an attribute from this element node * <p>If this node is not an element, or if the specified node is not an attribute * of this element, this method takes no action.</p> * <p>The attribute object itself becomes unusable; any attempt to use this attribute object, * or any other object representing the same node, is likely to result in an exception.</p> * * @param attribute the attribute node to be removed */ public void removeAttribute(/*@NotNull*/ NodeInfo attribute) { if (!(attribute instanceof AttributeImpl)) { return; // no action } AttributeCollectionImpl atts = (AttributeCollectionImpl) getAttributeList(); int index = ((AttributeImpl) attribute).getSiblingPosition(); if (index >= 0 && atts.isId(index)) { DocumentImpl root = getPhysicalRoot(); root.deregisterID(atts.getValue(index)); } atts.removeAttribute(index); ((AttributeImpl) attribute).setRawParent(null); }
String name = attributes.getLocalName(i); if (comparesEqual(name, "http-equiv")) { String value = Whitespace.trim(attributes.getValue(i)); if (value.equalsIgnoreCase("Content-Type")) { NodeName name = attributes.getNodeName(i); SimpleType typeCode = attributes.getTypeAnnotation(i); String value = attributes.getValue(i); Location locationId = attributes.getLocation(i); int properties = attributes.getProperties(i);
String name = attributes.getLocalName(i); if (comparesEqual(name, "http-equiv")) { String value = Whitespace.trim(attributes.getValue(i)); if (value.equalsIgnoreCase("Content-Type")) { NodeName name = attributes.getNodeName(i); SimpleType typeCode = attributes.getTypeAnnotation(i); String value = attributes.getValue(i); Location locationId = attributes.getLocation(i); int properties = attributes.getProperties(i);
/** * startContent: Add any namespace undeclarations needed to stop * namespaces being inherited from parent elements */ public void startContent() throws XPathException { inStartTag = false; int props = elementProperties | ReceiverOptions.NAMESPACE_OK; if (hasChildren) { props |= ReceiverOptions.HAS_CHILDREN; } nextReceiver.startElement(elementNameCode, elementTypeCode, elementLocationId, props); declareNamespacesForStartElement(); final int length = bufferedAttributes.getLength(); for (int i = 0; i < length; i++) { nextReceiver.attribute(bufferedAttributes.getNodeName(i), bufferedAttributes.getTypeAnnotation(i), bufferedAttributes.getValue(i), bufferedAttributes.getLocation(i), bufferedAttributes.getProperties(i) | ReceiverOptions.NAMESPACE_OK); } acceptAttributes = false; nextReceiver.startContent(); }
/** * startContent: Add any namespace undeclarations needed to stop * namespaces being inherited from parent elements */ public void startContent() throws XPathException { inStartTag = false; int props = elementProperties | ReceiverOptions.NAMESPACE_OK; if (hasChildren) { props |= ReceiverOptions.HAS_CHILDREN; } nextReceiver.startElement(elementNameCode, elementTypeCode, elementLocationId, props); declareNamespacesForStartElement(); final int length = bufferedAttributes.getLength(); for (int i = 0; i < length; i++) { nextReceiver.attribute(bufferedAttributes.getNodeName(i), bufferedAttributes.getTypeAnnotation(i), bufferedAttributes.getValue(i), bufferedAttributes.getLocation(i), bufferedAttributes.getProperties(i) | ReceiverOptions.NAMESPACE_OK); } acceptAttributes = false; nextReceiver.startContent(); }