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


Java Element.setIdAttributeNode方法代码示例

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


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

示例1: SignatureProperties

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Constructs {@link SignatureProperties} from {@link Element}
 * @param element <code>SignatureProperties</code> element
 * @param BaseURI the URI of the resource where the XML instance was stored
 * @throws XMLSecurityException
 */
public SignatureProperties(Element element, String BaseURI) throws XMLSecurityException {
    super(element, BaseURI);

    Attr attr = element.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        element.setIdAttributeNode(attr, true);
    }

    int length = getLength();
    for (int i = 0; i < length; i++) {
        Element propertyElem =
            XMLUtils.selectDsNode(this.constructionElement, Constants._TAG_SIGNATUREPROPERTY, i);
        Attr propertyAttr = propertyElem.getAttributeNodeNS(null, "Id");
        if (propertyAttr != null) {
            propertyElem.setIdAttributeNode(propertyAttr, true);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SignatureProperties.java

示例2: DOMSignatureValue

import org.w3c.dom.Element; //导入方法依赖的package包/类
DOMSignatureValue(Element sigValueElem, XMLCryptoContext context)
    throws MarshalException
{
    try {
        // base64 decode signatureValue
        value = Base64.decode(sigValueElem);
    } catch (Base64DecodingException bde) {
        throw new MarshalException(bde);
    }

    Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        id = attr.getValue();
        sigValueElem.setIdAttributeNode(attr, true);
    } else {
        id = null;
    }
    this.sigValueElem = sigValueElem;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DOMXMLSignature.java

示例3: SignatureAlgorithm

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Constructor SignatureAlgorithm
 *
 * @param element
 * @param baseURI
 * @param secureValidation
 * @throws XMLSecurityException
 */
public SignatureAlgorithm(
    Element element, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    super(element, baseURI);
    algorithmURI = this.getURI();

    Attr attr = element.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        element.setIdAttributeNode(attr, true);
    }

    if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI)
        || XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) {
        Object exArgs[] = { algorithmURI };

        throw new XMLSecurityException("signature.signatureAlgorithm", exArgs);
    }

    signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
    signatureAlgorithm.engineGetContextFromElement(this.constructionElement);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:SignatureAlgorithm.java

示例4: marshallAttribute

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Marshall an attribute name and value to a DOM Element. This is particularly useful for attributes whose names
 * appear in namespace-qualified form.
 * 
 * @param attributeName the attribute name in QName form
 * @param attributeValue the attribute value
 * @param domElement the target element to which to marshall
 * @param isIDAttribute flag indicating whether the attribute being marshalled should be handled as an ID-typed
 *            attribute
 */
public static void marshallAttribute(QName attributeName, String attributeValue, Element domElement,
        boolean isIDAttribute) {
    Document document = domElement.getOwnerDocument();
    Attr attribute = XMLHelper.constructAttribute(document, attributeName);
    attribute.setValue(attributeValue);
    domElement.setAttributeNodeNS(attribute);
    if (isIDAttribute) {
        domElement.setIdAttributeNode(attribute, true);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:XMLHelper.java

示例5: marshallAttributeMap

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Marshall the attributes represented by the indicated AttributeMap into the indicated DOM Element.
 * 
 * @param attributeMap the AttributeMap
 * @param domElement the target Element
 */
public static void marshallAttributeMap(AttributeMap attributeMap, Element domElement) {
    Document document = domElement.getOwnerDocument();
    Attr attribute = null;
    for (Entry<QName, String> entry : attributeMap.entrySet()) {
        attribute = XMLHelper.constructAttribute(document, entry.getKey());
        attribute.setValue(entry.getValue());
        domElement.setAttributeNodeNS(attribute);
        if (Configuration.isIDAttribute(entry.getKey()) || attributeMap.isIDAttribute(entry.getKey())) {
            domElement.setIdAttributeNode(attribute, true);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:XMLHelper.java

示例6: DOMSignatureProperty

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates a <code>DOMSignatureProperty</code> from an element.
 *
 * @param propElem a SignatureProperty element
 */
public DOMSignatureProperty(Element propElem, XMLCryptoContext context)
    throws MarshalException
{
    // unmarshal attributes
    target = DOMUtils.getAttributeValue(propElem, "Target");
    if (target == null) {
        throw new MarshalException("target cannot be null");
    }
    Attr attr = propElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        id = attr.getValue();
        propElem.setIdAttributeNode(attr, true);
    } else {
        id = null;
    }

    NodeList nodes = propElem.getChildNodes();
    int length = nodes.getLength();
    List<XMLStructure> content = new ArrayList<XMLStructure>(length);
    for (int i = 0; i < length; i++) {
        content.add(new javax.xml.crypto.dom.DOMStructure(nodes.item(i)));
    }
    if (content.isEmpty()) {
        throw new MarshalException("content cannot be empty");
    } else {
        this.content = Collections.unmodifiableList(content);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:DOMSignatureProperty.java

示例7: DOMManifest

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates a <code>DOMManifest</code> from an element.
 *
 * @param manElem a Manifest element
 */
public DOMManifest(Element manElem, XMLCryptoContext context,
                   Provider provider)
    throws MarshalException
{
    Attr attr = manElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        this.id = attr.getValue();
        manElem.setIdAttributeNode(attr, true);
    } else {
        this.id = null;
    }

    boolean secVal = Utils.secureValidation(context);

    Element refElem = DOMUtils.getFirstChildElement(manElem, "Reference");
    List<Reference> refs = new ArrayList<Reference>();
    refs.add(new DOMReference(refElem, context, provider));

    refElem = DOMUtils.getNextSiblingElement(refElem);
    while (refElem != null) {
        String localName = refElem.getLocalName();
        if (!localName.equals("Reference")) {
            throw new MarshalException("Invalid element name: " +
                                       localName + ", expected Reference");
        }
        refs.add(new DOMReference(refElem, context, provider));
        if (secVal && (refs.size() > DOMSignedInfo.MAXIMUM_REFERENCE_COUNT)) {
            String error = "A maxiumum of " + DOMSignedInfo.MAXIMUM_REFERENCE_COUNT + " "
                + "references per Manifest are allowed with secure validation";
            throw new MarshalException(error);
        }
        refElem = DOMUtils.getNextSiblingElement(refElem);
    }
    this.references = Collections.unmodifiableList(refs);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:DOMManifest.java

示例8: DOMManifest

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates a <code>DOMManifest</code> from an element.
 *
 * @param manElem a Manifest element
 */
public DOMManifest(Element manElem, XMLCryptoContext context,
                   Provider provider)
    throws MarshalException
{
    Attr attr = manElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        this.id = attr.getValue();
        manElem.setIdAttributeNode(attr, true);
    } else {
        this.id = null;
    }

    boolean secVal = Utils.secureValidation(context);

    Element refElem = DOMUtils.getFirstChildElement(manElem, "Reference");
    List<Reference> refs = new ArrayList<Reference>();
    refs.add(new DOMReference(refElem, context, provider));

    refElem = DOMUtils.getNextSiblingElement(refElem);
    while (refElem != null) {
        String localName = refElem.getLocalName();
        if (!localName.equals("Reference")) {
            throw new MarshalException("Invalid element name: " +
                                       localName + ", expected Reference");
        }
        refs.add(new DOMReference(refElem, context, provider));
        if (secVal && Policy.restrictNumReferences(refs.size())) {
            String error = "A maximum of " + Policy.maxReferences()
                + " references per Manifest are allowed when"
                + " secure validation is enabled";
            throw new MarshalException(error);
        }
        refElem = DOMUtils.getNextSiblingElement(refElem);
    }
    this.references = Collections.unmodifiableList(refs);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:DOMManifest.java

示例9: DOMSignatureProperties

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates a <code>DOMSignatureProperties</code> from an element.
 *
 * @param propsElem a SignatureProperties element
 * @throws MarshalException if a marshalling error occurs
 */
public DOMSignatureProperties(Element propsElem, XMLCryptoContext context)
    throws MarshalException
{
    // unmarshal attributes
    Attr attr = propsElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        id = attr.getValue();
        propsElem.setIdAttributeNode(attr, true);
    } else {
        id = null;
    }

    NodeList nodes = propsElem.getChildNodes();
    int length = nodes.getLength();
    List<SignatureProperty> properties =
        new ArrayList<SignatureProperty>(length);
    for (int i = 0; i < length; i++) {
        Node child = nodes.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String name = child.getLocalName();
            if (!name.equals("SignatureProperty")) {
                throw new MarshalException("Invalid element name: " + name +
                                           ", expected SignatureProperty");
            }
            properties.add(new DOMSignatureProperty((Element)child,
                                                    context));
        }
    }
    if (properties.isEmpty()) {
        throw new MarshalException("properties cannot be empty");
    } else {
        this.properties = Collections.unmodifiableList(properties);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:DOMSignatureProperties.java

示例10: DOMXMLObject

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates an <code>XMLObject</code> from an element.
 *
 * @param objElem an Object element
 * @throws MarshalException if there is an error when unmarshalling
 */
public DOMXMLObject(Element objElem, XMLCryptoContext context,
                    Provider provider)
throws MarshalException
{
    // unmarshal attributes
    this.encoding = DOMUtils.getAttributeValue(objElem, "Encoding");

    Attr attr = objElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        this.id = attr.getValue();
        objElem.setIdAttributeNode(attr, true);
    } else {
        this.id = null;
    }
    this.mimeType = DOMUtils.getAttributeValue(objElem, "MimeType");

    NodeList nodes = objElem.getChildNodes();
    int length = nodes.getLength();
    List<XMLStructure> content = new ArrayList<XMLStructure>(length);
    for (int i = 0; i < length; i++) {
        Node child = nodes.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            Element childElem = (Element)child;
            String tag = childElem.getLocalName();
            if (tag.equals("Manifest")) {
                content.add(new DOMManifest(childElem, context, provider));
                continue;
            } else if (tag.equals("SignatureProperties")) {
                content.add(new DOMSignatureProperties(childElem, context));
                continue;
            } else if (tag.equals("X509Data")) {
                content.add(new DOMX509Data(childElem));
                continue;
            }
            //@@@FIXME: check for other dsig structures
        }
        content.add(new javax.xml.crypto.dom.DOMStructure(child));
    }
    if (content.isEmpty()) {
        this.content = Collections.emptyList();
    } else {
        this.content = Collections.unmodifiableList(content);
    }
    this.objectElem = objElem;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:DOMXMLObject.java

示例11: DOMKeyInfo

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates a <code>DOMKeyInfo</code> from XML.
 *
 * @param kiElem KeyInfo element
 */
public DOMKeyInfo(Element kiElem, XMLCryptoContext context,
                  Provider provider)
    throws MarshalException
{
    // get Id attribute, if specified
    Attr attr = kiElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        id = attr.getValue();
        kiElem.setIdAttributeNode(attr, true);
    } else {
        id = null;
    }

    // get all children nodes
    NodeList nl = kiElem.getChildNodes();
    int length = nl.getLength();
    if (length < 1) {
        throw new MarshalException
            ("KeyInfo must contain at least one type");
    }
    List<XMLStructure> content = new ArrayList<XMLStructure>(length);
    for (int i = 0; i < length; i++) {
        Node child = nl.item(i);
        // ignore all non-Element nodes
        if (child.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }
        Element childElem = (Element)child;
        String localName = childElem.getLocalName();
        if (localName.equals("X509Data")) {
            content.add(new DOMX509Data(childElem));
        } else if (localName.equals("KeyName")) {
            content.add(new DOMKeyName(childElem));
        } else if (localName.equals("KeyValue")) {
            content.add(DOMKeyValue.unmarshal(childElem));
        } else if (localName.equals("RetrievalMethod")) {
            content.add(new DOMRetrievalMethod(childElem,
                                               context, provider));
        } else if (localName.equals("PGPData")) {
            content.add(new DOMPGPData(childElem));
        } else { //may be MgmtData, SPKIData or element from other namespace
            content.add(new javax.xml.crypto.dom.DOMStructure((childElem)));
        }
    }
    keyInfoTypes = Collections.unmodifiableList(content);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:DOMKeyInfo.java

示例12: registerElementById

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:IdResolver.java


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