if (nsprefix != null && "".equals(nsprefix.getValue())) { ns.addMappingAndRender( XMLNS, "", getNullNode(nsprefix.getOwnerDocument()));
ns.addMapping(XMLNS, "", getNullNode(xmlns.getOwnerDocument()));
XMLNS, "", getNullNode(xmlns.getOwnerDocument()));
XMLNS, "", getNullNode(xmlns.getOwnerDocument()));
public AttributeView(Attr attr) { super(attr.getOwnerDocument()); _attr = attr; }
/** */ private int getAttrNameCase(Attr attr) { DocumentImpl document = (DocumentImpl) attr.getOwnerDocument(); if (document == null) return DocumentTypeAdapter.STRICT_CASE; DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class); if (adapter == null) return DocumentTypeAdapter.STRICT_CASE; return adapter.getAttrNameCase(); }
/** * Returns true if this attribute is in a drawable document with one of the * root tags that require API 21 */ private static boolean isAlreadyWarnedDrawableFile(@NonNull XmlContext context, @NonNull Attr attribute, int attributeApiLevel) { // Don't complain if it's in a drawable file where we've already // flagged the root drawable type as being unsupported if (context.getResourceFolderType() == ResourceFolderType.DRAWABLE && attributeApiLevel == 21) { String root = attribute.getOwnerDocument().getDocumentElement().getTagName(); if (TAG_RIPPLE.equals(root) || TAG_VECTOR.equals(root) || TAG_ANIMATED_VECTOR.equals(root) || TAG_ANIMATED_SELECTOR.equals(root)) { return true; } } return false; }
protected boolean isAttrType(String typeName) { if (_value.getOwnerDocument().isSupported("Core", "3.0")) { return typeInfo(typeName); } return false; }
/** * Returns true if this attribute is in a drawable document with one of the * root tags that require API 21 */ private static boolean isAlreadyWarnedDrawableFile(@NonNull XmlContext context, @NonNull Attr attribute, int attributeApiLevel) { // Don't complain if it's in a drawable file where we've already // flagged the root drawable type as being unsupported if (context.getResourceFolderType() == ResourceFolderType.DRAWABLE && attributeApiLevel == 21) { String root = attribute.getOwnerDocument().getDocumentElement().getTagName(); if (TAG_RIPPLE.equals(root) || TAG_VECTOR.equals(root) || TAG_ANIMATED_VECTOR.equals(root) || TAG_ANIMATED_SELECTOR.equals(root)) { return true; } } return false; }
protected void runTest() throws Throwable { Document document = dbf.newDocumentBuilder().newDocument(); // Initialize element with original attribute Element element = document.createElementNS("urn:ns1", "test"); Attr attr1 = document.createAttributeNS("urn:ns2", "p:attr"); attr1.setValue("value1"); element.setAttributeNodeNS(attr1); // Replace attribute Attr attr2 = document.createAttributeNS("urn:ns2", "q:attr"); attr2.setValue("value2"); element.setAttributeNodeNS(attr2); assertNull(attr1.getOwnerElement()); assertSame(document, attr1.getOwnerDocument()); assertSame(element, attr2.getOwnerElement()); assertSame(document, attr2.getOwnerDocument()); assertEquals("value2", element.getAttributeNS("urn:ns2", "attr")); } }
public Attr setAttributeNodeNS( Attr newAttr ) throws DOMException { if (newAttr.getOwnerDocument() != getOwnerDocument()) throw new DOMException( DOMException.WRONG_DOCUMENT_ERR, "attribute must be from the same document as the element" ); ((AttrImpl) newAttr).setOwnerElement( this ); AttrImpl oldAttr = (AttrImpl) _attributes.put( newAttr.getName(), newAttr ); if (oldAttr != null) oldAttr.setOwnerElement( null ); return oldAttr; }
public Attr setAttributeNode( Attr newAttr ) throws DOMException { if (newAttr.getOwnerDocument() != getOwnerDocument()) throw new DOMException( DOMException.WRONG_DOCUMENT_ERR, "attribute must be from the same document as the element" ); ((AttrImpl) newAttr).setOwnerElement( this ); AttrImpl oldAttr = (AttrImpl) _attributes.put( newAttr.getName(), newAttr ); if (oldAttr != null) oldAttr.setOwnerElement( null ); return oldAttr; }
public Attr setAttributeNode( Attr newAttr ) throws DOMException { if (newAttr.getOwnerDocument() != getOwnerDocument()) throw new DOMException( DOMException.WRONG_DOCUMENT_ERR, "attribute must be from the same document as the element" ); ((AttrImpl) newAttr).setOwnerElement( this ); AttrImpl oldAttr = (AttrImpl) _attributes.put( newAttr.getName(), newAttr ); if (oldAttr != null) oldAttr.setOwnerElement( null ); return oldAttr; }
public Attr setAttributeNodeNS( Attr newAttr ) throws DOMException { if (newAttr.getOwnerDocument() != getOwnerDocument()) throw new DOMException( DOMException.WRONG_DOCUMENT_ERR, "attribute must be from the same document as the element" ); ((AttrImpl) newAttr).setOwnerElement( this ); AttrImpl oldAttr = (AttrImpl) _attributes.put( newAttr.getName(), newAttr ); if (oldAttr != null) oldAttr.setOwnerElement( null ); return oldAttr; }
public IPropertyDescriptor createAttributePropertyDescriptor(Attr attr) { IPropertyDescriptor result = null; String attributeName = attr.getName(); ModelQuery mq = ModelQueryUtil.getModelQuery(attr.getOwnerDocument()); CMAttributeDeclaration ad = null; if (mq != null) { ad = mq.getCMAttributeDeclaration(attr); } if (ad != null) { result = createPropertyDescriptorHelper(attributeName, attr.getOwnerElement(), ad); } if (result == null) { result = new TextPropertyDescriptor(attributeName, attributeName); } return result; }
/** * Applies the current prefix and URI to a given {@link Attr Attribute}. * * @param attribute * the {@link Attr Attribute} to modify * @return the modified {@link Attr Attribute} */ public Attr applyTo(final Attr attribute) { final String qualifiedName = getQualifiedNameFor(DOMUtils.getLocalName(attribute)); final Document ownerDocument = attribute.getOwnerDocument(); return (Attr) ownerDocument.renameNode(attribute, _nsURI, qualifiedName); }
public static CMNode getDeclaration(Node node) { CMNode decl = null; ModelQuery mq = null; switch (node.getNodeType()) { case Node.ATTRIBUTE_NODE : { mq = ModelQueryUtil.getModelQuery(((Attr) node).getOwnerDocument()); decl = mq.getCMAttributeDeclaration((Attr) node); } break; case Node.ELEMENT_NODE : { mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument()); decl = mq.getCMElementDeclaration((Element) node); } break; } return decl; }
protected void runTest() throws Throwable { String localName = qname.getLocalPart(); String uri = DOMUtils.getNamespaceURI(qname); String prefix = DOMUtils.getPrefix(qname); String name = DOMUtils.getQualifiedName(qname); Document doc = dbf.newDocumentBuilder().newDocument(); Attr attr = doc.createAttributeNS(uri, name); // Check name assertEquals("Attr name mismatch", localName, attr.getLocalName()); assertEquals("NamsspaceURI mismatch", uri, attr.getNamespaceURI()); assertEquals("namespace prefix mismatch", prefix, attr.getPrefix()); assertEquals(name, attr.getName()); // Check defaults assertSame(doc, attr.getOwnerDocument()); assertNull(attr.getOwnerElement()); assertNull(attr.getFirstChild()); assertEquals("", attr.getValue()); } }
public IPropertyDescriptor createAttributePropertyDescriptor(Attr attr) { IPropertyDescriptor result = null; String attributeName = attr.getName(); ModelQuery mq = ModelQueryUtil.getModelQuery(attr.getOwnerDocument()); if (mq != null) { CMAttributeDeclaration ad = mq.getCMAttributeDeclaration(attr); if (ad != null) { String[] valuesArray = mq.getPossibleDataTypeValues(attr.getOwnerElement(), ad); if ((valuesArray != null) && (valuesArray.length > 0)) { result = new EnumeratedStringPropertyDescriptor(attributeName, attributeName, valuesArray); } } } if (result == null) { result = createDefaultPropertyDescriptor(attributeName); } return result; }
protected void runTest() throws Throwable { Document document = dbf.newDocumentBuilder().newDocument(); Element element = document.createElementNS("urn:ns1", "p:element"); element.setAttributeNS(DOMUtils.getNamespaceURI(qname), DOMUtils.getQualifiedName(qname), value); assertTrue(element.hasAttributes()); NamedNodeMap attributes = element.getAttributes(); assertEquals(1, attributes.getLength()); Attr attr = (Attr)attributes.item(0); assertSame(document, attr.getOwnerDocument()); assertSame(element, attr.getOwnerElement()); assertEquals(DOMUtils.getNamespaceURI(qname), attr.getNamespaceURI()); assertEquals(DOMUtils.getPrefix(qname), attr.getPrefix()); assertEquals(qname.getLocalPart(), attr.getLocalName()); assertEquals(DOMUtils.getQualifiedName(qname), attr.getName()); assertEquals(value, attr.getValue()); assertSame(attr, element.getAttributeNodeNS(DOMUtils.getNamespaceURI(qname), qname.getLocalPart())); } }