コード例 #1
0
 /**
  * Parse the given fragment as XHTML 1.1. This is a sanity method for {@link
  * #parseXHTMLFragment(String)} with the predefined XHTML 1.1 document type.
  *
  * @param sXHTMLFragment The XHTML fragment to parse. May be <code>null</code>.
  * @return <code>null</code> if parsing failed.
  */
 @Nullable
 public IMicroDocument parseXHTMLFragment(@Nullable final String sXHTMLFragment) {
   // Build mini HTML and insert fragment in the middle.
   // If parsing succeeds, it is considered valid HTML.
   final String sHTMLNamespaceURI = this.m_eHTMLVersion.getNamespaceURI();
   final String sXHTML =
       XMLEmitterPhloc.getDocTypeHTMLRepresentation(
               EXMLSerializeVersion.XML_10,
               EXMLIncorrectCharacterHandling.DEFAULT,
               this.m_eHTMLVersion.getDocType())
           + "<html"
           + (sHTMLNamespaceURI != null
               ? ' ' + CXML.XML_ATTR_XMLNS + "=\"" + sHTMLNamespaceURI + '"'
               : "")
           + "><head><title></title></head><body>"
           + StringHelper.getNotNull(sXHTMLFragment)
           + "</body></html>";
   return parseXHTMLDocument(sXHTML);
 }
コード例 #2
0
ファイル: HCTextNode.java プロジェクト: phlocbg/phloc-html
 @Nonnull
 public HCTextNode setText(@Nullable final String sText) {
   m_sText = StringHelper.getNotNull(sText);
   return this;
 }