org.w3c.dom.Element.getLocalName()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(445)

本文整理了Java中org.w3c.dom.Element.getLocalName()方法的一些代码示例,展示了Element.getLocalName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getLocalName()方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:getLocalName

Element.getLocalName介绍

暂无

代码示例

代码示例来源:origin: spockframework/spock

  1. @Override
  2. protected void doParse(Element element, BeanDefinitionBuilder builder) {
  3. // configure MockFactory
  4. builder.addConstructorArgValue(element.getAttribute("class"));
  5. builder.addPropertyValue("name", element.getAttribute("id"));
  6. builder.addPropertyValue("mockNature", element.getLocalName());
  7. }

代码示例来源:origin: plutext/docx4j

  1. private QName getQName(Element el) {
  2. QName qname = new QName(el.getNamespaceURI(), el.getLocalName());
  3. System.out.println(qname);
  4. return qname;
  5. }

代码示例来源:origin: plutext/docx4j

  1. /**
  2. * Returns true if the element is in XML Signature namespace and the local
  3. * name equals the supplied one.
  4. *
  5. * @param element
  6. * @param localName
  7. * @return true if the element is in XML Signature namespace and the local name equals
  8. * the supplied one
  9. */
  10. public static boolean elementIsInSignatureSpace(Element element, String localName) {
  11. if (element == null){
  12. return false;
  13. }
  14. return Constants.SignatureSpecNS.equals(element.getNamespaceURI())
  15. && element.getLocalName().equals(localName);
  16. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * <p>
  3. * Returns the first child element with the given name. Returns <code>null</code> if not found.
  4. * </p>
  5. *
  6. * @param parent
  7. * parent element
  8. * @param localName
  9. * name of the child element
  10. * @return child element, null if not found.
  11. */
  12. protected static Element getChildElementByName( Element parent, String localName ) {
  13. NodeList children = parent.getChildNodes();
  14. for ( int i = 0; i < children.getLength(); i++ ) {
  15. Node node = children.item( i );
  16. if ( node.getNodeType() == Node.ELEMENT_NODE ) {
  17. Element element = (Element) node;
  18. if ( element.getLocalName().equals( localName ) ) {
  19. return element;
  20. }
  21. }
  22. }
  23. return null;
  24. }

代码示例来源:origin: apache/geode

  1. final Node root = doc.getDocumentElement();
  2. final int incomingElementOrder =
  3. getElementOrder(elementOrderMap, xmlEntity.getNamespace(), xmlEntity.getType());
  4. final int length = nodes.getLength();
  5. for (int i = 0; i < length; i++) {
  6. final Node node = nodes.item(i);
  7. final String type = childElement.getLocalName();
  8. final String namespace = childElement.getNamespaceURI();

代码示例来源:origin: marytts/marytts

  1. trimEmptyTextNodes(actual);
  2. if (expected.getNodeType() != actual.getNodeType()) {
  3. throw new Exception("Different types of nodes: " + expected + " " + actual);
  4. Document expectedDoc = (Document) expected;
  5. Document actualDoc = (Document) actual;
  6. compareNodes(expectedDoc.getDocumentElement(), actualDoc.getDocumentElement(), false);
  7. } else if (expected instanceof Element) {
  8. Element expectedElement = (Element) expected;
  9. if (!expectedElement.getLocalName().equals(actualElement.getLocalName())) {
  10. throw new Exception("Element names do not match: " + expectedElement.getLocalName() + " "
  11. + actualElement.getLocalName());
  12. String expectedNS = expectedElement.getNamespaceURI();
  13. String actualNS = actualElement.getNamespaceURI();
  14. if ((expectedNS == null && actualNS != null) || (expectedNS != null && !expectedNS.equals(actualNS))) {
  15. throw new Exception("Element namespaces names do not match: " + expectedNS + " " + actualNS);
  16. String elementName = "{" + expectedElement.getNamespaceURI() + "}" + actualElement.getLocalName();
  17. for (int i = 0; i < expectedChildren.getLength(); i++) {
  18. Node expectedChild = expectedChildren.item(i);
  19. Node actualChild = actualChildren.item(i);
  20. compareNodes(expectedChild, actualChild, false);

代码示例来源:origin: ehcache/ehcache3

  1. public ServiceCreationConfiguration<ClusteringService> parseServiceCreationConfiguration(final Element fragment, ClassLoader classLoader) {
  2. if ("cluster".equals(fragment.getLocalName())) {
  3. String clusterTierManager = null;
  4. Duration getTimeout = null, putTimeout = null, connectionTimeout = null;
  5. final NodeList childNodes = fragment.getChildNodes();
  6. for (int i = 0; i < childNodes.getLength(); i++) {
  7. final Node item = childNodes.item(i);
  8. if (Node.ELEMENT_NODE == item.getNodeType()) {
  9. switch (item.getLocalName()) {
  10. case "connection":
  11. clusterTierManager = ((Element)item).getAttribute("cluster-tier-manager");
  12. final NodeList serverNodes = item.getChildNodes();
  13. for (int j = 0; j < serverNodes.getLength(); j++) {
  14. final Node serverNode = serverNodes.item(j);
  15. final String host = ((Element)serverNode).getAttributeNode("host").getValue();
  16. final Attr port = ((Element)serverNode).getAttributeNode("port");

代码示例来源:origin: plutext/docx4j

  1. public static void injectAttrs( Node sourceNode, String classVal, String styleVal ) {
  2. log.debug("node type" + sourceNode.getNodeType());
  3. switch (sourceNode.getNodeType() ) {
  4. for (int i=0; i<nodes.getLength(); i++) {
  5. log.debug("child " + i + "of DOCUMENT_NODE");
  6. injectAttrs((Node)nodes.item(i), classVal, styleVal );
  7. if (el.getLocalName()==null) {}
  8. else if (el.getLocalName().equals("div")
  9. || el.getLocalName().equals("p")
  10. || el.getLocalName().equals("ol")
  11. || el.getLocalName().equals("ul")) {
  12. if (el.getAttribute("class").trim().equals("")
  13. && el.getAttribute("style").trim().equals("") ) {
  14. for (int i=0; i<children.getLength(); i++) {
  15. injectAttrs((Node)children.item(i), classVal, styleVal );

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. String elName = el.getLocalName();
  2. if (el.getNamespaceURI().equals(PackageProperties.NAMESPACE_DCTERMS))
  3. if (!(elName.equals(KEYWORD_CREATED) || elName.equals(KEYWORD_MODIFIED)))
  4. throw new InvalidFormatException(
  5. if (el.getNamespaceURI().equals(PackageProperties.NAMESPACE_DCTERMS)) {
  6. int childElementCount = childElements.getLength();
  7. for (int i = 0; i < childElementCount; i++)
  8. checkElementForOPCCompliance((Element)childElements.item(i));

代码示例来源:origin: plutext/docx4j

  1. /**
  2. * @param signatureElement
  3. * @return the node that is the signature
  4. * @throws TransformationException
  5. */
  6. private static Node searchSignatureElement(Node signatureElement)
  7. throws TransformationException {
  8. boolean found = false;
  9. while (true) {
  10. if (signatureElement == null
  11. || signatureElement.getNodeType() == Node.DOCUMENT_NODE) {
  12. break;
  13. }
  14. Element el = (Element) signatureElement;
  15. if (el.getNamespaceURI().equals(Constants.SignatureSpecNS)
  16. && el.getLocalName().equals(Constants._TAG_SIGNATURE)) {
  17. found = true;
  18. break;
  19. }
  20. signatureElement = signatureElement.getParentNode();
  21. }
  22. if (!found) {
  23. throw new TransformationException(
  24. "transform.envelopedSignatureTransformNotInSignatureElement");
  25. }
  26. return signatureElement;
  27. }

代码示例来源:origin: apache/geode

  1. Map<String, String> attributes = xmlEntity.getAttributes();
  2. Element root = doc.getDocumentElement();
  3. if (root.getLocalName().equals(type)) {

代码示例来源:origin: pentaho/pentaho-kettle

  1. if ( childElement != null ) {
  2. if ( child.hasAttribute( WsdlUtils.ELEMENT_REF_ATTR ) ) {
  3. return wsdlTypes.getTypeQName( child.getAttribute( WsdlUtils.ELEMENT_REF_ATTR ) );
  4. } else if ( child.hasAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) ) {
  5. return wsdlTypes.getTypeQName( child.getAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) );
  6. return new QName( childElement.getNamespaceURI(), childElement.getLocalName() );
  7. return new QName( "http://www.w3.org/2001/XMLSchema", "any" );
  8. return new QName( "http://www.w3.org/2001/XMLSchema", "String" );

代码示例来源:origin: ehcache/ehcache3

  1. public XmlConfigurationWrapper documentToConfig(Document document, ClassLoader classLoader, Map<String, ClassLoader> cacheClassLoaders) throws JAXBException, ClassNotFoundException, InstantiationException, IllegalAccessException {
  2. substituteSystemProperties(document);
  3. Element root = document.getDocumentElement();
  4. QName rootName = new QName(root.getNamespaceURI(), root.getLocalName());
  5. if (!CORE_SCHEMA_ROOT_NAME.equals(rootName)) {
  6. throw new XmlConfigurationException("Expecting " + CORE_SCHEMA_ROOT_NAME + " element; found " + rootName);

代码示例来源:origin: pentaho/pentaho-kettle

  1. setName( e.getAttribute( WsdlUtils.NAME_ATTR ), wsdlTypes );
  2. _xmlType = wsdlTypes.getTypeQName( e.getAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) );
  3. } else if ( e.hasAttribute( WsdlUtils.ELEMENT_REF_ATTR ) ) {
  4. _xmlType = wsdlTypes.getTypeQName( e.getAttribute( WsdlUtils.ELEMENT_REF_ATTR ) );
  5. _name = new QName( "", _xmlType.getLocalPart() );
  6. } else if ( e.hasAttribute( WsdlUtils.NAME_ATTR ) ) {
  7. setName( e.getAttribute( WsdlUtils.NAME_ATTR ), wsdlTypes );
  8. if ( t != null && WsdlUtils.COMPLEX_TYPE_NAME.equals( t.getLocalName() ) ) {
  9. _itemXmlType = getArrayItemType( t, wsdlTypes );
  10. _isArray = _itemXmlType != null;

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

  1. Element el = doc.getDocumentElement();
  2. if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI())
  3. || !"handler-chains".equals(el.getLocalName())) {
  4. "NOT_VALID_ROOT_ELEMENT",
  5. "http://java.sun.com/xml/ns/javaee"
  6. .equals(el.getNamespaceURI()),
  7. "handler-chains".equals(el.getLocalName()),
  8. xml, handlerFileURL));
  9. if (node instanceof Element) {
  10. el = (Element)node;
  11. if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI())
  12. || !"handler-chain".equals(el.getLocalName())) {

代码示例来源:origin: apache/cxf

  1. private Element getWadlElement(Element wadlEl) {
  2. String href = wadlEl.getAttribute("href");
  3. if (href.length() > 0 && href.startsWith("#")) {
  4. return resolveLocalReference(wadlEl.getOwnerDocument().getDocumentElement(),
  5. wadlEl.getLocalName(), href);
  6. }
  7. return wadlEl;
  8. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * <p>
  3. * Returns a list of child elements with the given name. Returns an empty list if there are no such child elements.
  4. * </p>
  5. *
  6. * @param parent
  7. * parent element
  8. * @param localName
  9. * Local name of the child element
  10. * @return child elements
  11. */
  12. protected static List<Element> getChildElementsByName( Element parent, String localName ) {
  13. List<Element> elements = new ArrayList<Element>();
  14. NodeList children = parent.getChildNodes();
  15. for ( int i = 0; i < children.getLength(); i++ ) {
  16. Node node = children.item( i );
  17. if ( node.getNodeType() == Node.ELEMENT_NODE ) {
  18. Element element = (Element) node;
  19. if ( element.getLocalName().equals( localName ) ) {
  20. elements.add( element );
  21. }
  22. }
  23. }
  24. return elements;
  25. }
  26. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. private String determineResourceName(Document theDocument) {
  2. Element root = null;
  3. NodeList list = theDocument.getChildNodes();
  4. for (int i = 0; i < list.getLength(); i++) {
  5. if (list.item(i) instanceof Element) {
  6. root = (Element) list.item(i);
  7. break;
  8. }
  9. }
  10. root = theDocument.getDocumentElement();
  11. return root.getLocalName();
  12. }

代码示例来源:origin: marytts/marytts

  1. trimEmptyTextNodes(actual);
  2. if (expected.getNodeType() != actual.getNodeType()) {
  3. throw new Exception("Different types of nodes: " + expected + " " + actual);
  4. Document expectedDoc = (Document) expected;
  5. Document actualDoc = (Document) actual;
  6. compareNodes(expectedDoc.getDocumentElement(), actualDoc.getDocumentElement(), false);
  7. } else if (expected instanceof Element) {
  8. Element expectedElement = (Element) expected;
  9. if (!expectedElement.getLocalName().equals(actualElement.getLocalName())) {
  10. throw new Exception("Element names do not match: " + expectedElement.getLocalName() + " "
  11. + actualElement.getLocalName());
  12. String expectedNS = expectedElement.getNamespaceURI();
  13. String actualNS = actualElement.getNamespaceURI();
  14. if ((expectedNS == null && actualNS != null) || (expectedNS != null && !expectedNS.equals(actualNS))) {
  15. throw new Exception("Element namespaces names do not match: " + expectedNS + " " + actualNS);
  16. String elementName = "{" + expectedElement.getNamespaceURI() + "}" + actualElement.getLocalName();
  17. for (int i = 0; i < expectedChildren.getLength(); i++) {
  18. Node expectedChild = expectedChildren.item(i);
  19. Node actualChild = actualChildren.item(i);
  20. compareNodes(expectedChild, actualChild, false);

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

  1. public XmlNode updateXML(Object jaxbObject, XmlNode xmlNode) throws JAXBException {
  2. if(jaxbObject==null || xmlNode==null) throw new IllegalArgumentException();
  3. // TODO
  4. // for now just marshal
  5. // TODO: object model independenc
  6. Element e = (Element)xmlNode;
  7. Node ns = e.getNextSibling();
  8. Node p = e.getParentNode();
  9. p.removeChild(e);
  10. // if the type object is passed, the following step is necessary to make
  11. // the marshalling successful.
  12. JaxBeanInfo bi = context.getBeanInfo(jaxbObject, true);
  13. if(!bi.isElement())
  14. jaxbObject = new JAXBElement(new QName(e.getNamespaceURI(),e.getLocalName()),bi.jaxbType,jaxbObject);
  15. getMarshaller().marshal(jaxbObject,p);
  16. Node newNode = p.getLastChild();
  17. p.removeChild(newNode);
  18. p.insertBefore(newNode,ns);
  19. return (XmlNode)newNode;
  20. }

相关文章