org.w3c.dom.Element.setIdAttributeNode()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中org.w3c.dom.Element.setIdAttributeNode()方法的一些代码示例,展示了Element.setIdAttributeNode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setIdAttributeNode()方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:setIdAttributeNode

Element.setIdAttributeNode介绍

[英]If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.
[中]如果参数isIdtrue,则此方法将指定的属性声明为用户确定的ID属性。这会影响Attr.isId的值和Document.getElementById的行为,但不会更改可能正在使用的任何架构,尤其是不会影响指定Attr节点的Attr.schemaTypeInfo。使用参数isId的值false取消声明属性,使其成为用户确定的ID属性。

代码示例

代码示例来源:origin: plutext/docx4j

/**
 * Method registerElementById
 *
 * @param element the element to register
 * @param id the ID attribute
 */
public static void registerElementById(Element element, Attr id) {
  element.setIdAttributeNode(id, true);
}

代码示例来源:origin: plutext/docx4j

protected void setLocalIdAttribute(String attrName, String value) {
  
  if (value != null) {
    Attr attr = getDocument().createAttributeNS(null, attrName);
    attr.setValue(value);
    getElement().setAttributeNodeNS(attr);
    getElement().setIdAttributeNode(attr, true);
  }
  else {
    getElement().removeAttributeNS(null, attrName);
  }
}

代码示例来源:origin: org.apache.santuario/xmlsec

/**
 * Method registerElementById
 *
 * @param element the element to register
 * @param id the ID attribute
 */
public static void registerElementById(Element element, Attr id) {
  element.setIdAttributeNode(id, true);
}

代码示例来源:origin: org.apache.santuario/xmlsec

@Override
public void writeIdAttribute(String prefix, String namespaceURI, String localName, String value) {
  if (value == null) {
    return;
  }
  Attr newAttr = writeAttribute(prefix, namespaceURI, localName, value);
  ( (Element)currentNode).setIdAttributeNode(newAttr, true);
}

代码示例来源:origin: org.opensingular/singular-commons

/**
 * @see org.w3c.dom.Element#setIdAttributeNode(org.w3c.dom.Attr, boolean)
 */
public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
  getCurrentInternal().setIdAttributeNode(idAttr, isId);
}

代码示例来源:origin: org.opensingular/singular-commons

/**
 * @see org.w3c.dom.Element#setIdAttributeNode(org.w3c.dom.Attr, boolean)
 */
@Override
public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
  original.get().setIdAttributeNode(idAttr, isId);
}

代码示例来源:origin: org.opensaml/xmltooling

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  KeyInfoType keyInfo = (KeyInfoType) xmlObject;
  if (attribute.getLocalName().equals(KeyInfoType.ID_ATTRIB_NAME)) {
    keyInfo.setID(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    super.processAttribute(xmlObject, attribute);
  }
}

代码示例来源:origin: io.apigee.opensaml/xmltooling

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  ECKeyValue ec = (ECKeyValue) xmlObject;
  if (attribute.getLocalName().equals(ECKeyValue.ID_ATTRIB_NAME)) {
    ec.setID(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    super.processAttribute(xmlObject, attribute);
  }
}

代码示例来源:origin: io.apigee.opensaml/xmltooling

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  KeyInfoType keyInfo = (KeyInfoType) xmlObject;
  if (attribute.getLocalName().equals(KeyInfoType.ID_ATTRIB_NAME)) {
    keyInfo.setID(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    super.processAttribute(xmlObject, attribute);
  }
}

代码示例来源:origin: io.apigee.opensaml/xmltooling

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  EncryptionProperties ep = (EncryptionProperties) xmlObject;
  if (attribute.getLocalName().equals(EncryptionProperties.ID_ATTRIB_NAME)) {
    ep.setID(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    super.processAttribute(xmlObject, attribute);
  }
}

代码示例来源:origin: io.apigee.opensaml/xmltooling

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  KeyInfoReference ref = (KeyInfoReference) xmlObject;
  if (attribute.getLocalName().equals(KeyInfoReference.ID_ATTRIB_NAME)) {
    ref.setID(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else if (attribute.getLocalName().equals(KeyInfoReference.URI_ATTRIB_NAME)) {
    ref.setURI(attribute.getValue());
  } else {
    super.processAttribute(xmlObject, attribute);
  }
}

代码示例来源:origin: org.opensaml/openws

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  AttributedString attributedString = (AttributedString) xmlObject;
  
  QName attribQName = 
    XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (AttributedString.WSU_ID_ATTR_NAME.equals(attribQName)) {
    attributedString.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLHelper.unmarshallToAttributeMap(attributedString.getUnknownAttributes(), attribute);
  }
}

代码示例来源:origin: org.opensaml/opensaml-soap-impl

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  AttributedString attributedString = (AttributedString) xmlObject;
  
  QName attribQName = 
    QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (AttributedString.WSU_ID_ATTR_NAME.equals(attribQName)) {
    attributedString.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLObjectSupport.unmarshallToAttributeMap(attributedString.getUnknownAttributes(), attribute);
  }
}

代码示例来源:origin: org.opensaml/openws

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  AttributedURI attributedURI = (AttributedURI) xmlObject;
  
  QName attribQName = 
    XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (AttributedURI.WSU_ID_ATTR_NAME.equals(attribQName)) {
    attributedURI.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLHelper.unmarshallToAttributeMap(attributedURI.getUnknownAttributes(), attribute);
  }
}

代码示例来源:origin: org.opensaml/opensaml-soap-impl

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  AttributedURI attributedURI = (AttributedURI) xmlObject;
  
  QName attribQName = 
    QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (AttributedURI.WSU_ID_ATTR_NAME.equals(attribQName)) {
    attributedURI.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLObjectSupport.unmarshallToAttributeMap(attributedURI.getUnknownAttributes(), attribute);
  }
}

代码示例来源:origin: org.opensaml/opensaml-soap-impl

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  UsernameToken token = (UsernameToken) xmlObject;
  
  QName attribQName = 
    QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (UsernameToken.WSU_ID_ATTR_NAME.equals(attribQName)) {
    token.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLObjectSupport.unmarshallToAttributeMap(token.getUnknownAttributes(), attribute);
  }
}

代码示例来源:origin: org.opensaml/opensaml-soap-impl

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  Timestamp timestamp = (Timestamp) xmlObject;
  
  QName attrName =
    QNameSupport.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (Timestamp.WSU_ID_ATTR_NAME.equals(attrName)) {
    timestamp.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLObjectSupport.unmarshallToAttributeMap(timestamp.getUnknownAttributes(), attribute);
  }
  
}

代码示例来源:origin: org.opensaml/openws

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  Timestamp timestamp = (Timestamp) xmlObject;
  
  QName attrName =
    XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (Timestamp.WSU_ID_ATTR_NAME.equals(attrName)) {
    timestamp.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLHelper.unmarshallToAttributeMap(timestamp.getUnknownAttributes(), attribute);
  }
  
}

代码示例来源:origin: org.opensaml/openws

/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
  AttributedDateTime dateTime = (AttributedDateTime) xmlObject;
  
  QName attrName =
    XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
  if (AttributedDateTime.WSU_ID_ATTR_NAME.equals(attrName)) {
    dateTime.setWSUId(attribute.getValue());
    attribute.getOwnerElement().setIdAttributeNode(attribute, true);
  } else {
    XMLHelper.unmarshallToAttributeMap(dateTime.getUnknownAttributes(), attribute);
  }
}

代码示例来源:origin: org.apache.santuario/xmlsec

protected void setLocalIdAttribute(String attrName, String value) {
  if (value != null) {
    Attr attr = getDocument().createAttributeNS(null, attrName);
    attr.setValue(value);
    getElement().setAttributeNodeNS(attr);
    getElement().setIdAttributeNode(attr, true);
  }
  else {
    getElement().removeAttributeNS(null, attrName);
  }
}

相关文章

微信公众号

最新文章

更多