本文整理了Java中org.jdom.Element.getTextNormalize()
方法的一些代码示例,展示了Element.getTextNormalize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getTextNormalize()
方法的具体详情如下:
包路径:org.jdom.Element
类名称:Element
方法名:getTextNormalize
[英]Returns the textual content of this element with all surrounding whitespace removed and internal whitespace normalized to a single space. If no textual value exists for the element, or if only whitespace exists, the empty string is returned.
[中]返回此元素的文本内容,删除所有周围的空格,并将内部空格规范化为单个空格。如果元素不存在文本值,或者只有空格,则返回空字符串。
代码示例来源:origin: org.codehaus.xfire/xfire-core
public String getTextNormalize()
{
return element.getTextNormalize();
}
代码示例来源:origin: org.jdom/jdom-legacy
/**
* Returns the normalized textual content of the named child element, or
* null if there's no such child.
*
* @param name the name of the child
* @param ns the namespace of the child
* @return normalized text content for the named child,
* or null if no such child
*/
public String getChildTextNormalize(final String name, final Namespace ns) {
final Element child = getChild(name, ns);
if (child == null) {
return null;
}
return child.getTextNormalize();
}
代码示例来源:origin: org.jdom/jdom-legacy
/**
* Returns the normalized textual content of the named child element, or
* null if there's no such child. See <code>{@link
* #getTextNormalize()}</code> for details of text normalizing.
*
* @param name the name of the child
* @return normalized text content for the named child,
* or null if no such child
*/
public String getChildTextNormalize(final String name) {
final Element child = getChild(name);
if (child == null) {
return null;
}
return child.getTextNormalize();
}
代码示例来源:origin: de.smartics.ci/smartics-ci-commons-hudson-config
private String fetchId(final Document document) throws JDOMException
{
final Element projectIdElement =
(Element) XPath.selectSingleNode(document,
"/maven2-moduleset/authToken");
final String projectId = projectIdElement.getTextNormalize();
return projectId;
}
代码示例来源:origin: de.smartics.properties/smartics-properties-core
@SuppressWarnings("unchecked")
private void handleAliases(final Element rootNode, final Builder builder)
{
final Element aliases = rootNode.getChild("aliases", NS);
if (aliases != null)
{
final List<Element> aliasElements = aliases.getChildren("alias", NS);
for (final Element aliasElement : aliasElements)
{
final String alias = aliasElement.getTextNormalize();
final String physical = aliasElement.getAttributeValue("for", NS);
builder.withAlias(alias, physical);
}
}
}
}
代码示例来源:origin: de.smartics.properties/smartics-properties-config
/**
* Parses a set.
*
* @param rootNode the root node that contains the set.
* @param setGi the name of the element that is the set.
* @param elementGi the name of the elements within the set.
* @param defaultSet the set to return if no set is found within the root
* node.
* @return the parsed set.
*/
@SuppressWarnings("unchecked")
protected final Set<String> readSet(final Element rootNode,
final String setGi, final String elementGi, final Set<String> defaultSet)
{
final Element set = rootNode.getChild(setGi, namespace);
if (set != null)
{
final Set<String> collection = new HashSet<String>();
final List<Element> elements = set.getChildren(elementGi, namespace);
for (final Element element : elements)
{
final String text = element.getTextNormalize();
collection.add(text);
}
return collection;
}
return defaultSet;
}
代码示例来源:origin: org.jdom/jdom-contrib
protected void processElement(Element el, DefaultMutableTreeNode dmtn) {
DefaultMutableTreeNode dmtnLocal =
new DefaultMutableTreeNode(el.getName());
String elText = el.getTextNormalize();
if (elText != null && !elText.equals("")) {
dmtnLocal.add(new DefaultMutableTreeNode(elText));
}
processAttributes(el, dmtnLocal);
Iterator iter = el.getChildren().iterator();
while (iter.hasNext()) {
Element nextEl = (Element)iter.next();
processElement(nextEl, dmtnLocal);
}
dmtn.add(dmtnLocal);
}
代码示例来源:origin: stackoverflow.com
Element root = document.getRootElement();
ElementFilter filter = new org.jdom2.filter.ElementFilter("model");
for(Element c : root.getDescendants(filter)) {
System.out.println(c.getTextNormalize());
}
代码示例来源:origin: net.bpelunit/framework
private String extractProcessId(String responseBody) throws IOException {
SAXBuilder builder = new SAXBuilder();
String processId = null;
try {
Document doc = builder.build(new StringReader(responseBody));
Element envelope = doc.getRootElement();
Iterator<Element> it = JDomUtil.getDescendants(envelope,
new ElementFilter("name"));
Element idElement = it.next();
processId = idElement.getTextNormalize();
} catch (JDOMException e) {
throw new IOException(e);
}
return processId;
}
代码示例来源:origin: cn-cerc/summer-mis
@SuppressWarnings("rawtypes")
public static String getChildrenText(List children) {
StringBuffer sb = new StringBuffer();
if (!children.isEmpty()) {
Iterator it = children.iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
String name = e.getName();
String value = e.getTextNormalize();
List list = e.getChildren();
sb.append("<" + name + ">");
if (!list.isEmpty()) {
sb.append(getChildrenText(list));
}
sb.append(value);
sb.append("</" + name + ">");
}
}
return sb.toString();
}
代码示例来源:origin: cn.minsin/mutils-wechat-wechatpay-core
/**
* 获取子结点的xml
*
* @param children
* @return String
*/
public static String getChildrenText(List children) {
StringBuffer sb = new StringBuffer();
if (!children.isEmpty()) {
Iterator it = children.iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
String name = e.getName();
String value = e.getTextNormalize();
List list = e.getChildren();
sb.append("<" + name + ">");
if (!list.isEmpty()) {
sb.append(getChildrenText(list));
}
sb.append(value);
sb.append("</" + name + ">");
}
}
return sb.toString();
}
代码示例来源:origin: cn-cerc/summer-mis
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Map doXMLParse(String strxml) throws Exception {
if (null == strxml || "".equals(strxml)) {
return null;
}
Map m = new HashMap();
InputStream in = String2Inputstream(strxml);
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(in);
Element root = doc.getRootElement();
List list = root.getChildren();
Iterator it = list.iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
String k = e.getName();
String v = "";
List children = e.getChildren();
if (children.isEmpty()) {
v = e.getTextNormalize();
} else {
v = getChildrenText(children);
}
m.put(k, v);
}
// 关闭流
in.close();
return m;
}
代码示例来源:origin: de.julielab/jcore-mallet-0.4
private String getTextWithinElement (Element node)
{
StringBuffer substringBuf = new StringBuffer();
List children = node.getContent();
Iterator iterator = children.iterator();
String intString;
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof Element) {
if (!((Element)o).getChildren().isEmpty())
intString = getTextWithinElement ((Element)o);
else {
intString = ((Element)o).getTextNormalize();
}
substringBuf.append(intString);
}
else if (o instanceof Text) {
substringBuf.append(((Text)o).getText());
}
}
return substringBuf.toString();
}
代码示例来源:origin: de.smartics.properties/smartics-properties-core
@SuppressWarnings(UNCHECKED)
private void addTags(final ProjectdocMetaData metaData, final Element filing)
{
final Element tagsElement = filing.getChild("tags", getNs());
if (tagsElement != null)
{
final List<Element> tags = tagsElement.getChildren("tag", getNs());
for (final Element tag : tags)
{
final String tagName = tag.getTextNormalize();
metaData.addTag(tagName);
}
}
}
代码示例来源:origin: de.julielab/jcore-mallet-0.4
protected String getTextWithinElement (Element node)
{
StringBuffer substringBuf = new StringBuffer();
List children = node.getContent();
Iterator iterator = children.iterator();
String intString;
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof Element) {
if (!((Element)o).getChildren().isEmpty ())
intString = getTextWithinElement ((Element)o);
else {
intString = ((Element)o).getTextNormalize();
}
substringBuf.append(intString);
}
else if (o instanceof Text) {
substringBuf.append(((Text)o).getText());
}
}
return substringBuf.toString();
}
}
代码示例来源:origin: edu.ucar/opendap
/**
* A convienience function used for displaying information in _Debug mode.
* Prints an XML element's name, content (if any) and Attributes to
* System.out
*/
private void showXMLElement(Element e, String indent) {
System.out.print(parseLevel + indent + "Element: " + e.getName() + " ");
String text = e.getTextNormalize();
if (!text.equals(""))
System.out.print(" = " + text + " ");
//System.out.println("");
Iterator atts = e.getAttributes().iterator();
while (atts.hasNext()) {
org.jdom.Attribute att = (org.jdom.Attribute) atts.next();
//System.out.print(parseLevel + indent + " ");
System.out.print(att.getName() + ": " + att.getValue() + " ");
}
System.out.println("");
Iterator kids = e.getChildren().iterator();
while (kids.hasNext()) {
Element kid = (Element) kids.next();
showXMLElement(kid, indent + " ");
}
}
代码示例来源:origin: de.smartics.properties/smartics-properties-core
@SuppressWarnings(UNCHECKED)
private void addCategories(final ProjectdocMetaData metaData,
final Element filing)
{
final Element categoriesElement = filing.getChild("categories", getNs());
if (categoriesElement != null)
{
final List<Element> categories =
categoriesElement.getChildren("category", getNs());
for (final Element category : categories)
{
final String categoryName = category.getTextNormalize();
metaData.addCategory(categoryName);
}
}
}
代码示例来源:origin: de.smartics.properties/smartics-properties-core
@SuppressWarnings(UNCHECKED)
private void addParents(final ProjectdocMetaData metaData,
final Element filing)
{
final Element parentsElement = filing.getChild("parents", getNs());
if (parentsElement != null)
{
final List<Element> parents =
parentsElement.getChildren("parent", getNs());
for (final Element parent : parents)
{
final String parentName = parent.getTextNormalize();
metaData.addParent(parentName);
}
}
}
代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers
@Override
protected List<YExportable> parse(Element root, Namespace ns, Object... hints) {
List<YExportable> ret=super.parse(root, ns, hints);
YElement element=(YElement) ret.get(0);
ns = root.getNamespace("base_dc");
@SuppressWarnings("unchecked")
List<Element> classcodeElements = Collections.checkedList(root.getChildren(BaseDublinCoreElementsNames.BASE_DC_AUTOCLASSCODE, ns), Element.class);
for (Element classcodeElement : classcodeElements) {
element.addCategoryRef(fromBaseDdcInfered(classcodeElement.getTextNormalize()));
}
@SuppressWarnings("unchecked")
List<Element> autoClasscodeElements = Collections.checkedList(root.getChildren(BaseDublinCoreElementsNames.BASE_DC_CLASSCODE, ns), Element.class);
for (Element autoClasscodeElement : autoClasscodeElements) {
element.addCategoryRef(fromBaseDdcByHand(autoClasscodeElement.getTextNormalize()));
}
return ret;
}
代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers
private void updateJournalAids(org.jdom.Element jmeta, YElement journal) {
List<org.jdom.Element> aids = JDOMHelper.getChildren(jmeta, "journal-id");
for (org.jdom.Element aid : aids) {
String journalIdType = aid.getAttributeValue("journal-id-type");
String idVal = aid.getTextNormalize();
if ("eudml-id".equalsIgnoreCase(journalIdType)) {
journal.addId(new YId(IdSchemaIds.EXT_SCHEMA_EUDML, idVal));
} else if ("doi".equalsIgnoreCase(journalIdType)) {
journal.addId(new YId(IdSchemaIds.EXT_SCHEME_DOI, idVal));
} else if ("issn".equalsIgnoreCase(journalIdType)) {
journal.addId(new YId(IdSchemaIds.EXT_SCHEME_ISSN, idVal));
} else if ("pubmed".equalsIgnoreCase(journalIdType)) {
journal.addId(new YId(IdSchemaIds.EXT_SCHEME_PMID, idVal));
} else if ("cedram-id".equalsIgnoreCase(journalIdType)) {
journal.addId(new YId(IdSchemaIds.EXT_SCHEME_CEDRAM, idVal));
}else {
journal.addAttribute( journalIdType, idVal);
}
}
}
//?? do we need this?
内容来源于网络,如有侵权,请联系作者删除!