本文整理汇总了Java中org.w3c.dom.Element.hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.hasAttribute方法的具体用法?Java Element.hasAttribute怎么用?Java Element.hasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Element
的用法示例。
在下文中一共展示了Element.hasAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doParse
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
// first check the attributes
if (element.hasAttribute(AUTOEXPORT) && !DISABLED.equals(element.getAttribute(AUTOEXPORT).trim())) {
if (element.hasAttribute(INTERFACE)) {
parserContext.getReaderContext().error(
"either 'auto-export' or 'interface' attribute has be specified but not both", element);
}
if (DomUtils.getChildElementByTagName(element, INTERFACES) != null) {
parserContext.getReaderContext().error(
"either 'auto-export' attribute or <intefaces> sub-element has be specified but not both",
element);
}
}
builder.addPropertyValue(CACHE_TARGET, true);
super.doParse(element, parserContext, builder);
}
示例2: parseEntityElement
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* 解析 entity 节点信息
*
* @param entityElement entity 节点
* @param mappingInfo 本 entity 节点包含的映射信息
*/
private void parseEntityElement(Element entityElement, MappingInfo mappingInfo) {
// 解析 entity 的 class 属性
String className = entityElement.getAttribute(CLASS_ATTRIBUTE);
mappingInfo.setClassName(className);
// 解析 entity 的 sheetName 属性
if (entityElement.hasAttribute(SHEET_NAME_ATTRIBUTE))
mappingInfo.setSheetName(entityElement.getAttribute(SHEET_NAME_ATTRIBUTE));
// 解析 entity 的 boldHeading 属性
if (entityElement.hasAttribute(BOLD_HEADING_ATTRIBUTE)) {
String isBoldHeading = entityElement.getAttribute(BOLD_HEADING_ATTRIBUTE);
mappingInfo.setBoldHeading(isBoldHeading.equals("true"));
}
// 读取并解析 property 节点
NodeList properties = entityElement.getElementsByTagName(PROPERTY_ELEMENT);
for (int index = 0; index < properties.getLength(); index++) {
Node propertyNode = properties.item(index);
if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
Element propertyElement = (Element) propertyNode;
parsePropertyElement(propertyElement, mappingInfo);
}
}
}
示例3: parseActionProvider
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Metadata parseActionProvider(final Element element, final ParserContext context) {
registerRpcProviderServiceRefBean(context);
registerRpcRegistryServiceRefBean(context);
registerSchemaServiceRefBean(context);
MutableBeanMetadata metadata = createBeanMetadata(context, context.generateId(), ActionProviderBean.class,
true, true);
addBlueprintBundleRefProperty(context, metadata);
metadata.addProperty("rpcProviderService", createRef(context, RPC_PROVIDER_SERVICE_NAME));
metadata.addProperty("rpcRegistry", createRef(context, RPC_REGISTRY_NAME));
metadata.addProperty("schemaService", createRef(context, SCHEMA_SERVICE_NAME));
metadata.addProperty("interfaceName", createValue(context, element.getAttribute(INTERFACE)));
if (element.hasAttribute(REF_ATTR)) {
metadata.addProperty("implementation", createRef(context, element.getAttribute(REF_ATTR)));
}
LOG.debug("parseActionProvider returning {}", metadata);
return metadata;
}
示例4: SetLabelTags
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void SetLabelTags(Element eOutput)
{
NodeList lst = eOutput.getElementsByTagName("label") ;
int nb = lst.getLength() ;
for (int i=0; i<nb; i++)
{
Element e = (Element)lst.item(i) ;
if (e.hasAttribute("type"))
{
if (e.getAttribute("type").equals("activeChoice"))
{
String target = e.getAttribute("activeChoiceTarget") ;
Element eTarget = m_tab.get(target);
if (eTarget==null || eTarget.getAttribute("protection").equals("autoskip"))
{
e.setAttribute("type", "") ;
}
}
}
}
}
示例5: convertAttributeDefinition
import org.w3c.dom.Element; //导入方法依赖的package包/类
private AttributeDefinition convertAttributeDefinition(Element elt) throws ConverterException {
if (!elt.hasAttribute("name"))
cannotConvertXML(elt, "missing @name");
String name = elt.getAttribute("name");
Expression value = convertExpression(XMLUtils.attributeOrValue(elt, "value"));
boolean classAttribute = elt.hasAttribute("class") ? Strings.getBoolean(elt.getAttribute("class")) : false;
String type = elt.hasAttribute("type") ? elt.getAttribute("type") : "boolean";
if (type.startsWith("bool"))
return new BooleanExpressionAttributeDefinition(classAttribute, name, value, null);
if (type.startsWith("int"))
return new IntExpressionAttributeDefinition(classAttribute, name, value, null);
if ("nominal".equals(type) || type.startsWith("str")) {
Collection<String> values = new ArrayList<String>();
try {
for (Element v : XMLUtils.childrenElements(elt))
values.add(XMLUtils.evaluateString(XMLUtils.CONTENTS, v));
}
catch (XPathExpressionException xpee) {
cannotConvertXML(elt, xpee.getMessage());
}
return new NominalExpressionAttributeDefinition(classAttribute, name, values, value, null);
}
cannotConvertXML(elt, "unsupported attribute type " + type);
return null;
}
示例6: doMerging
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* @param xmlStruct
* @param xmlData
* @return
*/
public Document doMerging(Document xmlStruct, Document xmlData)
{
if (xmlData == null)
{
return xmlStruct ;
}
//XMLUtil.ExportXML(xmlData, ResourceManager.getLogDir()+"xmlData.xml");
//XMLUtil.ExportXML(xmlStruct, ResourceManager.getLogDir()+"xmlStruct.xml");
Document xmlOutput = XMLUtil.CreateDocument() ;
Element eOutput = (Element)xmlOutput.importNode(xmlStruct.getDocumentElement(), true) ;
xmlOutput.appendChild(eOutput) ;
Element eData = xmlData.getDocumentElement() ;
if (eData.hasAttribute("cursorPosition"))
{
int cursorPosition = NumberParser.getAsInt(eData.getAttribute("cursorPosition"));
SetCursorPosition(eOutput, cursorPosition);
}
SetEditTags(eOutput, eData) ;
SetFormProperties(eOutput, eData) ;
SetPFKeys(eOutput, eData) ;
//XMLUtil.ExportXML(xmlOutput, ResourceManager.getLogDir()+"xmlOutput.xml");
return xmlOutput ;
}
示例7: processChildTables
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void processChildTables(Map<String, TableConfig> tables,
TableConfig parentTable, String strDatoNodes, Element tableNode, boolean isLowerCaseNames) {
// parse child tables
NodeList childNodeList = tableNode.getChildNodes();
for (int j = 0; j < childNodeList.getLength(); j++) {
Node theNode = childNodeList.item(j);
if (!theNode.getNodeName().equals("childTable")) {
continue;
}
Element childTbElement = (Element) theNode;
String cdTbName = childTbElement.getAttribute("name");
if (isLowerCaseNames) {
cdTbName = cdTbName.toLowerCase();
}
String primaryKey = childTbElement.hasAttribute("primaryKey") ? childTbElement.getAttribute("primaryKey").toUpperCase() : null;
boolean autoIncrement = false;
if (childTbElement.hasAttribute("autoIncrement")) {
autoIncrement = Boolean.parseBoolean(childTbElement.getAttribute("autoIncrement"));
}
boolean needAddLimit = true;
if (childTbElement.hasAttribute("needAddLimit")) {
needAddLimit = Boolean.parseBoolean(childTbElement.getAttribute("needAddLimit"));
}
//join key ,the parent's column
String joinKey = childTbElement.getAttribute("joinKey").toUpperCase();
String parentKey = childTbElement.getAttribute("parentKey").toUpperCase();
TableConfig table = new TableConfig(cdTbName, primaryKey, autoIncrement, needAddLimit,
TableTypeEnum.TYPE_SHARDING_TABLE, strDatoNodes, null, false, parentTable, joinKey, parentKey);
if (tables.containsKey(table.getName())) {
throw new ConfigException("table " + table.getName() + " duplicated!");
}
tables.put(table.getName(), table);
//child table may also have children
processChildTables(tables, table, strDatoNodes, childTbElement, isLowerCaseNames);
}
}
示例8: map
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public Pair<String,ModifierPosition> map(Element x) {
String modId = x.getTextContent().trim();
ModifierPosition modPos = null;
if (x.hasAttribute("@POSITION")) {
modPos = ModifierPosition.valueOf(x.getAttribute("@POSITION"));
}
return new Pair<String,ModifierPosition>(modId, modPos);
}
示例9: parseVersion
import org.w3c.dom.Element; //导入方法依赖的package包/类
private VersionNumber parseVersion(Element element) {
if (element.hasAttribute("version")) {
try {
VersionNumber version = new VersionNumber(element.getAttribute("version"));
return version;
} catch (NumberFormatException e) {
addMessage("<em class=\"error\">The version " + element.getAttribute("version")
+ " is not a legal RapidMiner version, assuming 4.0.</em>");
return new VersionNumber(4, 0);
}
}
addMessage("<em class=\"error\">Found no version information, assuming 4.0.</em>");
return new VersionNumber(4, 0);
}
示例10: attributeOrValue
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Returns the value of one of the attributes, if none is present the text contents of the specified node.
* @param element
* @param alternateAttributes
*/
public static final String attributeOrValue(Element element, String mainAttribute, String... alternateAttributes) {
if (element.hasAttribute(mainAttribute))
return element.getAttribute(mainAttribute);
if (alternateAttributes != null) {
for (String a : alternateAttributes)
if (element.hasAttribute(a))
return element.getAttribute(a);
}
return element.getTextContent();
}
示例11: parseBeanReference
import org.w3c.dom.Element; //导入方法依赖的package包/类
private Object parseBeanReference(Element parent, Element element, ParserContext parserContext,
BeanDefinitionBuilder builder) {
// check shortcut on the parent
if (parent.hasAttribute(REF))
parserContext.getReaderContext().error(
"nested bean definition/reference cannot be used when attribute 'ref' is specified", parent);
return parsePropertySubElement(parserContext, element, builder.getBeanDefinition());
}
示例12: configureAutoProxyCreator
import org.w3c.dom.Element; //导入方法依赖的package包/类
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
String txAdvisorBeanName = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
Object eleSource = parserContext.extractSource(element);
// Create the TransactionAttributeSource definition.
RootBeanDefinition sourceDef = new RootBeanDefinition(
"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource");
sourceDef.setSource(eleSource);
sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);
// Create the TransactionInterceptor definition.
RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
interceptorDef.setSource(eleSource);
interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
registerTransactionManager(element, interceptorDef);
interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);
// Create the TransactionAttributeSourceAdvisor definition.
RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
advisorDef.setSource(eleSource);
advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
if (element.hasAttribute("order")) {
advisorDef.getPropertyValues().add("order", element.getAttribute("order"));
}
parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
parserContext.registerComponent(compositeDef);
}
}
示例13: getAttributeOrNull
import org.w3c.dom.Element; //导入方法依赖的package包/类
private String getAttributeOrNull(Element item, String name)
{
if(item.hasAttribute(name))
return item.getAttribute(name);
return null;
}
示例14: load
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Imports realms.
*
* @param metadataElement the metadata element we are processing within a source.
* @param source the name of the source file.
* @throws JaffaRulesFrameworkException if any internal error occurs.
*/
public void load(Element metadataElement, String source) throws JaffaRulesFrameworkException {
if (log.isDebugEnabled())
log.debug("Loading realms from " + source);
Element[] realmElements = getChildren(metadataElement);
for (Element realmElement : realmElements) {
if (ELEMENT_REALM.equals(realmElement.getNodeName())) {
// create a Realm
Realm realm = new Realm();
realm.setName(realmElement.hasAttribute(ATTR_NAME) ? realmElement.getAttribute(ATTR_NAME) : null);
realm.setSource(source);
realm.setLine(getLine(realmElement));
// Add classRegexes and inheritanceRuleFilter to the realm
Element[] realmChildren = getChildren(realmElement);
for (Element realmChild : realmChildren) {
if (ELEMENT_CLASS.equals(realmChild.getNodeName()))
realm.addClassRegex(realmChild.hasAttribute(ATTR_REGEX) ? realmChild.getAttribute(ATTR_REGEX) : null);
else if (ELEMENT_INHERITANCE_RULE_FILTER.equals(realmChild.getNodeName())) {
if (realmChild.hasAttribute(ATTR_INCLUDES))
realm.addInheritanceRulesToInclude(Arrays.asList(realmChild.getAttribute(ATTR_INCLUDES).split(",")));
if (realmChild.hasAttribute(ATTR_EXCLUDES))
realm.addInheritanceRulesToExclude(Arrays.asList(realmChild.getAttribute(ATTR_EXCLUDES).split(",")));
} else {
// unknown element
log.warn("Unknown element found while importing class regex inside a realm element: " + realmChild.getNodeName());
}
}
if (log.isDebugEnabled())
log.debug("Loaded realm: " + realm);
addRealm(realm);
} else {
// unknown element
log.warn("Unknown element found while importing Realm: " + realmElement.getNodeName());
}
}
}
示例15: buildDefaultParamValues
import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Map<String,List<Element>> buildDefaultParamValues(Document defaultParamValuesDoc) throws PlanException {
Map<String,List<Element>> result = new LinkedHashMap<String,List<Element>>();
if (defaultParamValuesDoc == null) {
return result;
}
Element root = defaultParamValuesDoc.getDocumentElement();
for (Element elt : XMLUtils.childrenElements(root)) {
String tag = elt.getTagName();
switch (tag) {
case MODULE_ELEMENT_NAME: {
if (!elt.hasAttribute(CLASS_ATTRIBUTE_NAME)) {
throw new PlanException("missing " + CLASS_ATTRIBUTE_NAME + " attribute in module defaults");
}
String moduleClass = elt.getAttribute(CLASS_ATTRIBUTE_NAME);
if (result.containsKey(moduleClass)) {
throw new PlanException("duplicate default values for module " + moduleClass);
}
List<Element> defaultValues = XMLUtils.childrenElements(elt);
result.put(moduleClass, defaultValues);
break;
}
default: {
throw new PlanException("unexpected tag " + tag + " in module defaults");
}
}
}
return result;
}