当前位置: 首页>>代码示例>>Java>>正文


Java XSAnnotation.W3C_DOM_ELEMENT属性代码示例

本文整理汇总了Java中com.sun.org.apache.xerces.internal.xs.XSAnnotation.W3C_DOM_ELEMENT属性的典型用法代码示例。如果您正苦于以下问题:Java XSAnnotation.W3C_DOM_ELEMENT属性的具体用法?Java XSAnnotation.W3C_DOM_ELEMENT怎么用?Java XSAnnotation.W3C_DOM_ELEMENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.sun.org.apache.xerces.internal.xs.XSAnnotation的用法示例。


在下文中一共展示了XSAnnotation.W3C_DOM_ELEMENT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeToDOM

private synchronized void writeToDOM(Node target, short type) {
    Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ?
            target.getOwnerDocument() : (Document)target;
    DOMParser parser = fGrammar.getDOMParser();
    StringReader aReader = new StringReader(fData);
    InputSource aSource = new InputSource(aReader);
    try {
        parser.parse(aSource);
    }
    catch (SAXException e) {
        // this should never happen!
        // REVISIT:  what to do with this?; should really not
        // eat it...
    }
    catch (IOException i) {
        // ditto with above
    }
    Document aDocument = parser.getDocument();
    parser.dropDocumentReferences();
    Element annotation = aDocument.getDocumentElement();
    Node newElem = null;
    if (futureOwner instanceof CoreDocumentImpl) {
        newElem = futureOwner.adoptNode(annotation);
        // adoptNode will return null when the DOM implementations are not compatible.
        if (newElem == null) {
            newElem = futureOwner.importNode(annotation, true);
        }
    }
    else {
        newElem = futureOwner.importNode(annotation, true);
    }
    target.insertBefore(newElem, target.getFirstChild());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:XSAnnotationImpl.java

示例2: writeAnnotation

/**
 *  Write contents of the annotation to the specified DOM object. If the
 * specified <code>target</code> object is a DOM in-scope namespace
 * declarations for <code>annotation</code> element are added as
 * attributes nodes of the serialized <code>annotation</code>, otherwise
 * the corresponding events for all in-scope namespace declaration are
 * sent via specified document handler.
 * @param target  A target pointer to the annotation target object, i.e.
 *   <code>org.w3c.dom.Document</code>,
 *   <code>org.xml.sax.ContentHandler</code>.
 * @param targetType  A target type.
 * @return If the <code>target</code> is recognized type and supported by
 *   this implementation return true, otherwise return false.
 */
public boolean writeAnnotation(Object target,
                               short targetType) {
    if(targetType == XSAnnotation.W3C_DOM_ELEMENT || targetType == XSAnnotation.W3C_DOM_DOCUMENT) {
        writeToDOM((Node)target, targetType);
        return true;
    } else if (targetType == SAX_CONTENTHANDLER) {
        writeToSAX((ContentHandler)target);
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:XSAnnotationImpl.java


注:本文中的com.sun.org.apache.xerces.internal.xs.XSAnnotation.W3C_DOM_ELEMENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。