本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.setBookmark方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.setBookmark方法的具体用法?Java XmlCursor.setBookmark怎么用?Java XmlCursor.setBookmark使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xmlbeans.XmlCursor
的用法示例。
在下文中一共展示了XmlCursor.setBookmark方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTextElement
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param qname
* @param value
* @return
*/
static XML createTextElement(XMLLibImpl lib, javax.xml.namespace.QName qname, String value)
{
XScriptAnnotation anno;
XmlObject xo = XmlObject.Factory.newInstance();
XmlCursor cursor = xo.newCursor();
try {
cursor.toNextToken();
cursor.beginElement(qname.getLocalPart(), qname.getNamespaceURI());
//if(namespace.length() > 0)
// cursor.insertNamespace("", namespace);
cursor.insertChars(value);
cursor.toStartDoc();
cursor.toNextToken();
anno = new XScriptAnnotation(cursor);
cursor.setBookmark(anno);
} finally {
cursor.dispose();
}
return new XML(lib, anno);
}
示例2: createFromXmlObject
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
static XML createFromXmlObject(XMLLibImpl lib, XmlObject xo)
{
XScriptAnnotation anno;
XmlCursor curs = xo.newCursor();
if (curs.currentTokenType().isStartdoc())
{
curs.toFirstContentToken();
}
try {
anno = new XScriptAnnotation(curs);
curs.setBookmark(anno);
} finally {
curs.dispose();
}
return new XML(lib, anno);
}
示例3: verify_condition
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private boolean verify_condition(XmlCursor cursor, Condition condition) {
boolean more, found=false;
XmlBookmark bookmark = new XmlBookmark(){};
cursor.setBookmark(bookmark);
if (condition.isAttribute) {
for (more=cursor.toFirstAttribute(); more&&!found; more=cursor.toNextAttribute()) {
if (cursor.getName().getLocalPart().equals(condition.name)) {
found = cursor.getTextValue().trim().equals(condition.value);
}
}
} else {
for (more=cursor.toFirstChild(); more&&!found; more=cursor.toNextSibling()) {
if (cursor.getName().getLocalPart().equals(condition.name)) {
found = cursor.getTextValue().trim().equals(condition.value);
}
}
}
cursor.toBookmark(bookmark);
return found;
}
示例4: createEmptyXML
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
static XML createEmptyXML(XMLLibImpl lib)
{
XScriptAnnotation anno;
XmlObject xo = XmlObject.Factory.newInstance();
XmlCursor curs = xo.newCursor();
try {
anno = new XScriptAnnotation(curs);
curs.setBookmark(anno);
} finally {
curs.dispose();
}
return new XML(lib, anno);
}
示例5: createAttributeXML
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Special constructor for making an attribute
*
*/
private static XML createAttributeXML(XMLLibImpl lib, XmlCursor cursor)
{
if (!cursor.isAttr())
throw new IllegalArgumentException();
XScriptAnnotation anno = new XScriptAnnotation(cursor);
cursor.setBookmark(anno);
return new XML(lib, anno);
}
示例6: findAnnotation
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param curs
* @return
*/
protected static XScriptAnnotation findAnnotation(XmlCursor curs)
{
XmlBookmark anno = curs.getBookmark(XScriptAnnotation.class);
if (anno == null)
{
anno = new XScriptAnnotation(curs);
curs.setBookmark(anno);
}
return (XScriptAnnotation)anno;
}
示例7: replace
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param destCurs
* @param newValue
*/
private void replace(XmlCursor destCurs, XML newValue)
{
if (destCurs.isStartdoc())
{
// Can't overwrite a whole document (user really wants to overwrite the contents of).
destCurs.toFirstContentToken();
}
// Orphan the token -- don't delete it outright on the XmlCursor.
removeToken(destCurs);
XmlCursor srcCurs = newValue.newCursor();
if (srcCurs.currentTokenType().isStartdoc())
{
// Cann't append a whole document (user really wants to append the contents of).
srcCurs.toFirstContentToken();
}
moveSrcToDest(srcCurs, destCurs, false);
// Re-link a new annotation to this cursor -- we just deleted the previous annotation on entrance to replace.
if (!destCurs.toPrevSibling())
{
destCurs.toPrevToken();
}
destCurs.setBookmark(new XScriptAnnotation(destCurs));
// todo would be nice if destCurs.toNextSibling went to where the next token if the cursor was pointing at the last token in the stream.
destCurs.toEndToken();
destCurs.toNextToken();
srcCurs.dispose();
}
示例8: evaluate_recursive_descent
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private String evaluate_recursive_descent(XmlCursor cursor, PathSegment path) {
String value = null;
XmlBookmark bookmark = new XmlBookmark(){};
cursor.setBookmark(bookmark);
value = evaluate_segment(cursor, path);
if (value!=null) return value;
boolean more = cursor.toFirstChild();
while (value==null && more) {
value = evaluate_recursive_descent(cursor, path);
more = cursor.toNextSibling();
}
cursor.toBookmark(bookmark);
return value;
}