本文整理汇总了Java中org.apache.xerces.xni.XMLAttributes.getQName方法的典型用法代码示例。如果您正苦于以下问题:Java XMLAttributes.getQName方法的具体用法?Java XMLAttributes.getQName怎么用?Java XMLAttributes.getQName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xni.XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes.getQName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAttributes
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
private void parseAttributes(XMLAttributes attrs, Stack<String> langStack, Stack<String> xmlBaseStack) {
if (attrs.getLength() > 0) attributeList = new ReaderAttributeList();
String u, n, v;
for (int i = 0; i < attrs.getLength(); i++) {
u = attrs.getURI(i);
n = attrs.getQName(i);
v = attrs.getValue(i);
if (isNamespace(n)) {
if (namespaces == null) namespaces = new HashMap<String, String>();
namespaces.put(n, v);
} else {
if (lang == null) lang = resolveLang(n, v, langStack);
if (xmlBase == null) xmlBase = resolveXmlBase(n, v, xmlBaseStack);
}
attributeList.add(u, n, v);
attributeStrings.add(n + "=\"" + v + "\"");
}
}
示例2: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* The start of an element. If the document specifies the start element
* by using an empty tag, then the startElement method will immediately
* be followed by the endElement method, with no intervening methods.
* Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false.
*
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startElement (QName element, XMLAttributes attributes, Augmentations augs) {
// namespace declarations parameter has no effect if namespaces is false.
if (!fNamespaceDeclarations && fNamespaceAware) {
int len = attributes.getLength();
for (int i = len - 1; i >= 0; --i) {
if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) ||
XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) {
attributes.removeAttributeAt(i);
}
}
}
super.startElement(element, attributes, augs);
}
示例3: hasNonSchemaAttributes
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* @param attributes
* @return
*/
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
final int length = attributes.getLength();
for (int i = 0; i < length; ++i) {
String uri = attributes.getURI(i);
if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
uri != NamespaceContext.XMLNS_URI &&
!(uri == NamespaceContext.XML_URI &&
attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
return true;
}
}
return false;
}
示例4: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Start element. */
public void startElement(QName element, XMLAttributes attrs,
Augmentations augs) throws XNIException {
Element elementNode = fDocument.createElement(element.rawname);
int count = attrs != null ? attrs.getLength() : 0;
for (int i = 0; i < count; i++) {
String aname = attrs.getQName(i);
String avalue = attrs.getValue(i);
if (XMLChar.isValidName(aname)) {
elementNode.setAttribute(aname, avalue);
}
}
fCurrentNode.appendChild(elementNode);
fCurrentNode = elementNode;
}
示例5: startAnnotation
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
void startAnnotation(String elemRawName, XMLAttributes attributes,
NamespaceContext namespaceContext) {
if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256);
fAnnotationBuffer.append("<").append(elemRawName).append(" ");
// attributes are a bit of a pain. To get this right, we have to keep track
// of the namespaces we've seen declared, then examine the namespace context
// for other namespaces so that we can also include them.
// optimized for simplicity and the case that not many
// namespaces are declared on this annotation...
ArrayList namespaces = new ArrayList();
for (int i = 0; i < attributes.getLength(); ++i) {
String aValue = attributes.getValue(i);
String aPrefix = attributes.getPrefix(i);
String aQName = attributes.getQName(i);
// if it's xmlns:* or xmlns, must be a namespace decl
if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) {
namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ?
attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING);
}
fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" ");
}
// now we have to look through currently in-scope namespaces to see what
// wasn't declared here
Enumeration currPrefixes = namespaceContext.getAllPrefixes();
while(currPrefixes.hasMoreElements()) {
String prefix = (String)currPrefixes.nextElement();
String uri = namespaceContext.getURI(prefix);
if (uri == null) {
uri = XMLSymbols.EMPTY_STRING;
}
if (!namespaces.contains(prefix)) {
// have to declare this one
if(prefix == XMLSymbols.EMPTY_STRING) {
fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" ");
}
else {
fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" ");
}
}
}
fAnnotationBuffer.append(">\n");
}