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


Java Attr类代码示例

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


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

示例1: makeIdMap

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * Method removed when ref removed from configuration, only used for menu... separator, languages
 */
@Deprecated
public static void makeIdMap(Node pElement, Map<String, CwfDataIf> pIdMap) {
    if (pElement.getNodeType() == Node.ELEMENT_NODE) {
        String tTagName = ((Element) pElement).getTagName();
        String tId = ((Element) pElement).getAttribute("id");
        if (!tId.isEmpty() && tTagName.equals(TAG_MENUITEM)) {
            CwfDataIf tData = CwfDataFactory.create();
            tData.setProperty(ATTR_TAG_NAME, TAG_MENUITEM);
            for (int i = 0; i < pElement.getAttributes().getLength(); i++) {
                Attr tAttr = (Attr) pElement.getAttributes().item(i);
                tData.setProperty(tAttr.getName(), tAttr.getValue());
            }
            pIdMap.put(tId, tData);

        }
        NodeList tNodes = pElement.getChildNodes();
        for (int i = 0; i < tNodes.getLength(); i++) {
            makeIdMap(tNodes.item(i), pIdMap);
        }
    }
}
 
开发者ID:cinnober,项目名称:ciguan,代码行数:25,代码来源:AsUtil.java

示例2: buildDerivationTree

import org.w3c.dom.Attr; //导入依赖的package包/类
public static void buildDerivationTree(Element mother, Node derivation){
	Element t = derivDoc.createElement("tree");
	NamedNodeMap atts = derivation.getAttributes();		
	for (int i = 0 ; i < atts.getLength() ; i++){
		Attr a = (Attr) atts.item(i);
		String name = a.getNodeName();
		String val  = a.getNodeValue();
		if (name.equals("id")) {
			t.setAttribute("id", val);
		} else if (name.equals("op")) {
			t.setAttribute("op", val);
		} else if (name.equals("op-node")) {
			t.setAttribute("node", val);
		} // skip the other attributes
	}
	NodeList childList = derivation.getChildNodes();
       for (int i = 0; i < childList.getLength(); i++)
       {
           Node child = childList.item(i);
           if (child instanceof Element)
           {
               buildDerivationTree(t, child);
           }
       }
       mother.appendChild(t);
}
 
开发者ID:spetitjean,项目名称:TuLiPA-frames,代码行数:27,代码来源:DOMderivationBuilder.java

示例3: getPrefixForAttr

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * If the given attribute is a namespace declaration for the given namespace URI,
 * return its prefix. Otherwise null.
 */
private static String getPrefixForAttr(Attr attr, String nsUri) {
    String attrName = attr.getNodeName();
    if (!attrName.startsWith("xmlns:") && !attrName.equals("xmlns"))
        return null;    // not nsdecl

    if(attr.getValue().equals(nsUri)) {
        if(attrName.equals("xmlns"))
            return "";
        String localName = attr.getLocalName();
        return (localName != null) ? localName :
            QName.valueOf(attrName).getLocalPart();
    }

    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:DOMStreamReader.java

示例4: processAttribute

import org.w3c.dom.Attr; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    EncryptionProperty ep = (EncryptionProperty) xmlObject;

    if (attribute.getLocalName().equals(EncryptionProperty.ID_ATTRIB_NAME)) {
        ep.setID(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else if (attribute.getLocalName().equals(EncryptionProperty.TARGET_ATTRIB_NAME)) {
        ep.setTarget(attribute.getValue());
    } else {
        QName attributeName = XMLHelper.getNodeQName(attribute);
        if (attribute.isId()) {
            ep.getUnknownAttributes().registerID(attributeName);
        }
        ep.getUnknownAttributes().put(attributeName, attribute.getValue());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:EncryptionPropertyUnmarshaller.java

示例5: setNodeName

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * Sets the name of the root element. Warning this can be expensive
 * operation until we use DOM Level 3
 * 
 * @param newname
 * @return
 */
public void setNodeName(final String newname)
{
	ensureRoot();
	checkNotAttribute(newname);

	final NamedNodeMap attributes = m_elRoot.getAttributes();
	final Document doc = m_elRoot.getOwnerDocument();
	final Element newelem = doc.createElement(newname);

	Node child;
	while( (child = m_elRoot.getFirstChild()) != null )
	{
		m_elRoot.removeChild(child);
		newelem.appendChild(child);
	}

	for( int i = 0; i < attributes.getLength(); i++ )
	{
		final Attr attr = (Attr) attributes.item(i);
		newelem.setAttribute(attr.getName(), attr.getValue());
	}

	m_elRoot.getParentNode().replaceChild(newelem, m_elRoot);
	m_elRoot = newelem;
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:PropBagEx.java

示例6: assignAttributeValue

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * Sets the text value of an attribute on a provided element if set in the attributeValueMap table.
 * 
 * @param attName the attribute local name.
 * @param contentElem the element to set the attribute on.
 */
public void assignAttributeValue(String attName,
                                 Element contentElem) {
   if (null != attName && null != contentElem) {
      String attValue = null;
      if (sampleXML) {
         attValue = "?";
      }
      else {
         attValue = getAttributeValue(attName, contentElem);
      }
      if (null != attValue) {
         Attr att = DocumentHelper.createAttribute(generatedDoc, "", attName);
         att.setValue(attValue);
         contentElem.setAttributeNode(att);
      }
   }
}
 
开发者ID:mqsysadmin,项目名称:dpdirect,代码行数:24,代码来源:SchemaLoader.java

示例7: process

import org.w3c.dom.Attr; //导入依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();

	if (BeanDefinitionParserDelegate.ID_ATTRIBUTE.equals(name)) {
		return false;
	}

	if (BeanDefinitionParserDelegate.DEPENDS_ON_ATTRIBUTE.equals(name)) {
		builder.getBeanDefinition().setDependsOn(
			(StringUtils.tokenizeToStringArray(attribute.getValue(),
				BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS)));
		return false;
	}
	if (BeanDefinitionParserDelegate.LAZY_INIT_ATTRIBUTE.equals(name)) {
		builder.setLazyInit(Boolean.valueOf(attribute.getValue()));
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:20,代码来源:StandardAttributeCallback.java

示例8: declareExtensionNamespace

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes
 * attribute of the target document.
 */
private void declareExtensionNamespace( Element target, String nsUri ) {
    // look for the attribute
    Element root = target.getOwnerDocument().getDocumentElement();
    Attr att = root.getAttributeNodeNS(Const.JAXB_NSURI,EXTENSION_PREFIXES);
    if( att==null ) {
        String jaxbPrefix = allocatePrefix(root,Const.JAXB_NSURI);
        // no such attribute. Create one.
        att = target.getOwnerDocument().createAttributeNS(
            Const.JAXB_NSURI,jaxbPrefix+':'+EXTENSION_PREFIXES);
        root.setAttributeNodeNS(att);
    }

    String prefix = allocatePrefix(root,nsUri);
    if( att.getValue().indexOf(prefix)==-1 )
        // avoid redeclaring the same namespace twice.
        att.setValue( att.getValue()+' '+prefix);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Internalizer.java

示例9: handleAttributesSubtree

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * Returns the Attr[]s to be output for the given element.
 * <br>
 * The code of this method is a copy of {@link #handleAttributes(Element,
 * NameSpaceSymbTable)},
 * whereas it takes into account that subtree-c14n is -- well -- subtree-based.
 * So if the element in question isRoot of c14n, it's parent is not in the
 * node set, as well as all other ancestors.
 *
 * @param element
 * @param ns
 * @return the Attr[]s to be output
 * @throws CanonicalizationException
 */
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
    throws CanonicalizationException {
    if (!element.hasAttributes()) {
        return null;
    }

    // result will contain all the attrs declared directly on that element
    final SortedSet<Attr> result = this.result;
    result.clear();

    if (element.hasAttributes()) {
        NamedNodeMap attrs = element.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr attribute = (Attr) attrs.item(i);
            result.add(attribute);
        }
    }

    return result.iterator();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:CanonicalizerPhysical.java

示例10: run

import org.w3c.dom.Attr; //导入依赖的package包/类
public void run() {
    Set<String> declaredPrefixes = new HashSet<String>();
    for( Node n=node; n!=null && n.getNodeType()==Node.ELEMENT_NODE; n=n.getParentNode() ) {
        NamedNodeMap atts = n.getAttributes();
        if(atts==null)      continue; // broken DOM. but be graceful.
        for( int i=0; i<atts.getLength(); i++ ) {
            Attr a = (Attr)atts.item(i);
            String nsUri = a.getNamespaceURI();
            if(nsUri==null || !nsUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI))
                continue;   // not a namespace declaration
            String prefix = a.getLocalName();
            if(prefix==null)
                continue;   // broken DOM. skip to be safe
            if(prefix.equals("xmlns")) {
                prefix = "";
            }
            String value = a.getValue();
            if(value==null)
                continue;   // broken DOM. skip to be safe
            if(declaredPrefixes.add(prefix)) {
                serializer.addInscopeBinding(value,prefix);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:DomPostInitAction.java

示例11: assertNotRelativeNS

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * This method throws an exception if the Attribute value contains
 * a relative URI.
 *
 * @param attr
 * @throws CanonicalizationException
 */
public static void assertNotRelativeNS(Attr attr) throws CanonicalizationException {
    if (attr == null) {
        return;
    }

    String nodeAttrName = attr.getNodeName();
    boolean definesDefaultNS = nodeAttrName.equals("xmlns");
    boolean definesNonDefaultNS = nodeAttrName.startsWith("xmlns:");

    if ((definesDefaultNS || definesNonDefaultNS) && namespaceIsRelative(attr)) {
        String parentName = attr.getOwnerElement().getTagName();
        String attrValue = attr.getValue();
        Object exArgs[] = { parentName, nodeAttrName, attrValue };

        throw new CanonicalizationException(
            "c14n.Canonicalizer.RelativeNamespace", exArgs
        );
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:C14nHelper.java

示例12: evaluate

import org.w3c.dom.Attr; //导入依赖的package包/类
@Override
public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) {
    if (outcome == ComparisonResult.EQUAL) {
        return outcome; // only evaluate differences.
    }

    Node controlNode = comparison.getControlDetails().getTarget();
    Node testNode = comparison.getTestDetails().getTarget();

    if ((controlNode instanceof Attr && testNode instanceof Attr)) {
        if (similarAttributes((Attr) controlNode, (Attr) testNode)) {
            return ComparisonResult.SIMILAR;
        } else {
            return outcome;
        }
    }

    return outcome;
}
 
开发者ID:carlanton,项目名称:mpd-tools,代码行数:20,代码来源:MyDifferenceEvaluator.java

示例13: processAttribute

import org.w3c.dom.Attr; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    StatusResponseType sr = (StatusResponseType) samlObject;

    if (attribute.getLocalName().equals(StatusResponseType.VERSION_ATTRIB_NAME)) {
        sr.setVersion(SAMLVersion.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(StatusResponseType.ID_ATTRIB_NAME)) {
        sr.setID(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else if (attribute.getLocalName().equals(StatusResponseType.IN_RESPONSE_TO_ATTRIB_NAME)) {
        sr.setInResponseTo(attribute.getValue());
    } else if (attribute.getLocalName().equals(StatusResponseType.ISSUE_INSTANT_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        sr.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (attribute.getLocalName().equals(StatusResponseType.DESTINATION_ATTRIB_NAME)) {
        sr.setDestination(attribute.getValue());
    } else if (attribute.getLocalName().equals(StatusResponseType.CONSENT_ATTRIB_NAME)) {
        sr.setConsent(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:StatusResponseTypeUnmarshaller.java

示例14: resolveInput

import org.w3c.dom.Attr; //导入依赖的package包/类
/**
 * Resolves the input from the given retrieval method
 * @return
 * @throws XMLSecurityException
 */
private static XMLSignatureInput resolveInput(
    RetrievalMethod rm, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    Attr uri = rm.getURIAttr();
    // Apply the transforms
    Transforms transforms = rm.getTransforms();
    ResourceResolver resRes = ResourceResolver.getInstance(uri, baseURI, secureValidation);
    XMLSignatureInput resource = resRes.resolve(uri, baseURI, secureValidation);
    if (transforms != null) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "We have Transforms");
        }
        resource = transforms.performTransforms(resource);
    }
    return resource;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:RetrievalMethodResolver.java

示例15: getAllNamespaces

import org.w3c.dom.Attr; //导入依赖的package包/类
private Namespaces getAllNamespaces() {
    Namespaces rv = new Namespaces();

    Node target = this.dom;
    if (target instanceof Attr) {
        target = ((Attr)target).getOwnerElement();
    }
    while(target != null) {
        if (target instanceof Element) {
            addNamespaces(rv, (Element)target);
        }
        target = target.getParentNode();
    }
    //    Fallback in case no namespace was declared
    rv.declare(Namespace.create("", ""));
    return rv;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:18,代码来源:XmlNode.java


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