当前位置: 首页>>代码示例>>Java>>正文


Java Element.setAttributeNS方法代码示例

本文整理汇总了Java中org.w3c.dom.Element.setAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:Java Element.setAttributeNS方法的具体用法?Java Element.setAttributeNS怎么用?Java Element.setAttributeNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Element的用法示例。


在下文中一共展示了Element.setAttributeNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: namespace

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected void namespace(Element element, String prefix, String uri) {
    String qname;
    if ("".equals(prefix) || prefix == null) {
        qname = "xmlns";
    } else {
        qname = "xmlns:" + prefix;
    }

    // older version of Xerces (I confirmed that the bug is gone with Xerces 2.4.0)
    // have a problem of re-setting the same namespace attribute twice.
    // work around this bug removing it first.
    if (element.hasAttributeNS("http://www.w3.org/2000/xmlns/", qname)) {
        // further workaround for an old Crimson bug where the removeAttribtueNS
        // method throws NPE when the element doesn't have any attribute.
        // to be on the safe side, check the existence of attributes before
        // attempting to remove it.
        // for details about this bug, see org.apache.crimson.tree.ElementNode2
        // line 540 or the following message:
        // https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=2767
        element.removeAttributeNS("http://www.w3.org/2000/xmlns/", qname);
    }
    // workaround until here

    element.setAttributeNS("http://www.w3.org/2000/xmlns/", qname, uri);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SAX2DOMEx.java

示例2: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    EncryptedType et = (EncryptedType) xmlObject;

    if (et.getID() != null) {
        domElement.setAttributeNS(null, EncryptedType.ID_ATTRIB_NAME, et.getID());
        domElement.setIdAttributeNS(null, EncryptedType.ID_ATTRIB_NAME, true);
    }

    if (et.getType() != null) {
        domElement.setAttributeNS(null, EncryptedType.TYPE_ATTRIB_NAME, et.getType());
    }

    if (et.getMimeType() != null) {
        domElement.setAttributeNS(null, EncryptedType.MIMETYPE_ATTRIB_NAME, et.getMimeType());
    }

    if (et.getEncoding() != null) {
        domElement.setAttributeNS(null, EncryptedType.ENCODING_ATTRIB_NAME, et.getEncoding());
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:EncryptedTypeMarshaller.java

示例3: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    PolicyReference pr = (PolicyReference) xmlObject;
    
    if (pr.getURI() != null) {
        domElement.setAttributeNS(null, PolicyReference.URI_ATTRIB_NAME, pr.getURI());
    }
    
    if (pr.getDigest() != null) {
        domElement.setAttributeNS(null, PolicyReference.DIGEST_ATTRIB_NAME, pr.getDigest());
    }
    
    if (pr.getDigestAlgorithm() != null) {
        domElement.setAttributeNS(null, PolicyReference.DIGEST_ALGORITHM_ATTRIB_NAME, pr.getDigestAlgorithm());
    }
    
    XMLHelper.marshallAttributeMap(pr.getUnknownAttributes(), domElement);
    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:PolicyReferenceMarshaller.java

示例4: toElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
Element toElement() {
    Element result =
        XMLUtils.createElementInEncryptionSpace(
            contextDocument, EncryptionConstants._TAG_ENCRYPTIONPROPERTY
        );
    if (null != target) {
        result.setAttributeNS(null, EncryptionConstants._ATT_TARGET, target);
    }
    if (null != id) {
        result.setAttributeNS(null, EncryptionConstants._ATT_ID, id);
    }
    // TODO: figure out the anyAttribyte stuff...
    // TODO: figure out the any stuff...

    return result;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:XMLCipher.java

示例5: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    AttributeValueType attributeValue = (AttributeValueType) xmlObject;

    if(!DatatypeHelper.isEmpty(attributeValue.getDataType())){
    	domElement.setAttributeNS(null,AttributeAssignmentType.DATA_TYPE_ATTRIB_NAME, attributeValue.getDataType());
    }
    
    Attr attribute;
    for (Entry<QName, String> entry : attributeValue.getUnknownAttributes().entrySet()) {
        attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
        attribute.setValue(entry.getValue());
        domElement.setAttributeNodeNS(attribute);
        if (Configuration.isIDAttribute(entry.getKey())
                || attributeValue.getUnknownAttributes().isIDAttribute(entry.getKey())) {
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AttributeValueTypeMarshaller.java

示例6: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    NameIDPolicy policy = (NameIDPolicy) samlObject;

    if (policy.getFormat() != null) {
        domElement.setAttributeNS(null, NameIDPolicy.FORMAT_ATTRIB_NAME, policy.getFormat());
    }

    if (policy.getSPNameQualifier() != null) {
        domElement.setAttributeNS(null, NameIDPolicy.SP_NAME_QUALIFIER_ATTRIB_NAME, policy.getSPNameQualifier());
    }

    if (policy.getAllowCreateXSBoolean() != null) {
        domElement.setAttributeNS(null, NameIDPolicy.ALLOW_CREATE_ATTRIB_NAME, policy.getAllowCreateXSBoolean()
                .toString());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:NameIDPolicyMarshaller.java

示例7: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    NamedCurve nc = (NamedCurve) xmlObject;

    if (nc.getURI() != null) {
        domElement.setAttributeNS(null, NamedCurve.URI_ATTRIB_NAME, nc.getURI());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:NamedCurveMarshaller.java

示例8: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {

    AttributeQuery attributeQuery = (AttributeQuery) samlElement;

    if (attributeQuery.getResource() != null) {
        domElement.setAttributeNS(null, AttributeQuery.RESOURCE_ATTRIB_NAME, attributeQuery.getResource());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AttributeQueryMarshaller.java

示例9: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    ECKeyValue ec = (ECKeyValue) xmlObject;

    if (ec.getID() != null) {
        domElement.setAttributeNS(null, ECKeyValue.ID_ATTRIB_NAME, ec.getID());
        domElement.setIdAttributeNS(null, ECKeyValue.ID_ATTRIB_NAME, true);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ECKeyValueMarshaller.java

示例10: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    X509Digest xd = (X509Digest) xmlObject;

    if (xd.getAlgorithm() != null) {
        domElement.setAttributeNS(null, X509Digest.ALGORITHM_ATTRIB_NAME, xd.getAlgorithm());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:X509DigestMarshaller.java

示例11: circumventBug2650

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * This method spreads all namespace attributes in a DOM document to their
 * children. This is needed because the XML Signature XPath transform
 * must evaluate the XPath against all nodes in the input, even against
 * XPath namespace nodes. Through a bug in XalanJ2, the namespace nodes are
 * not fully visible in the Xalan XPath model, so we have to do this by
 * hand in DOM spaces so that the nodes become visible in XPath space.
 *
 * @param doc
 * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">
 * Namespace axis resolution is not XPath compliant </A>
 */
public static void circumventBug2650(Document doc) {

    Element documentElement = doc.getDocumentElement();

    // if the document element has no xmlns definition, we add xmlns=""
    Attr xmlnsAttr =
        documentElement.getAttributeNodeNS(Constants.NamespaceSpecNS, "xmlns");

    if (xmlnsAttr == null) {
        documentElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", "");
    }

    XMLUtils.circumventBug2650internal(doc);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:XMLUtils.java

示例12: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    DEREncodedKeyValue der = (DEREncodedKeyValue) xmlObject;

    if (der.getID() != null) {
        domElement.setAttributeNS(null, DEREncodedKeyValue.ID_ATTRIB_NAME, der.getID());
        domElement.setIdAttributeNS(null, DEREncodedKeyValue.ID_ATTRIB_NAME, true);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DEREncodedKeyValueMarshaller.java

示例13: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
    AttributeAssignmentType attributeAssignment = (AttributeAssignmentType) samlElement;

    if (!DatatypeHelper.isEmpty(attributeAssignment.getAttributeId())) {
        domElement.setAttributeNS(null, AttributeAssignmentType.ATTR_ID_ATTRIB_NAME, attributeAssignment
                .getAttributeId());
    }
    if(!DatatypeHelper.isEmpty(attributeAssignment.getDataType())){
    	super.marshallAttributes(samlElement, domElement);
    }
    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AttributeAssignmentTypeMarshaller.java

示例14: marshallAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
    NameIdentifier nameIdentifier = (NameIdentifier) samlElement;

    if (nameIdentifier.getNameQualifier() != null) {
        domElement
                .setAttributeNS(null, NameIdentifier.NAMEQUALIFIER_ATTRIB_NAME, nameIdentifier.getNameQualifier());
    }

    if (nameIdentifier.getFormat() != null) {
        domElement.setAttributeNS(null, NameIdentifier.FORMAT_ATTRIB_NAME, nameIdentifier.getFormat());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:NameIdentifierMarshaller.java

示例15: getEmbeddedImageElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * 
 */
protected Element getEmbeddedImageElement(String src)
{
	Element img = images.get(src);

	if (img == null)
	{
		img = document.createElement("svg");
		img.setAttribute("width", "100%");
		img.setAttribute("height", "100%");

		Element inner = document.createElement("image");
		inner.setAttribute("width", "100%");
		inner.setAttribute("height", "100%");

		// Store before transforming to DataURL
		images.put(src, img);

		if (!src.startsWith("data:image/"))
		{
			try
			{
				String tmp = createDataUrl(src);
				
				if (tmp != null)
				{
					src = tmp;
				}
			}
			catch (IOException e)
			{
				// ignore
			}
		}

		inner.setAttributeNS(mxConstants.NS_XLINK, "xlink:href", src);
		img.appendChild(inner);
		img.setAttribute("id", "i" + (images.size()));
		getDefsElement().appendChild(img);
	}

	return img;
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:46,代码来源:mxSvgCanvas.java


注:本文中的org.w3c.dom.Element.setAttributeNS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。