本文整理了Java中javax.xml.stream.events.Attribute.getName()
方法的一些代码示例,展示了Attribute.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.getName()
方法的具体详情如下:
包路径:javax.xml.stream.events.Attribute
类名称:Attribute
方法名:getName
[英]Returns the QName for this attribute
[中]返回此属性的QName
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Returns the qualified name of the attribute
*
* @param a
* an attribute event
* @param enabledNamespaces
* indicates if namespaces should be added or not
* @return the qualified name of the attribute
*/
private String getAttributeName( Attribute a, boolean enabledNamespaces ) {
if ( !enabledNamespaces ) {
return a.getName().getLocalPart();
} else {
return getName( a.getName().getPrefix(), a.getName().getLocalPart() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private List
// adjust the version attribute
List
Iterator> existingAttributesIterator = startElement.getAttributes();
while ( existingAttributesIterator.hasNext() ) {
Attribute attribute = (Attribute) existingAttributesIterator.next();
if ( VERSION_ATTRIBUTE_NAME.equals( attribute.getName().getLocalPart() ) ) {
if ( !DEFAULT_VERSION.equals( attribute.getName().getPrefix() ) ) {
newElementAttributeList.add(
xmlEventFactory.createAttribute(
attribute.getName(),
DEFAULT_VERSION
)
);
}
}
else {
newElementAttributeList.add( attribute );
}
}
return newElementAttributeList;
}
}
代码示例来源:origin: hibernate/hibernate-orm
private Attribute mapAttribute(StartElement startElement, Attribute originalAttribute) {
// Here we look to see if this attribute is the JPA version attribute, and if so do 2 things:
// 1) validate its version attribute is valid
// 2) update its version attribute to the default version if not already
//
// NOTE : atm this is a very simple check using just the attribute's local name
// rather than checking its qualified name. It is possibly (though unlikely)
// that this could match on "other" version attributes in the same element
if ( ROOT_ELEMENT_NAME.equals( startElement.getName().getLocalPart() ) ) {
if ( VERSION_ATTRIBUTE_NAME.equals( originalAttribute.getName().getLocalPart() ) ) {
final String specifiedVersion = originalAttribute.getValue();
if ( !LocalXsdResolver.isValidJpaVersion( specifiedVersion ) ) {
throw new BadVersionException( specifiedVersion );
}
return xmlEventFactory.createAttribute( VERSION_ATTRIBUTE_NAME, LocalXsdResolver.latestJpaVerison() );
}
}
return originalAttribute;
}
代码示例来源:origin: org.codehaus.woodstox/woodstox-core-asl
if (attrs == null || !attrs.hasNext()) {
attrMap = null;
} else {
attrMap = new LinkedHashMap();
do {
Attribute attr = (Attribute) attrs.next();
attrMap.put(attr.getName(), attr);
} while (attrs.hasNext());
if (ns != null && ns.hasNext()) {
ArrayList l = new ArrayList();
do {
l.add((Namespace) ns.next()); // cast to catch type problems early
} while (ns.hasNext());
myCtxt = MergedNsContext.construct(nsCtxt, l);
代码示例来源:origin: org.leapframework/leap-lang
@Override
public String next() {
Attribute a = it.next();
return a.getName().getLocalPart();
}
};
代码示例来源:origin: com.googlecode.totallylazy/totallylazy
private Element copyAttributes(StartElement source, Element destination) {
for (Attribute attribute : forwardOnly(Unchecked.
destination.setAttribute(attribute.getName().getLocalPart(), attribute.getValue());
}
return destination;
}
代码示例来源:origin: spring-projects/spring-framework
private Attributes getAttributes(StartElement event) {
AttributesImpl attributes = new AttributesImpl();
for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute attribute = (Attribute) i.next();
QName qName = attribute.getName();
String namespace = qName.getNamespaceURI();
if (namespace == null || !hasNamespacesFeature()) {
type = "CDATA";
attributes.addAttribute(namespace, qName.getLocalPart(), toQualifiedName(qName), type, attribute.getValue());
for (Iterator i = event.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
String prefix = namespace.getPrefix();
String namespaceUri = namespace.getNamespaceURI();
代码示例来源:origin: com.sun.xml.stream/sjsxp
void addAttributes(Iterator attrs){
if(attrs == null)
return;
while(attrs.hasNext()){
Attribute attr = (Attribute)attrs.next();
fAttributes.put(attr.getName(),attr);
}
}
代码示例来源:origin: stax/stax
private void writeAttribute(Attribute a)
throws XMLStreamException
{
writer.writeAttribute(a.getName().getNamespaceURI(),
a.getName().getLocalPart(),
a.getValue());
}
public void addAttribute(Attribute a)
代码示例来源:origin: aws/aws-sdk-java
private void updateContext(XMLEvent event) {
if (event == null) return;
if (event.isEndElement()) {
stack.pop();
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
} else if (event.isStartElement()) {
stack.push(event.asStartElement().getName().getLocalPart());
stackString += "/" + event.asStartElement().getName().getLocalPart();
} else if (event.isAttribute()) {
Attribute attribute = (Attribute)event;
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
stackString += "/@" + attribute.getName().getLocalPart();
}
}
代码示例来源:origin: spring-projects/spring-framework
private void handleStartElement(StartElement startElement) throws SAXException {
if (getContentHandler() != null) {
QName qName = startElement.getName();
if (hasNamespacesFeature()) {
for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
}
for (Iterator i = startElement.getAttributes(); i.hasNext();){
Attribute attribute = (Attribute) i.next();
QName attributeName = attribute.getName();
startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
}
getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
getAttributes(startElement));
}
else {
getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
}
}
}
代码示例来源:origin: stax/stax
private static void printAttribute(Attribute a) {
printName(a.getName().getPrefix(),a.getName().getNamespaceURI(),
a.getName().getLocalPart());
System.out.print("='"+a.getValue()+"'");
}
代码示例来源:origin: camunda/camunda-bpm-platform
Attribute getAttributeByName(String name) {
if(attributes == null)
return null;
for(Attribute attr: attributes) {
if(name.equals(attr.getName().getLocalPart()))
return attr;
}
return null;
}
代码示例来源:origin: com.sun.xml.bind/jaxb-impl
for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute staxAttr = (Attribute)i.next();
QName name = staxAttr.getName();
String uri = fixNull(name.getNamespaceURI());
String localName = name.getLocalPart();
String prefix = name.getPrefix();
String qName;
qName = prefix + ':' + localName;
String type = staxAttr.getDTDType();
String value = staxAttr.getValue();
代码示例来源:origin: stax/stax
private static void printAttribute(Attribute a) {
System.out.println("PREFIX: " + a.getName().getPrefix());
System.out.println("NAMESP: " + a.getName().getNamespaceURI());
System.out.println("NAME: " + a.getName().getLocalPart());
System.out.println("VALUE: " + a.getValue());
System.out.println("TYPE: " + a.getDTDType());
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
private void updateContext(XMLEvent event) {
if (event == null) return;
if (event.isEndElement()) {
stack.pop();
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
} else if (event.isStartElement()) {
stack.push(event.asStartElement().getName().getLocalPart());
stackString += "/" + event.asStartElement().getName().getLocalPart();
} else if (event.isAttribute()) {
Attribute attribute = (Attribute)event;
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
stackString += "/@" + attribute.getName().getLocalPart();
}
}
代码示例来源:origin: org.springframework/spring-core
private Attributes getAttributes(StartElement event) {
AttributesImpl attributes = new AttributesImpl();
for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute attribute = (Attribute) i.next();
QName qName = attribute.getName();
String namespace = qName.getNamespaceURI();
if (namespace == null || !hasNamespacesFeature()) {
type = "CDATA";
attributes.addAttribute(namespace, qName.getLocalPart(), toQualifiedName(qName), type, attribute.getValue());
for (Iterator i = event.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
String prefix = namespace.getPrefix();
String namespaceUri = namespace.getNamespaceURI();
代码示例来源:origin: org.metatype.sxc/sxc-jaxb
public String getAttributeValue(String namespaceURI, String localName) {
for (Attribute attribute : getAttributes()) {
if (attribute.getName().getNamespaceURI().equals(namespaceURI) && attribute.getName().getLocalPart().equals(localName)) {
return attribute.getValue();
}
}
return null;
}
代码示例来源:origin: apache/cxf
public String getAttributeLocalName(int arg0) {
String ret = null;
List
if (currentAttributes != null) {
Attribute a = currentAttributes.get(arg0);
if (a != null) {
ret = a.getName().getLocalPart();
}
}
return ret;
}
代码示例来源:origin: org.springframework/spring-core
private void handleStartElement(StartElement startElement) throws SAXException {
if (getContentHandler() != null) {
QName qName = startElement.getName();
if (hasNamespacesFeature()) {
for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
}
for (Iterator i = startElement.getAttributes(); i.hasNext();){
Attribute attribute = (Attribute) i.next();
QName attributeName = attribute.getName();
startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
}
getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
getAttributes(startElement));
}
else {
getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
}
}
}