예제 #1
0
 @Nonnull
 public IMicroDocument getAsDocument() {
   final IMicroDocument aDocument = new MicroDocument();
   final IMicroElement aElement = aDocument.appendElement(CFeed.XMLNS_ATOM, "feed");
   super.fillElement(aElement);
   for (final IFeedElement aEntry : m_aEntries) aElement.appendChild(aEntry.getAsElement("entry"));
   return aDocument;
 }
예제 #2
0
 public CSSFiles(@Nonnull final IReadableResource aFile) {
   final IMicroDocument aDoc = MicroReader.readMicroXML(aFile);
   if (aDoc != null) {
     final IMicroElement eRoot = aDoc.getDocumentElement();
     if (eRoot.getTagName().equals("list")) {
       // Old style
       s_aLogger.warn("CSS file " + aFile.getPath() + " is in old syntax");
       final List<String> aAllCSSFiles = new ArrayList<String>();
       if (XMLListHandler.readList(eRoot, aAllCSSFiles).isFailure())
         s_aLogger.error("Failed to read " + aFile.getPath());
       for (final String sCSS : aAllCSSFiles) addGlobalItem(null, sCSS, null);
     } else {
       // New style
       for (final IMicroElement eChild : eRoot.getAllChildElements("css")) {
         final String sCondComment = eChild.getAttribute("condcomment");
         final String sPath = eChild.getAttribute("path");
         if (StringHelper.hasNoText(sPath)) {
           s_aLogger.error("Found CSS item without a path in " + aFile.getPath());
           continue;
         }
         final String sMedia = eChild.getAttribute("media");
         // ESCA-JAVA0261:
         final Set<ECSSMedium> aMediaList = new LinkedHashSet<ECSSMedium>();
         if (sMedia != null)
           for (final String sMedium : RegExHelper.getSplitToArray(sMedia, ",\\s*")) {
             final ECSSMedium eMedium = ECSSMedium.getFromNameOrNull(sMedium);
             if (eMedium == null) {
               s_aLogger.warn(
                   "CSS item '"
                       + sPath
                       + "' in "
                       + aFile.getPath()
                       + " has an invalid medium '"
                       + sMedium
                       + "' - ignoring");
               continue;
             }
             aMediaList.add(eMedium);
           }
         addGlobalItem(sCondComment, sPath, aMediaList);
       }
     }
   }
 }
예제 #3
0
 /**
  * Interpret the passed XHTML fragment as HTML and retrieve a result container with all body
  * elements.
  *
  * @param sXHTML The XHTML text fragment. This fragment is parsed as an HTML body and may
  *     therefore not contain the &lt;body&gt; tag.
  * @return <code>null</code> if the passed text could not be interpreted as XHTML or if no body
  *     element was found, an {@link IMicroContainer} with all body children otherwise.
  */
 @Nullable
 public IMicroContainer unescapeXHTMLFragment(@Nullable final String sXHTML) {
   // Ensure that the content is surrounded by a single tag
   final IMicroDocument aDoc = parseXHTMLFragment(sXHTML);
   if (aDoc != null && aDoc.getDocumentElement() != null) {
     // Find "body" case insensitive
     final IMicroElement eBody =
         HCUtils.getFirstChildElement(aDoc.getDocumentElement(), EHTMLElement.BODY);
     if (eBody != null) {
       final IMicroContainer ret = new MicroContainer();
       if (eBody.hasChildren()) {
         // Make a copy of the list, because it is modified in
         // detachFromParent!
         for (final IMicroNode aChildNode : ContainerHelper.newList(eBody.getChildren()))
           ret.appendChild(aChildNode.detachFromParent());
       }
       return ret;
     }
   }
   return null;
 }