use of org.apache.xmlbeans.XmlCursor in project hackpad by dropbox.
the class XML method getXmlObject.
XmlObject getXmlObject() {
XmlObject xo;
XmlCursor cursor = newCursor();
try {
xo = cursor.getObject();
} finally {
cursor.dispose();
}
return xo;
}
use of org.apache.xmlbeans.XmlCursor in project hackpad by dropbox.
the class XML method setLocalName.
/**
*
* @param name
*/
void setLocalName(String localName) {
XmlCursor cursor = newCursor();
try {
if (cursor.isStartdoc())
cursor.toFirstContentToken();
if (cursor.isText() || cursor.isComment())
return;
javax.xml.namespace.QName qname = cursor.getName();
cursor.setName(new javax.xml.namespace.QName(qname.getNamespaceURI(), localName, qname.getPrefix()));
} finally {
cursor.dispose();
}
}
use of org.apache.xmlbeans.XmlCursor in project hackpad by dropbox.
the class XML method tokenType.
/**
*
* @return
*/
XmlCursor.TokenType tokenType() {
XmlCursor.TokenType result;
XmlCursor curs = newCursor();
if (curs.isStartdoc()) {
curs.toFirstContentToken();
}
result = curs.currentTokenType();
curs.dispose();
return result;
}
use of org.apache.xmlbeans.XmlCursor in project hackpad by dropbox.
the class XML method removeChild.
/**
*
* @param index
*/
protected void removeChild(long index) {
XmlCursor curs = newCursor();
if (moveToChild(curs, index, false, false)) {
removeToken(curs);
}
curs.dispose();
}
use of org.apache.xmlbeans.XmlCursor in project hackpad by dropbox.
the class XML method namespace.
/**
*
* @param prefix
* @return
*/
Object namespace(String prefix) {
XmlCursor cursor = newCursor();
if (cursor.isStartdoc()) {
cursor.toFirstContentToken();
}
Object result = null;
if (prefix == null) {
if (cursor.isStart() || cursor.isAttr()) {
Object[] inScopeNS = NamespaceHelper.inScopeNamespaces(lib, cursor);
// XXX Is it reaaly necessary to create the second cursor?
XmlCursor cursor2 = newCursor();
if (cursor2.isStartdoc())
cursor2.toFirstContentToken();
result = NamespaceHelper.getNamespace(lib, cursor2, inScopeNS);
cursor2.dispose();
}
} else {
Map prefixToURI = NamespaceHelper.getAllNamespaces(lib, cursor);
String uri = (String) prefixToURI.get(prefix);
result = (uri == null) ? Undefined.instance : new Namespace(lib, prefix, uri);
}
cursor.dispose();
return result;
}
Aggregations