List of usage examples for org.dom4j Attribute getValue
String getValue();
From source file:com.doculibre.constellio.utils.izpack.UsersXmlFileUtils.java
License:Open Source License
@SuppressWarnings("unchecked") private static ConstellioUser toConstellioUser(Element element) { ConstellioUser constellioUser = new ConstellioUser(); constellioUser.setFirstName(element.attributeValue(FIRST_NAME)); constellioUser.setLastName(element.attributeValue(LAST_NAME)); constellioUser.setUsername(element.attributeValue(LOGIN)); constellioUser.setPasswordHash(element.attributeValue(PASSWORD_HASH)); Attribute locale = element.attribute(LOCALE); if (locale != null) { constellioUser.setLocaleCode(locale.getValue()); } else {/* ww w . j av a 2s . c o m*/ constellioUser.setLocale(ConstellioSpringUtils.getDefaultLocale()); } Iterator<Element> rolesIt = element.elementIterator(ROLES); if (rolesIt != null) { Element roles = rolesIt.next(); for (Iterator<Element> it = roles.elementIterator(ROLE); it.hasNext();) { Element currentRole = it.next(); constellioUser.addRole(currentRole.attributeValue(VALUE)); } } return constellioUser; }
From source file:com.doculibre.constellio.utils.xml.SolrShemaXmlReader.java
License:Open Source License
private static Map<String, Map<String, String>> readFields(Document schemaDocument, Boolean readDynamicFields, Boolean checkTypes) {//from ww w.j av a2 s . co m Map<String, Map<String, String>> returnList = new HashMap<String, Map<String, String>>(); //AnalyzerClassServices analyzerClassServices = ConstellioSpringUtils.getAnalyzerClassServices(); FieldTypeServices fieldTypeServices = ConstellioSpringUtils.getFieldTypeServices(); if (schemaDocument != null) { Element fieldsElement = schemaDocument.getRootElement().element("fields"); List<Element> fieldElements; if (readDynamicFields) { fieldElements = fieldsElement.elements("dynamicField"); } else { fieldElements = fieldsElement.elements("field"); } for (Iterator<Element> it = fieldElements.iterator(); it.hasNext();) { Element fieldElement = it.next(); if (checkTypes) { /*String analyzerClassName = fieldElement.attributeValue("analyzer"); if (analyzerClassName != null) { AnalyzerClass analyzerClass = analyzerClassServices.get(analyzerClassName); if (analyzerClass == null) { throw new RuntimeException("New Analyzers must be defined throught Constellio Interface"); } }*/ String typeName = fieldElement.attributeValue("type"); if (typeName == null) { throw new RuntimeException("A Field must have a type"); } FieldType fieldType = fieldTypeServices.get(typeName); if (fieldType == null) { throw new RuntimeException( "New Field type " + typeName + " must be defined throught Constellio Interface"); } } String fieldName = fieldElement.attributeValue("name"); if (fieldName == null) { throw new RuntimeException("A Field must have a name"); } List<Attribute> attributes = fieldElement.attributes(); Map<String, String> attributesToMap = new HashMap<String, String>(); for (Attribute att : attributes) { if (!att.getQualifiedName().equals("name")) { attributesToMap.put(att.getQualifiedName(), att.getValue()); } } returnList.put(fieldName, attributesToMap); } } return returnList; }
From source file:com.dotmarketing.viewtools.XmlTool.java
License:Apache License
/** * Returns a {@link Map} of all attributes for the first/sole {@link Node} held internally by this instance. If that * Node is not an {@link Element}, this will return null. *///w w w.j a va 2 s .co m public Map<String, String> attributes() { Node node = node(); if (node instanceof Element) { Map<String, String> attrs = new HashMap<String, String>(); for (Iterator i = ((Element) node).attributeIterator(); i.hasNext();) { Attribute a = (Attribute) i.next(); attrs.put(a.getName(), a.getValue()); } return attrs; } return null; }
From source file:com.example.sample.pMainActivity.java
License:Apache License
public void listNodes(Element node) { System.out.println("" + node.getName()); List<Attribute> list = node.attributes(); for (Attribute attr : list) { Log.d(TAG, "listNodes: " + attr.getText() + "-----" + attr.getName() + "---" + attr.getValue()); }//from w ww .j a va2 s .c om if (!(node.getTextTrim().equals(""))) { Log.d(TAG, "getText: " + node.getText()); node.setText("getText: "); saveDocument(document); Log.d(TAG, "saveDocument: " + node.getText()); } Iterator<Element> it = node.elementIterator(); while (it.hasNext()) { Element e = it.next(); listNodes(e); } }
From source file:com.flaptor.hounder.util.HtmlParser.java
License:Apache License
@SuppressWarnings("unchecked") private void extractLinks(Document htmlDoc, Output out) { List links = htmlDoc.selectNodes("//A"); for (Iterator iter = links.iterator(); iter.hasNext();) { Element link = (Element) iter.next(); Attribute href = link.attribute("href"); if (null != href) { try { out.addLink(href.getValue(), link.getText()); } catch (Exception e) { logger.warn("Exception occurred, ignoring link " + link.getText() + " at " + href.getValue(), e);// w w w . j av a 2 s . c o m } } } }
From source file:com.flaptor.util.parser.HtmlParser.java
License:Apache License
@SuppressWarnings("unchecked") private void extractLinks(Document htmlDoc, ParseOutput out) { try {/*w w w .j ava 2 s . c om*/ Node baseNode = htmlDoc.selectSingleNode("//BASE|//Base|//base"); if (null != baseNode) { Attribute href = ((Element) baseNode).attribute("href"); if (null == href) { href = ((Element) baseNode).attribute("HREF"); if (null == href) { href = ((Element) baseNode).attribute("Href"); } } if (null != href) { String base = href.getValue(); if (null != base) { out.setBaseUrl(base); } } } List links = htmlDoc.selectNodes("//A|//a"); for (Iterator iter = links.iterator(); iter.hasNext();) { Element link = (Element) iter.next(); Attribute href = link.attribute("href"); if (null != href) { try { out.addLink(href.getValue(), link.getText()); } catch (URISyntaxException e) { logger.debug( "Exception occurred, ignoring link " + link.getText() + " at " + href.getValue(), e); } } } } catch (URISyntaxException e) { logger.debug("Exception occurred, ignoring links in " + out.getUrl(), e); } }
From source file:com.founder.fix.fixflow.core.impl.util.XmlUtil.java
License:Apache License
public static String getAttributeValue(Attribute attribute) { String result = null;/* w w w . ja va 2s . c o m*/ if (attribute != null) result = attribute.getValue(); return result; }
From source file:com.github.autoprimer3.AutoPrimer3Config.java
License:Open Source License
public LinkedHashSet<String> readTableFile(Document dasXml) throws DocumentException { LinkedHashSet<String> tables = new LinkedHashSet<>(); Element root = dasXml.getRootElement(); Element gff = root.element("GFF"); Element segment = gff.element("SEGMENT"); for (Iterator i = segment.elementIterator("TYPE"); i.hasNext();) { Element type = (Element) i.next(); Attribute id = type.attribute("id"); tables.add(id.getValue()); }//from ww w .ja v a2 s.c o m return tables; }
From source file:com.github.autoprimer3.AutoPrimer3Config.java
License:Open Source License
public LinkedHashSet<String> readTableFile(Document dasXml, String category) throws DocumentException { LinkedHashSet<String> tables = new LinkedHashSet<>(); Element root = dasXml.getRootElement(); Element gff = root.element("GFF"); Element segment = gff.element("SEGMENT"); for (Iterator i = segment.elementIterator("TYPE"); i.hasNext();) { Element type = (Element) i.next(); Attribute id = type.attribute("id"); Attribute cat = type.attribute("category"); if (cat.getValue().equals(category)) { tables.add(id.getValue());/*ww w .ja v a 2s. com*/ } } return tables; }
From source file:com.github.autoprimer3.GetUcscBuildsAndTables.java
License:Open Source License
public void readDasGenomeXmlDocument() { if (dasGenomeXml == null) { return;/* ww w . j a v a 2 s .c o m*/ } Element root = dasGenomeXml.getRootElement(); for (Iterator i = root.elementIterator("DSN"); i.hasNext();) { Element dsn = (Element) i.next(); Element source = dsn.element("SOURCE"); Attribute build = source.attribute("id"); Element mapmaster = dsn.element("MAPMASTER"); Element desc = dsn.element("DESCRIPTION"); buildToMapMaster.put(build.getValue(), mapmaster.getText()); buildToDescription.put(build.getValue(), desc.getText()); } }