當前位置: 首頁>>代碼示例>>Java>>正文


Java DocumentFragment類代碼示例

本文整理匯總了Java中org.w3c.dom.DocumentFragment的典型用法代碼示例。如果您正苦於以下問題:Java DocumentFragment類的具體用法?Java DocumentFragment怎麽用?Java DocumentFragment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DocumentFragment類屬於org.w3c.dom包,在下文中一共展示了DocumentFragment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: appendChildToDocument

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/**
 * Appends an image child to the panelGroup in the underlying JSP document
 */
public void appendChildToDocument(ActionEvent event)
{
  UIComponent eventSource = event.getComponent();
  UIComponent uic = eventSource.findComponent("pg1");
  
  // only allow the image to be added once
  if (_findChildById(uic,"oi3") != null)
    return;
    
  FacesContext fc = FacesContext.getCurrentInstance();

  DocumentFragment imageFragment = _createDocumentFragment(_IMAGE_MARK_UP);
  
  if (imageFragment != null)
  {
    DocumentChange change = new AddChildDocumentChange(imageFragment);
    
    ChangeManager apm = RequestContext.getCurrentInstance().getChangeManager();
    
    apm.addDocumentChange(fc, uic, change);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:26,代碼來源:ChangeBean.java

示例2: decryptUsingResolvedEncryptedKey

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/**
 * Attempt to decrypt by resolving the decryption key by first resolving EncryptedKeys, and using the KEK credential
 * resolver to resolve the key decryption for each.
 * 
 * @param encryptedData the encrypted data to decrypt
 * @param algorithm the algorithm of the key to be decrypted
 * @return the decrypted document fragment, or null if decryption key could not be resolved or decryption failed
 */
private DocumentFragment decryptUsingResolvedEncryptedKey(EncryptedData encryptedData, String algorithm) {
    if (encKeyResolver != null) {
        for (EncryptedKey encryptedKey : encKeyResolver.resolve(encryptedData)) {
            try {
                Key decryptedKey = decryptKey(encryptedKey, algorithm);
                return decryptDataToDOM(encryptedData, decryptedKey);
            } catch (DecryptionException e) {
                String msg = "Attempt to decrypt EncryptedData using key extracted from EncryptedKey failed: ";
                log.debug(msg, e);
                continue;
            }
        }
    }
    return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:Decrypter.java

示例3: parseInputStream

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/**
 * Parse the specified input stream in a DOM DocumentFragment, owned by the specified Document.
 * 
 * @param input the InputStream to parse
 * @param owningDocument the Document which will own the returned DocumentFragment
 * @return a DocumentFragment
 * @throws DecryptionException thrown if there is an error parsing the input stream
 */
private DocumentFragment parseInputStream(InputStream input, Document owningDocument) throws DecryptionException {
    // Since Xerces currently seems not to handle parsing into a DocumentFragment
    // without a bit hackery, use this to simulate, so we can keep the API
    // the way it hopefully will look in the future. Obviously this only works for
    // input streams containing valid XML instances, not fragments.

    Document newDocument = null;
    try {
        newDocument = parserPool.parse(input);
    } catch (XMLParserException e) {
        log.error("Error parsing decrypted input stream", e);
        throw new DecryptionException("Error parsing input stream", e);
    }

    Element element = newDocument.getDocumentElement();
    owningDocument.adoptNode(element);

    DocumentFragment container = owningDocument.createDocumentFragment();
    container.appendChild(element);

    return container;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:Decrypter.java

示例4: getElement

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
public Element getElement(DOMResult r) {
    // JAXP spec is ambiguous about what really happens in this case,
    // so work defensively
    Node n = r.getNode();
    if( n instanceof Document ) {
        return ((Document)n).getDocumentElement();
    }
    if( n instanceof Element )
        return (Element)n;
    if( n instanceof DocumentFragment )
        return (Element)n.getChildNodes().item(0);

    // if the result object contains something strange,
    // it is not a user problem, but it is a JAXB provider's problem.
    // That's why we throw a runtime exception.
    throw new IllegalStateException(n.toString());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:W3CDomHandler.java

示例5: addNode

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
protected void addNode(org.w3c.dom.Node newElement) throws SOAPException {
    insertBefore(soapDocument.getDomNode(newElement), null);

    if (getOwnerDocument() instanceof DocumentFragment)
        return;

    if (newElement instanceof ElementImpl) {
        ElementImpl element = (ElementImpl) newElement;
        QName elementName = element.getElementQName();
        if (!"".equals(elementName.getNamespaceURI())) {
            element.ensureNamespaceIsDeclared(
                elementName.getPrefix(), elementName.getNamespaceURI());
        }
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:ElementImpl.java

示例6: filter

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/** Run all defined filters. */
public ParseResult filter(Content content, ParseResult parseResult,
    HTMLMetaTags metaTags, DocumentFragment doc) {

  // loop on each filter
  for (int i = 0; i < this.htmlParseFilters.length; i++) {
    // call filter interface
    parseResult = htmlParseFilters[i].filter(content, parseResult, metaTags,
        doc);

    // any failure on parse obj, return
    if (!parseResult.isSuccess()) {
      // TODO: What happens when parseResult.isEmpty() ?
      // Maybe clone parseResult and use parseResult as backup...

      // remove failed parse before return
      parseResult.filter();
      return parseResult;
    }
  }

  return parseResult;
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:24,代碼來源:HtmlParseFilters.java

示例7: filter

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/**
 * Scan the HTML document looking at possible rel-tags
 */
public ParseResult filter(Content content, ParseResult parseResult,
    HTMLMetaTags metaTags, DocumentFragment doc) {

  // get parse obj
  Parse parse = parseResult.get(content.getUrl());
  // Trying to find the document's rel-tags
  Parser parser = new Parser(doc);
  Set<?> tags = parser.getRelTags();
  Iterator<?> iter = tags.iterator();
  Metadata metadata = parse.getData().getParseMeta();
  while (iter.hasNext())
    metadata.add(REL_TAG, (String) iter.next());

  return parseResult;
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:19,代碼來源:RelTagParser.java

示例8: filter

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
public ParseResult filter(Content content, ParseResult parseResult,
    HTMLMetaTags metaTags, DocumentFragment doc) {

  Parse parse = parseResult.get(content.getUrl());

  String url = content.getBaseUrl();
  ArrayList<Outlink> outlinks = new ArrayList<Outlink>();
  walk(doc, parse, metaTags, url, outlinks);
  if (outlinks.size() > 0) {
    Outlink[] old = parse.getData().getOutlinks();
    String title = parse.getData().getTitle();
    List<Outlink> list = Arrays.asList(old);
    outlinks.addAll(list);
    ParseStatus status = parse.getData().getStatus();
    String text = parse.getText();
    Outlink[] newlinks = (Outlink[]) outlinks.toArray(new Outlink[outlinks
        .size()]);
    ParseData parseData = new ParseData(status, title, newlinks, parse
        .getData().getContentMeta(), parse.getData().getParseMeta());

    // replace original parse obj with new one
    parseResult.put(content.getUrl(), new ParseText(text), parseData);
  }
  return parseResult;
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:26,代碼來源:JSParseFilter.java

示例9: detectLanguage

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/** Try to find the document's language from page headers and metadata */
private String detectLanguage(Parse page, DocumentFragment doc) {
  String lang = getLanguageFromMetadata(page.getData().getParseMeta());
  if (lang == null) {
    LanguageParser parser = new LanguageParser(doc);
    lang = parser.getLanguage();
  }

  if (lang != null) {
    return lang;
  }

  lang = page.getData().getContentMeta().get(Response.CONTENT_LANGUAGE);

  return lang;
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:17,代碼來源:HTMLLanguageParser.java

示例10: getElement

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
public Element getElement(DOMResult r) {
    // JAXP spec is ambiguous about what really happens in this case,
    // so work defensively
    Node n = r.getNode();
    if( n instanceof Document) {
        return ((Document)n).getDocumentElement();
    }
    if( n instanceof Element )
        return (Element)n;
    if( n instanceof DocumentFragment)
        return (Element)n.getChildNodes().item(0);

    // if the result object contains something strange,
    // it is not a user problem, but it is a JAXB provider's problem.
    // That's why we throw a runtime exception.
    throw new IllegalStateException(n.toString());
}
 
開發者ID:warnerbros,項目名稱:cpe-manifest-android-experience,代碼行數:18,代碼來源:W3CDomHandler.java

示例11: createBlockForSdt

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
public static DocumentFragment createBlockForSdt(FOConversionContext context, 
    		NodeIterator pPrNodeIt,
    		String pStyleVal, NodeIterator childResults, String tag) {
    	
    	DocumentFragment docfrag = createBlock(context,
        		 pPrNodeIt,
        		 pStyleVal,  childResults,
        		 true);
    	
    	// Set margins, but only for a shading container,
    	// not a borders container
    	if (tag.equals(Containerization.TAG_SHADING) && docfrag!=null) {
    		// docfrag.getNodeName() is  #document-fragment
    	    Node foBlock = docfrag.getFirstChild();
    	    if (foBlock!=null) {
				((Element)foBlock).setAttribute("margin-top", "0in");    	    	
				((Element)foBlock).setAttribute("margin-bottom", "0in");    	    	

//				((Element)foBlock).setAttribute("padding-top", "0in");    	    	
//				((Element)foBlock).setAttribute("padding-bottom", "0in");    	    	
    	    }
    	}
    	    
    	return docfrag;
    }
 
開發者ID:plutext,項目名稱:docx4j-export-FO,代碼行數:26,代碼來源:XsltFOFunctions.java

示例12: setFont

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
/**
 * Use RunFontSelector to determine the correct font for the list item label.
 * 
 * @param context
 * @param foListItemLabelBody
 * @param pPr
 * @param rPr
 * @param text
 */
protected static void setFont(FOConversionContext context, Element foListItemLabelBody, PPr pPr, RPr rPr, String text) {
	
	DocumentFragment result = (DocumentFragment)context.getRunFontSelector().fontSelector(pPr, rPr, text);
	log.debug(XmlUtils.w3CDomNodeToString(result));
	// eg <fo:inline xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">1)</fo:inline>
	
	// Now get the attribute value
	if (result!=null && result.getFirstChild()!=null) {
		Attr attr = ((Element)result.getFirstChild()).getAttributeNode("font-family");
		if (attr!=null) {
			foListItemLabelBody.setAttribute("font-family", attr.getValue());
		}
	}
			
}
 
開發者ID:plutext,項目名稱:docx4j-export-FO,代碼行數:25,代碼來源:XsltFOFunctions.java

示例13: getLayoutMasterSetFragment

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
public static DocumentFragment getLayoutMasterSetFragment(AbstractWmlConversionContext context) {

		LayoutMasterSet lms = getFoLayoutMasterSet(context);	
		
		// Set suitable extents, for which we need area tree 
		FOSettings foSettings = (FOSettings)context.getConversionSettings();
		if ( !foSettings.lsLayoutMasterSetCalculationInProgress()) // Avoid infinite loop
			// Can't just do it where foSettings.getApacheFopMime() is not MimeConstants.MIME_FOP_AREA_TREE,
			// since TOC functionality uses that.
		{
			fixExtents( lms, context, true);
		}
		
		org.w3c.dom.Document document = XmlUtils.marshaltoW3CDomDocument(lms, Context.getXslFoContext() );
		DocumentFragment docfrag = document.createDocumentFragment();
		docfrag.appendChild(document.getDocumentElement());
		
		
		return docfrag;		
	}
 
開發者ID:plutext,項目名稱:docx4j-export-FO,代碼行數:21,代碼來源:LayoutMasterSetBuilder.java

示例14: getValue

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
Object getValue(Stylesheet stylesheet, QName mode,
                Node context, int pos, int len)
  throws TransformerException
{
  if (select != null)
    return select.evaluate(context, pos, len);
  else if (children != null)
    {
      Document doc = (context instanceof Document) ? (Document) context :
        context.getOwnerDocument();
      DocumentFragment fragment = doc.createDocumentFragment();
      children.apply(stylesheet, mode, context, pos, len, fragment, null);
      return Collections.singleton(fragment);
    }
  else
    return null;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:18,代碼來源:ParameterNode.java

示例15: getValue

import org.w3c.dom.DocumentFragment; //導入依賴的package包/類
Object getValue(Stylesheet stylesheet, QName mode,
                Node context, int pos, int len)
  throws TransformerException
{
  if (select != null)
    {
      return select.evaluate(context, pos, len);
    }
  else if (content == null)
    {
      return "";
    }
  else
    {
      Document doc = (context instanceof Document) ? (Document) context :
        context.getOwnerDocument();
      DocumentFragment fragment = doc.createDocumentFragment();
      content.apply(stylesheet, mode,
                    context, pos, len,
                    fragment, null);
      return Collections.singleton(fragment);
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:24,代碼來源:WithParam.java


注:本文中的org.w3c.dom.DocumentFragment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。