Exemplo n.º 1
0
  protected WireFeed parseFeed(final Element eFeed, final Locale locale) throws FeedException {

    String baseURI = null;
    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.size() > 0) {
      feed.setEntries(parseEntries(feed, baseURI, eList, locale));
    }

    final List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace());
    if (foreignMarkup.size() > 0) {
      feed.setForeignMarkup(foreignMarkup);
    }
    return feed;
  }
Exemplo n.º 2
0
  public static void saveCourseCreerToXml(Evenement event) {
    Element elementEvent = JDomOperations.getElementActuel_();
    Element listCourses = elementEvent.getChild("listcourses");

    Iterator itListCoursesInEvent = event.getIteratorCollectionEssaiCourse_();
    while (itListCoursesInEvent.hasNext()) {
      EssaiOrCourse course = (EssaiOrCourse) itListCoursesInEvent.next();
      Element elementCourse = new Element("course");
      elementCourse.setAttribute(new Attribute("nomEssaiOrCourse", course.getNomEssaiOrCourse_()));
      elementCourse.setAttribute(
          new Attribute("typeEssaiOrCourse", course.getTypeEssaiOrCourse_().toString()));

      listCourses.addContent(elementCourse);
    }

    JDomOperations.enregistre(elementEvent.getDocument(), xmlDefaultPath);
  }
Exemplo n.º 3
0
 public JElement find(final org.jdom2.Element emt) {
   final JNamespaceAware me = mapped.get(emt);
   if (me != null) {
     return (JElement) me;
   }
   final org.jdom2.Element jp = emt.getParentElement();
   if (jp == null) {
     // root level element (or detached).
     final org.jdom2.Document jd = emt.getDocument();
     // both may be null....
     if (jd != shadow) {
       // we are from different documents...
       throw new DOMException(
           DOMException.WRONG_DOCUMENT_ERR, "Element is not part of our document");
     }
     // OK, we are a root level Element... let's map ourselves.
     final NamespaceStack ns = new NamespaceStack(scope);
     ns.push(emt);
     final ArrayList<Namespace> added = new ArrayList<Namespace>();
     for (final Namespace ans : ns.addedForward()) {
       added.add(ans);
     }
     final JElement je =
         new JElement(this, this, emt, ns.getScope(), added.toArray(new Namespace[added.size()]));
     mapped.put(emt, je);
     checkID(je);
     return je;
   }
   final JElement pnt = find(jp);
   final NamespaceStack ns = new NamespaceStack(pnt.scope);
   ns.push(emt);
   final ArrayList<Namespace> added = new ArrayList<Namespace>();
   for (final Namespace ans : ns.addedForward()) {
     added.add(ans);
   }
   final JElement ret =
       new JElement(this, pnt, emt, ns.getScope(), added.toArray(new Namespace[added.size()]));
   mapped.put(emt, ret);
   checkID(ret);
   return ret;
 }