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


Java Element.getTagName方法代码示例

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


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

示例1: convertXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected FactDefinition convertXML(Element xmlValue) throws ConverterException {
	Expression facts = null;
	Expression ctor = null;
	List<Pair<Expression,EvaluationType>> args = new ArrayList<Pair<Expression,EvaluationType>>();
	for (Element e : XMLUtils.childrenElements(xmlValue)) {
		String name = e.getTagName();
		switch (name) {
		case "facts":
			facts = convertComponent(Expression.class, e);
			break;
		case "functor":
			ctor = convertComponent(Expression.class, e);
			break;
		case "arg":
			EvaluationType type = getExpressionType(e, XMLUtils.getAttribute(e, "type", "string"));
			Expression expr = convertComponent(Expression.class, e);
			Pair<Expression,EvaluationType> p = new Pair<Expression,EvaluationType>(expr,type);
			args.add(p);
			break;
		default:
			cannotConvertXML(e, "unhandled element: " + name);
		}
	}
	return new FactDefinition(facts, ctor, args, null, null, null);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:27,代码来源:FactDefinitionParamConverter.java

示例2: parse

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
	CompositeComponentDefinition compositeDef =
			new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
	parserContext.pushContainingComponent(compositeDef);

	configureAutoProxyCreator(parserContext, element);

	List<Element> childElts = DomUtils.getChildElements(element);
	for (Element elt: childElts) {
		String localName = parserContext.getDelegate().getLocalName(elt);
		if (POINTCUT.equals(localName)) {
			parsePointcut(elt, parserContext);
		}
		else if (ADVISOR.equals(localName)) {
			parseAdvisor(elt, parserContext);
		}
		else if (ASPECT.equals(localName)) {
			parseAspect(elt, parserContext);
		}
	}

	parserContext.popAndRegisterContainingComponent();
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ConfigBeanDefinitionParser.java

示例3: LoadXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
public InfoTable LoadXML(File f) throws IOException, ParserConfigurationException, SAXException {
    File inputFile = new File("src/infotable.xml");
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(inputFile);
    Element root = doc.getDocumentElement();
    root.normalize();
    NodeList namesList = root.getChildNodes();

    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> infos = new ArrayList<>();
    for (int i = 0; i < namesList.getLength(); i++) {
        Node n = namesList.item(i);
        if (n.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }
        Element tableElement = (Element) n;
        String tagName = tableElement.getTagName();
        MainDataEnum e = MainDataEnum.valueOf(tagName);
        names.add(e.getVal());
        infos.add(tableElement.getTextContent());
    }

    InfoTable it = new InfoTable(names, infos);
    return it;
}
 
开发者ID:froehlichA,项目名称:RA-Reader,代码行数:27,代码来源:ReadFromXML.java

示例4: setAliasParam

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void setAliasParam(Element elt, Sequence<T> sequence) throws PlanException, ParameterException {
	String name = getAttribute(elt, NAME_ATTRIBUTE_NAME);
	Sequence.CompositeParamHandler<T> ph = sequence.createAliasParam(name);
	for (Node child : XMLUtils.childrenNodes(elt)) {
		if (checkEmptyText(child))
			continue;
		if (child instanceof Element) {
			Element childElement = (Element) child;
			String childName = childElement.getTagName();
			if (ALIAS_ELEMENT_NAME.equals(childName)) {
				String modulePath = getAttribute(childElement, MODULE_PATH_ATTRIBUTE_NAME);
				String paramName = getAttribute(childElement, PARAM_ATTRIBUTE_NAME);
				ph.addParamHandler(modulePath, paramName);
				continue;
			}
			throw new PlanException("unexpected element: " + childName);				
		}
		throw new PlanException("unexpected node: " + child);
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:21,代码来源:PlanLoader.java

示例5: init

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected void init(Element element) {
    super.init(element);

    List<Element> children = getChildElements(element);
    if (children.size() != 2) {
        throw new IllegalStateException("Element " + element.getTagName() + " must have 2 children");
    }
    LanguageElement left = model.createLanguageElement(children.get(0));
    if (!(left instanceof Value)) {
        throw new IllegalStateException("Element " + element.getTagName() + "'s first child must be a value or param.  Found: "
                + children.get(0).getTagName());
    }
    LanguageElement right = model.createLanguageElement(children.get(1));
    if (!(right instanceof Pattern)) {
        throw new IllegalStateException("Element " + element.getTagName() + "'s second child must be a pattern.  Found: "
                + children.get(1).getTagName());
    }
    leftSide = (Value) left;
    rightSide = (Pattern) right;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:22,代码来源:MatchesExpression.java

示例6: getChildElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * This method will return the single inner child with the given name of the given father
 * element. If obligatory is true, an Exception is thrown if the element is not present. If it's
 * ambiguous, an execption is thrown in any case.
 */
public static Element getChildElement(Element father, String tagName, boolean mandatory) throws XMLException {
	Collection<Element> children = getChildElements(father, tagName);
	switch (children.size()) {
		case 0:
			if (mandatory) {
				throw new XMLException("Missing child tag <" + tagName + "> inside <" + father.getTagName() + ">.");
			} else {
				return null;
			}
		case 1:
			return children.iterator().next();
		default:
			throw new XMLException("Child tag <" + tagName + "> inside <" + father.getTagName()
					+ "> must be unique, but found " + children.size() + ".");
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:XMLTools.java

示例7: init

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected void init(Element element) {
    List<Element> children = getChildElements(element);
    if (children.size() != 2) {
        throw new IllegalStateException("Element " + element.getTagName() + " must have 2 children");
    }
    LanguageElement left = model.createLanguageElement(children.get(0));
    if (!(left instanceof BooleanExpression)) {
        throw new IllegalStateException("Element " + element.getTagName() + " has a non-boolean expression child: "
                + children.get(0).getTagName());
    }
    LanguageElement right = model.createLanguageElement(children.get(1));
    if (!(right instanceof BooleanExpression)) {
        throw new IllegalStateException("Element " + element.getTagName() + " has a non-boolean expression child: "
                + children.get(1).getTagName());
    }
    leftSide = (BooleanExpression) left;
    rightSide = (BooleanExpression) right;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:20,代码来源:LogicalExpression.java

示例8: init

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected void init(Element element) {
    super.init(element);

    List<Element> children = getChildElements(element);
    if (children.size() > 3) {
        throw new IllegalStateException("Element " + element.getTagName() + " must not have more than 3 children");
    }
    LanguageElement left = model.createLanguageElement(children.get(0));
    if (!(left instanceof Value)) {
        throw new IllegalStateException("Element " + element.getTagName() + "'s first child must be a value or param.  Found: "
                + children.get(0).getTagName());
    }

    leftSide = (Value) left;
    rightSide = NamespacedListHelper.createRightSide(children, model, Model.TAG_IN_IP_RANGE);

}
 
开发者ID:Comcast,项目名称:redirector,代码行数:19,代码来源:InIpRangeExpression.java

示例9: findPath

import org.w3c.dom.Element; //导入方法依赖的package包/类
private Element findPath(Element element, String path) {
    int index = path.indexOf('/');
    String name = path;
    if (index != -1) {
        name = path.substring(0, index);
        path = path.substring(index + 1);
    }
    NodeList nl = element.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        Node child = nl.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            Element childElement = (Element) child;
            if (name.equals(childElement.getAttribute(FILENAME))) {
                if (!childElement.getTagName().equals(FOLDER) && // NOI18N
                        !childElement.getTagName().equals(FILE)) { // NOI18N
                    throw new BuildException("The layer filesystem items should be <folder> or <file> - was " + childElement.getTagName());
                }
                if (childElement.getAttribute(FILENAME).length() == 0) {
                    throw new BuildException("Layer file error? There was no " + FILENAME + " attribute on file " + childElement.getTagName());
                }
                if (index == -1) {
                    return childElement;
                } else {
                    Element result = findPath(childElement, path);
                    if (result != null) {
                        return result;
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:CslJar.java

示例10: getAttributeElements

import org.w3c.dom.Element; //导入方法依赖的package包/类
private List<Element> getAttributeElements(Element parent) {
    List<Element> attributes = new ArrayList<Element>();

    if (parent != null) {
        for (Element f : getElementChildren(parent)) {
            String tag = f.getTagName();
            if (ATTR.equals(tag)) { // NOI18N
                attributes.add(f);
            }
        }
    }

    return attributes;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CslJar.java

示例11: convertXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected AlvisRERelations convertXML(Element xmlValue) throws ConverterException {
	Expression items = null;
	Expression type = null;
	Expression arguments = ExpressionParser.parseUnsafe("nav:arguments");
	Expression role = DefaultExpressions.feature(ArgumentElement.ROLE_FEATURE_KEY);
	Expression label = null;
	for (Element child : XMLUtils.childrenElements(xmlValue)) {
		Expression e = convertComponent(Expression.class, child);
		String tag = child.getTagName();
		switch (tag) {
			case "items": items = e; break;
			case "type": type = e; break;
			case "arguments": arguments = e; break;
			case "role": role = e; break;
			case "label": label = e; break;
			default:
				cannotConvertXML(xmlValue, "unexpected tag " + tag);
		}
	}
	if (items == null) {
		cannotConvertXML(xmlValue, "missing tag items");
	}
	if (type == null) {
		cannotConvertXML(xmlValue, "missing tag type");
	}
	return new AlvisRERelations(items, type, arguments, role, label);
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:29,代码来源:AlvisRERelationsParamConverter.java

示例12: processCharElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void processCharElement(Element charElement, FontInfo info)
		throws ResourceParseException {
	// retrieve required integer attribute
	char ch = (char) getIntAndCheck("code", charElement);
	// retrieve optional float attributes
	float[] metrics = new float[4];
	metrics[DefaultTeXFont.WIDTH] = getOptionalFloat("width", charElement,
			0);
	metrics[DefaultTeXFont.HEIGHT] = getOptionalFloat("height",
			charElement, 0);
	metrics[DefaultTeXFont.DEPTH] = getOptionalFloat("depth", charElement,
			0);
	metrics[DefaultTeXFont.IT] = getOptionalFloat("italic", charElement, 0);
	// set metrics
	info.setMetrics(ch, metrics);

	// process children
	NodeList list = charElement.getChildNodes();
	for (int i = 0; i < list.getLength(); i++) {
		Node node = list.item(i);
		if (node.getNodeType() != Node.TEXT_NODE) {
			Element el = (Element) node;
			Object parser = charChildParsers.get(el.getTagName());
			if (parser == null) // unknown element
				throw new XMLResourceParseException(
						RESOURCE_NAME
								+ ": a <Char>-element has an unknown child element '"
								+ el.getTagName() + "'!");
			else
				// process the child element
				((CharChildParser) parser).parse(el, ch, info);
		}
	}
}
 
开发者ID:daquexian,项目名称:FlexibleRichTextView,代码行数:35,代码来源:DefaultTeXFontParser.java

示例13: validateTestXml

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Validate the test XML and get the root element.
 * 
 * @param configDoc 
 * @return  - the root element of the XML
 * @throws Exception - in case of an invalid tag name; 
 *                     accepted tag names are enumerated in ConfigTags 
 */
private Element validateTestXml(XmlDoc configDoc) throws Exception{
	// validate config.xml - only tags defined in ConfigTags are accepted 
	Element root = configDoc.getRoot();                                   

	// validate root                                                      
	if ( ! root.getTagName().equals(ConfigTags.suite.name()) ){
		throw new Exception("wrong xml root tag name; it should be 'suite' ");
	}                

	// TODO - change this from static
	setSuiteName(root.getAttribute("name"));
	setUser(root.getAttribute("user"));
	setEmail(root.getAttribute("email"));
	setGrid(root.getAttribute("grid"));
	setSuiteResultFileType(root.getAttribute("resultType"));
	
	
	// available testCases packages are set at start; this overwrites previous package settings
	String packages = TestConfig.nullToEmptyString(root.getAttribute("package"));
	if ( ! packages.isEmpty()){
		logger.log("Overwrite default package settings to: " + packages);
		setSuitePackages( packages );
	}
	
	
	List<Element> testsList = XmlDoc.getChildren(root);
	String testName;
	for (Element e : testsList) {
		testName = e.getTagName();
		// validate test tags         
		if ( ! ConfigTags.contains( testName ) ){                                                                            
			throw new Exception("wrong tag: " + e.getTagName());
		}
	}         

	return root;
}
 
开发者ID:danrusu,项目名称:mobileAutomation,代码行数:46,代码来源:XmlTestConfig.java

示例14: init

import org.w3c.dom.Element; //导入方法依赖的package包/类
public void init(AbstractModel model, Element element)
{
	this.model = model;
	name = element.getTagName();
	init(element);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:7,代码来源:LanguageElement.java

示例15: handleAttributesSubtree

import org.w3c.dom.Element; //导入方法依赖的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() && !firstCall) {
        return null;
    }
    // result will contain the attrs which have to be output
    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);
            String NUri = attribute.getNamespaceURI();
            String NName = attribute.getLocalName();
            String NValue = attribute.getValue();

            if (!XMLNS_URI.equals(NUri)) {
                // It's not a namespace attr node. Add to the result and continue.
                result.add(attribute);
            } else if (!(XML.equals(NName) && XML_LANG_URI.equals(NValue))) {
                // The default mapping for xml must not be output.
                Node n = ns.addMappingAndRender(NName, NValue, attribute);

                if (n != null) {
                    // Render the ns definition
                    result.add((Attr)n);
                    if (C14nHelper.namespaceIsRelative(attribute)) {
                        Object exArgs[] = {element.getTagName(), NName, attribute.getNodeValue()};
                        throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs
                        );
                    }
                }
            }
        }
    }

    if (firstCall) {
        // It is the first node of the subtree
        // Obtain all the namespaces defined in the parents, and added to the output.
        ns.getUnrenderedNodes(result);
        // output the attributes in the xml namespace.
        xmlattrStack.getXmlnsAttr(result);
        firstCall = false;
    }

    return result.iterator();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:68,代码来源:Canonicalizer11.java


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