当前位置: 首页>>代码示例>>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;未经允许,请勿转载。