List of usage examples for org.jdom2 Element getAttributeValue
public String getAttributeValue(final String attname, final Namespace ns)
This returns the attribute value for the attribute with the given name and within the given Namespace, null if there is no such attribute, and the empty string if the attribute value is empty.
From source file:com.rometools.propono.atom.common.Categories.java
License:Apache License
protected void parseCategoriesElement(final Element catsElem) { if (catsElem.getAttribute("href", AtomService.ATOM_PROTOCOL) != null) { setHref(catsElem.getAttribute("href", AtomService.ATOM_PROTOCOL).getValue()); }/*from w ww .ja va2 s . c o m*/ if (catsElem.getAttribute("fixed", AtomService.ATOM_PROTOCOL) != null) { if ("yes".equals(catsElem.getAttribute("fixed", AtomService.ATOM_PROTOCOL).getValue())) { setFixed(true); } } if (catsElem.getAttribute("scheme", AtomService.ATOM_PROTOCOL) != null) { setScheme(catsElem.getAttribute("scheme", AtomService.ATOM_PROTOCOL).getValue()); } // Loop to parse <atom:category> elemenents to Category objects final List<Element> catElems = catsElem.getChildren("category", AtomService.ATOM_FORMAT); for (final Element catElem : catElems) { final Category cat = new Category(); cat.setTerm(catElem.getAttributeValue("term", AtomService.ATOM_FORMAT)); cat.setLabel(catElem.getAttributeValue("label", AtomService.ATOM_FORMAT)); cat.setScheme(catElem.getAttributeValue("scheme", AtomService.ATOM_FORMAT)); addCategory(cat); } }
From source file:com.rometools.rome.io.impl.Atom10Parser.java
License:Open Source License
protected WireFeed parseFeed(final Element eFeed, final Locale locale) throws FeedException { String baseURI = null;/*from www . ja v a 2 s .c o m*/ try { baseURI = findBaseURI(eFeed); } catch (final Exception e) { throw new FeedException("ERROR while finding base URI of feed", e); } final Feed feed = parseFeedMetadata(baseURI, eFeed, locale); feed.setStyleSheet(getStyleSheet(eFeed.getDocument())); final String xmlBase = eFeed.getAttributeValue("base", Namespace.XML_NAMESPACE); if (xmlBase != null) { feed.setXmlBase(xmlBase); } feed.setModules(parseFeedModules(eFeed, locale)); final List<Element> eList = eFeed.getChildren("entry", getAtomNamespace()); if (!eList.isEmpty()) { feed.setEntries(parseEntries(feed, baseURI, eList, locale)); } final List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace()); if (!foreignMarkup.isEmpty()) { feed.setForeignMarkup(foreignMarkup); } return feed; }
From source file:com.rometools.rome.io.impl.Atom10Parser.java
License:Open Source License
protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI, final Locale locale) { final Entry entry = new Entry(); final String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE); if (xmlBase != null) { entry.setXmlBase(xmlBase);//from w ww. java 2 s.c om } final Element title = eEntry.getChild("title", getAtomNamespace()); if (title != null) { final Content c = new Content(); c.setValue(parseTextConstructToString(title)); c.setType(getAttributeValue(title, "type")); entry.setTitleEx(c); } final List<Element> links = eEntry.getChildren("link", getAtomNamespace()); entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, links)); entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, links)); final List<Element> authors = eEntry.getChildren("author", getAtomNamespace()); if (!authors.isEmpty()) { entry.setAuthors(parsePersons(baseURI, authors, locale)); } final List<Element> contributors = eEntry.getChildren("contributor", getAtomNamespace()); if (!contributors.isEmpty()) { entry.setContributors(parsePersons(baseURI, contributors, locale)); } final Element id = eEntry.getChild("id", getAtomNamespace()); if (id != null) { entry.setId(id.getText()); } final Element updated = eEntry.getChild("updated", getAtomNamespace()); if (updated != null) { entry.setUpdated(DateParser.parseDate(updated.getText(), locale)); } final Element published = eEntry.getChild("published", getAtomNamespace()); if (published != null) { entry.setPublished(DateParser.parseDate(published.getText(), locale)); } final Element summary = eEntry.getChild("summary", getAtomNamespace()); if (summary != null) { entry.setSummary(parseContent(summary)); } final Element content = eEntry.getChild("content", getAtomNamespace()); if (content != null) { final List<Content> contents = new ArrayList<Content>(); contents.add(parseContent(content)); entry.setContents(contents); } final Element rights = eEntry.getChild("rights", getAtomNamespace()); if (rights != null) { entry.setRights(rights.getText()); } final List<Element> categories = eEntry.getChildren("category", getAtomNamespace()); entry.setCategories(parseCategories(baseURI, categories)); // TODO: SHOULD handle Atom entry source element final Element source = eEntry.getChild("source", getAtomNamespace()); if (source != null) { entry.setSource(parseFeedMetadata(baseURI, source, locale)); } entry.setModules(parseItemModules(eEntry, locale)); final List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace()); if (!foreignMarkup.isEmpty()) { entry.setForeignMarkup(foreignMarkup); } return entry; }
From source file:com.rometools.rome.io.impl.RSS10Parser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>/*from w ww .j av a 2s . co m*/ * It first invokes super.parseItem and then parses and injects the description property if * present. * <p/> * * @param rssRoot the root element of the RSS document in case it's needed for context. * @param eItem the item element to parse. * @return the parsed RSSItem bean. */ @Override protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) { final Item item = super.parseItem(rssRoot, eItem, locale); final Element description = eItem.getChild("description", getRSSNamespace()); if (description != null) { item.setDescription(parseItemDescription(rssRoot, description)); } final Element encoded = eItem.getChild("encoded", getContentNamespace()); if (encoded != null) { final Content content = new Content(); content.setType(Content.HTML); content.setValue(encoded.getText()); item.setContent(content); } final String about = eItem.getAttributeValue("about", getRDFNamespace()); if (about != null) { item.setUri(about); } return item; }
From source file:com.rometools.rome.io.impl.RSS10Parser.java
License:Open Source License
@Override protected WireFeed parseChannel(final Element rssRoot, final Locale locale) { final Channel channel = (Channel) super.parseChannel(rssRoot, locale); final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final String uri = eChannel.getAttributeValue("about", getRDFNamespace()); if (uri != null) { channel.setUri(uri);//from www .j ava 2 s.c o m } return channel; }
From source file:com.sun.syndication.io.impl.Atom10Parser.java
License:Open Source License
protected WireFeed parseFeed(Element eFeed) throws FeedException { String baseURI = null;/*w w w . j a v a 2 s .c o m*/ try { baseURI = findBaseURI(eFeed); } catch (Exception e) { throw new FeedException("ERROR while finding base URI of feed", e); } Feed feed = parseFeedMetadata(baseURI, eFeed); String xmlBase = eFeed.getAttributeValue("base", Namespace.XML_NAMESPACE); if (xmlBase != null) { feed.setXmlBase(xmlBase); } feed.setModules(parseFeedModules(eFeed)); List eList = eFeed.getChildren("entry", getAtomNamespace()); if (eList.size() > 0) { feed.setEntries(parseEntries(feed, baseURI, eList)); } List foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace()); if (foreignMarkup.size() > 0) { feed.setForeignMarkup(foreignMarkup); } return feed; }
From source file:com.sun.syndication.io.impl.Atom10Parser.java
License:Open Source License
protected Entry parseEntry(Feed feed, Element eEntry, String baseURI) { Entry entry = new Entry(); String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE); if (xmlBase != null) { entry.setXmlBase(xmlBase);/* w w w . j a va 2 s .c o m*/ } Element e = eEntry.getChild("title", getAtomNamespace()); if (e != null) { Content c = new Content(); c.setValue(parseTextConstructToString(e)); c.setType(getAttributeValue(e, "type")); entry.setTitleEx(c); } List eList = eEntry.getChildren("link", getAtomNamespace()); entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, eList)); entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, eList)); eList = eEntry.getChildren("author", getAtomNamespace()); if (eList.size() > 0) { entry.setAuthors(parsePersons(baseURI, eList)); } eList = eEntry.getChildren("contributor", getAtomNamespace()); if (eList.size() > 0) { entry.setContributors(parsePersons(baseURI, eList)); } e = eEntry.getChild("id", getAtomNamespace()); if (e != null) { entry.setId(e.getText()); } e = eEntry.getChild("updated", getAtomNamespace()); if (e != null) { entry.setUpdated(DateParser.parseDate(e.getText())); } e = eEntry.getChild("published", getAtomNamespace()); if (e != null) { entry.setPublished(DateParser.parseDate(e.getText())); } e = eEntry.getChild("summary", getAtomNamespace()); if (e != null) { entry.setSummary(parseContent(e)); } e = eEntry.getChild("content", getAtomNamespace()); if (e != null) { List contents = new ArrayList(); contents.add(parseContent(e)); entry.setContents(contents); } e = eEntry.getChild("rights", getAtomNamespace()); if (e != null) { entry.setRights(e.getText()); } List cList = eEntry.getChildren("category", getAtomNamespace()); entry.setCategories(parseCategories(baseURI, cList)); // TODO: SHOULD handle Atom entry source element e = eEntry.getChild("source", getAtomNamespace()); if (e != null) { entry.setSource(parseFeedMetadata(baseURI, e)); } entry.setModules(parseItemModules(eEntry)); List foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace()); if (foreignMarkup.size() > 0) { entry.setForeignMarkup(foreignMarkup); } return entry; }
From source file:com.sun.syndication.io.impl.RSS10Parser.java
License:Open Source License
/** * Parses an item element of an RSS document looking for item information. * <p/>//from www . jav a 2 s .c o m * It first invokes super.parseItem and then parses and injects the description property if present. * <p/> * * @param rssRoot the root element of the RSS document in case it's needed for context. * @param eItem the item element to parse. * @return the parsed RSSItem bean. */ protected Item parseItem(Element rssRoot, Element eItem) { Item item = super.parseItem(rssRoot, eItem); Element e = eItem.getChild("description", getRSSNamespace()); if (e != null) { item.setDescription(parseItemDescription(rssRoot, e)); } Element ce = eItem.getChild("encoded", getContentNamespace()); if (ce != null) { Content content = new Content(); content.setType(Content.HTML); content.setValue(ce.getText()); item.setContent(content); } String uri = eItem.getAttributeValue("about", getRDFNamespace()); if (uri != null) { item.setUri(uri); } return item; }
From source file:com.sun.syndication.io.impl.RSS10Parser.java
License:Open Source License
protected WireFeed parseChannel(Element rssRoot) { Channel channel = (Channel) super.parseChannel(rssRoot); Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); String uri = eChannel.getAttributeValue("about", getRDFNamespace()); if (uri != null) { channel.setUri(uri);// ww w .ja va 2 s. c o m } return channel; }
From source file:com.tactfactory.harmony.generator.androidxml.ManifestUpdater.java
License:Open Source License
/** * Get the list of all the launcher activities names. * @return The launcher activities names *//*from w ww.j av a 2 s .co m*/ public List<String> getLauncherActivitiesNames() { // Load Root element final Element rootNode = this.getDocument().getRootElement(); // Load Name space (required for manipulate attributes) final Namespace ns = rootNode.getNamespace(ManifestConstants.NAMESPACE_ANDROID); List<String> result = new ArrayList<String>(); List<Element> activities = this.getActivities(); if (activities != null) { for (Element activity : activities) { List<Element> intentFilters = activity.getChildren(ManifestConstants.ELEMENT_INTENT_FILTER); if (intentFilters != null) { for (Element intentFilter : intentFilters) { List<Element> categories = intentFilter.getChildren(ManifestConstants.ELEMENT_CATEGORY); if (categories != null) { for (Element category : categories) { String categoryName = category.getAttributeValue(ManifestConstants.ATTRIBUTE_NAME, ns); if ("android.intent.category.LAUNCHER".equals(categoryName)) { result.add(activity.getAttributeValue(ManifestConstants.ATTRIBUTE_NAME, ns)); } } } } } } } return result; }