本文整理汇总了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());
}
示例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;
}