本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.getName方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.getName方法的具体用法?Java XmlCursor.getName怎么用?Java XmlCursor.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xmlbeans.XmlCursor
的用法示例。
在下文中一共展示了XmlCursor.getName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: localName
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @return
*/
String localName()
{
XmlCursor cursor = newCursor();
if (cursor.isStartdoc())
cursor.toFirstContentToken();
String name = null;
if(cursor.isStart() ||
cursor.isAttr() ||
cursor.isProcinst())
{
javax.xml.namespace.QName qname = cursor.getName();
name = qname.getLocalPart();
}
cursor.dispose();
return name;
}
示例2: setLocalName
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @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();
}
}
示例3: getNamespaces
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static void getNamespaces(XmlCursor cursor, Map prefixToURI)
{
cursor.push();
while(cursor.toNextToken().isAnyAttr())
{
if(cursor.isNamespace())
{
javax.xml.namespace.QName name = cursor.getName();
String prefix = name.getLocalPart();
String uri = name.getNamespaceURI();
prefixToURI.put(prefix, uri);
}
}
cursor.pop();
}
示例4: removeNamespace
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static void removeNamespace(XmlCursor cursor, String prefix)
{
cursor.push();
while(cursor.toNextToken().isAnyAttr())
{
if(cursor.isNamespace())
{
javax.xml.namespace.QName name = cursor.getName();
if(name.getLocalPart().equals(prefix))
{
cursor.removeXml();
break;
}
}
}
cursor.pop();
}
示例5: changeNS
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
protected void changeNS (String oldURI, String newURI)
{
XmlCursor curs = newCursor();
while (curs.toParent()) {
/* Goto the top of the document */
}
TokenType tt = curs.currentTokenType();
if (tt.isStartdoc())
{
tt = curs.toFirstContentToken();
}
if (tt.isStart())
{
do
{
if (tt.isStart() || tt.isAttr() || tt.isNamespace())
{
javax.xml.namespace.QName currQName = curs.getName();
if (oldURI.equals(currQName.getNamespaceURI()))
{
curs.setName(new javax.xml.namespace.QName(newURI, currQName.getLocalPart()));
}
}
tt = curs.toNextToken();
} while (!tt.isEnddoc() && !tt.isNone());
}
curs.dispose();
}
示例6: processName
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Updates the internal state of this NamespaceHelper to reflect the
* existance of the XML token pointed to by the cursor.
*/
private void processName(XmlCursor cursor, ObjArray declarations)
{
javax.xml.namespace.QName qname = cursor.getName();
String uri = qname.getNamespaceURI();
Set prefixes = (Set)uriToPrefix.get(uri);
if(prefixes == null || prefixes.size() == 0)
{
undeclared.add(uri);
if(declarations != null)
declarations.add(new Namespace(lib, uri));
}
}
示例7: update
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Updates the internal state of this NamespaceHelper with the
* namespace information of the element pointed to by the cursor.
*/
private void update(XmlCursor cursor, ObjArray declarations)
{
// Process the Namespace declarations
cursor.push();
while(cursor.toNextToken().isAnyAttr())
{
if(cursor.isNamespace())
{
javax.xml.namespace.QName name = cursor.getName();
String prefix = name.getLocalPart();
String uri = name.getNamespaceURI();
declareNamespace(prefix, uri, declarations);
}
}
cursor.pop();
// Process the element
processName(cursor, declarations);
// Process the attributes
cursor.push();
boolean hasNext = cursor.toFirstAttribute();
while(hasNext)
{
processName(cursor, declarations);
hasNext = cursor.toNextAttribute();
}
cursor.pop();
}
示例8: assertEquals
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Uses cursors to compare two XML documents, ignoring whitespace and
* ordering of attributes. Fails the JUnit test if they're different.
*
* @param message to display on test failure (may be null)
* @param expected
* @param actual
*/
public static void assertEquals(String message, XmlCursor expected, XmlCursor actual)
{
for (int child = 0; true; child++)
{
boolean child1 = expected.toChild(child);
boolean child2 = actual.toChild(child);
if (child1 != child2)
{
fail(message, "Different XML structure near " + QNameHelper.pretty(expected.getName()));
}
else if (expected.getName() != null && !expected.getName().equals(actual.getName()))
{
fail(message, "Expected element: '" + expected.getName()
+ "' differs from actual element: '" + actual.getName() + "'");
}
else if (child == 0 && !child1)
{
if (!(expected.getTextValue().equals(actual.getTextValue())))
{
fail(message, "Expected value for element " + QNameHelper.pretty(expected.getName()) + " -> '"
+ expected.getTextValue() + "' differs from actual value '" + actual.getTextValue() + "'");
}
break;
}
else if (child1)
{
assertEquals(message, expected, actual);
expected.toParent();
actual.toParent();
}
else
{
break;
}
}
assertAttributesEqual(message, expected, actual);
}
示例9: XScriptAnnotation
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
XScriptAnnotation (XmlCursor curs)
{
_name = curs.getName();
}
示例10: allChildNodes
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param namespace
* @return
*/
private XMLList allChildNodes(String namespace)
{
XMLList result = new XMLList(lib);
XmlCursor curs = newCursor();
TokenType tt = curs.currentTokenType();
javax.xml.namespace.QName targetProperty = new javax.xml.namespace.QName(namespace, "*");
if (tt.isStartdoc())
{
tt = curs.toFirstContentToken();
}
if (tt.isContainer())
{
tt = curs.toFirstContentToken();
while (!tt.isEnd())
{
if (!tt.isStart())
{
// Not an element
result.addToList(findAnnotation(curs));
// Reset target property to null in this case
targetProperty = null;
}
else
{
// Match namespace as well if specified
if (namespace == null ||
namespace.length() == 0 ||
namespace.equals("*") ||
curs.getName().getNamespaceURI().equals(namespace))
{
// Add it to the list
result.addToList(findAnnotation(curs));
// Set target property if target name is "*",
// Otherwise if target property does not match current, then
// set to null
if (targetProperty != null)
{
if (targetProperty.getLocalPart().equals("*"))
{
targetProperty = curs.getName();
}
else if (!targetProperty.getLocalPart().equals(curs.getName().getLocalPart()))
{
// Not a match, unset target property
targetProperty = null;
}
}
}
}
// Skip over child elements
if (tt.isStart())
{
tt = curs.toEndToken();
}
tt = curs.toNextToken();
}
}
curs.dispose();
// Set the targets for this XMLList.
result.setTargets(this, targetProperty);
return result;
}
示例11: getNamespace
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
static Namespace getNamespace(XMLLibImpl lib, XmlCursor cursor,
Object[] inScopeNamespaces)
{
String uri;
String prefix;
if (cursor.isProcinst()) {
uri = "";
prefix = "";
} else {
javax.xml.namespace.QName qname = cursor.getName();
uri = qname.getNamespaceURI();
prefix = qname.getPrefix();
}
if (inScopeNamespaces == null)
return new Namespace(lib, prefix, uri);
Namespace result = null;
for (int i = 0; i != inScopeNamespaces.length; ++i) {
Namespace ns = (Namespace)inScopeNamespaces[i];
if(ns == null) continue;
String nsURI = ns.uri();
if(nsURI.equals(uri))
{
if(prefix.equals(ns.prefix()))
{
result = ns;
break;
}
if(result == null ||
(result.prefix() == null &&
ns.prefix() != null))
result = ns;
}
}
if(result == null)
result = new Namespace(lib, prefix, uri);
return result;
}