本文整理了Java中javax.xml.stream.XMLStreamReader.getAttributeLocalName()
方法的一些代码示例,展示了XMLStreamReader.getAttributeLocalName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLStreamReader.getAttributeLocalName()
方法的具体详情如下:
包路径:javax.xml.stream.XMLStreamReader
类名称:XMLStreamReader
方法名:getAttributeLocalName
[英]Returns the localName of the attribute at the provided index
[中]返回所提供索引处属性的localName
代码示例来源:origin: pentaho/pentaho-kettle
public AttrBuffer( XMLStreamReader rd, int attrIndex ) {
prefix = rd.getAttributePrefix( attrIndex );
namespace = rd.getAttributeNamespace( attrIndex );
localName = rd.getAttributeLocalName( attrIndex );
value = rd.getAttributeValue( attrIndex );
}
代码示例来源:origin: spring-projects/spring-framework
private Attributes getAttributes() {
AttributesImpl attributes = new AttributesImpl();
for (int i = 0; i < this.reader.getAttributeCount(); i++) {
String namespace = this.reader.getAttributeNamespace(i);
if (namespace == null || !hasNamespacesFeature()) {
namespace = "";
}
String type = this.reader.getAttributeType(i);
if (type == null) {
type = "CDATA";
}
attributes.addAttribute(namespace, this.reader.getAttributeLocalName(i),
toQualifiedName(this.reader.getAttributeName(i)), type, this.reader.getAttributeValue(i));
}
if (hasNamespacePrefixesFeature()) {
for (int i = 0; i < this.reader.getNamespaceCount(); i++) {
String prefix = this.reader.getNamespacePrefix(i);
String namespaceUri = this.reader.getNamespaceURI(i);
String qName;
if (StringUtils.hasLength(prefix)) {
qName = "xmlns:" + prefix;
}
else {
qName = "xmlns";
}
attributes.addAttribute("", "", qName, "CDATA", namespaceUri);
}
}
return attributes;
}
代码示例来源:origin: apache/tika
private String findFirstAttributeValue(XMLStreamReader reader, String name) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
String n = reader.getAttributeLocalName(i);
if (name.equals(n)) {
return reader.getAttributeValue(i);
}
}
return "";
}
代码示例来源:origin: org.jboss.galleon/galleon-core
public static void readPackages(XMLStreamReader reader, FeaturePackConfig.Builder builder)
throws XMLStreamException, ProvisioningDescriptionException {
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
if(reader.getAttributeLocalName(i).equals(INHERIT)) {
builder.setInheritPackages(Boolean.parseBoolean(reader.getAttributeValue(i)));
} else {
throw ParsingUtils.unexpectedContent(reader);
while (reader.hasNext()) {
switch (reader.nextTag()) {
case XMLStreamConstants.END_ELEMENT: {
final String localName = reader.getLocalName();
if (EXCLUDE.equals(localName)) {
builder.excludePackage(parseName(reader));
代码示例来源:origin: ha-jdbc/ha-jdbc
@Override
public String invalidAttribute(XMLStreamReader reader, int index)
{
Location location = reader.getLocation();
return this.tr("Invalid value for <{2} {3}=\"{4}\"/> found at [{0}:{1}]", location.getLineNumber(), location.getColumnNumber(), reader.getLocalName(), reader.getAttributeLocalName(index), reader.getAttributeValue(index));
}
代码示例来源:origin: ha-jdbc/ha-jdbc
@Override
public String unexpectedAttribute(XMLStreamReader reader, int index)
{
Location location = reader.getLocation();
return this.tr("Unexpected <{2} {3}=\"...\"/> attribute found at [{0}:{1}]", location.getLineNumber(), location.getColumnNumber(), reader.getLocalName(), reader.getAttributeLocalName(index));
}
代码示例来源:origin: wildfly/wildfly
private void parseCredential(final XMLStreamReader streamReader, CredentialParseFunction function) throws RealmUnavailableException, XMLStreamException {
final int attributeCount = streamReader.getAttributeCount();
String name = null;
String algorithm = null;
String format = null;
for (int i = 0; i < attributeCount; i ++) {
String namespace = streamReader.getAttributeNamespace(i);
if (namespace != null && !namespace.equals("")) {
throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name);
}
final String localName = streamReader.getAttributeLocalName(i);
if ("name".equals(localName)) {
name = streamReader.getAttributeValue(i);
} else if ("algorithm".equals(localName)) {
algorithm = streamReader.getAttributeValue(i);
} else if ("format".equals(localName)) {
format = streamReader.getAttributeValue(i);
} else {
throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), name);
}
}
final String text = streamReader.getElementText().trim();
function.parseCredential(algorithm, format, text);
}
代码示例来源:origin: org.infinispan/infinispan-clustered-lock
private void parseClusteredLocksElement(XMLStreamReader reader, ClusteredLockManagerConfigurationBuilder builder)
throws XMLStreamException {
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case NUM_OWNERS:
builder.numOwner(Integer.parseInt(value));
break;
case RELIABILITY:
builder.reliability(Reliability.valueOf(value));
break;
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
Element element = Element.forName(reader.getLocalName());
switch (element) {
case CLUSTERED_LOCK:
parseClusteredLock(reader, builder.addClusteredLock());
break;
default:
throw ParseUtils.unexpectedElement(reader);
}
}
}
代码示例来源:origin: javaee/glassfish
/*package*/ void fillAttributes(XMLStreamReader in) {
for( int i=in.getAttributeCount()-1; i>=0; i-- ) {
String n = in.getAttributeLocalName(i);
if(model.attributes.containsKey(n)) {
if(attributes==null)
attributes = new HashMap<String, String>();
attributes.put(n,in.getAttributeValue(i));
}
}
if(attributes==null)
attributes = Collections.emptyMap();
}
代码示例来源:origin: kite-sdk/kite
private void copyAttribute(int i) throws XMLStreamException {
writer.writeAttribute(
reader.getAttributePrefix(i),
reader.getAttributeNamespace(i),
reader.getAttributeLocalName(i),
reader.getAttributeValue(i));
}
代码示例来源:origin: wildfly/wildfly
private void parseAttribute(final XMLStreamReader streamReader, final Attributes attributes) throws XMLStreamException, RealmUnavailableException {
String name = null;
String value = null;
final int attributeCount = streamReader.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String namespace = streamReader.getAttributeNamespace(i);
if (namespace != null && !namespace.equals("")) {
throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), this.name);
}
if ("name".equals(streamReader.getAttributeLocalName(i))) {
name = streamReader.getAttributeValue(i);
} else if ("value".equals(streamReader.getAttributeLocalName(i))) {
value = streamReader.getAttributeValue(i);
} else {
throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), this.name);
}
}
if (name == null) {
throw ElytronMessages.log.fileSystemRealmMissingAttribute("name", path, streamReader.getLocation().getLineNumber(), this.name);
}
if (value == null) {
throw ElytronMessages.log.fileSystemRealmMissingAttribute("value", path, streamReader.getLocation().getLineNumber(), this.name);
}
attributes.addLast(name, value);
if (streamReader.nextTag() != END_ELEMENT) {
throw ElytronMessages.log.fileSystemRealmInvalidContent(path, streamReader.getLocation().getLineNumber(), this.name);
}
}
代码示例来源:origin: org.jboss.metadata/jboss-metadata-web
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case WELCOME_FILE:
代码示例来源:origin: org.apache.tika/tika-parsers
private String findFirstAttributeValue(XMLStreamReader reader, String name) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
String n = reader.getAttributeLocalName(i);
if (name.equals(n)) {
return reader.getAttributeValue(i);
}
}
return "";
}
代码示例来源:origin: org.springframework/spring-core
private Attributes getAttributes() {
AttributesImpl attributes = new AttributesImpl();
for (int i = 0; i < this.reader.getAttributeCount(); i++) {
String namespace = this.reader.getAttributeNamespace(i);
if (namespace == null || !hasNamespacesFeature()) {
namespace = "";
}
String type = this.reader.getAttributeType(i);
if (type == null) {
type = "CDATA";
}
attributes.addAttribute(namespace, this.reader.getAttributeLocalName(i),
toQualifiedName(this.reader.getAttributeName(i)), type, this.reader.getAttributeValue(i));
}
if (hasNamespacePrefixesFeature()) {
for (int i = 0; i < this.reader.getNamespaceCount(); i++) {
String prefix = this.reader.getNamespacePrefix(i);
String namespaceUri = this.reader.getNamespaceURI(i);
String qName;
if (StringUtils.hasLength(prefix)) {
qName = "xmlns:" + prefix;
}
else {
qName = "xmlns";
}
attributes.addAttribute("", "", qName, "CDATA", namespaceUri);
}
}
return attributes;
}
代码示例来源:origin: org.jboss.metadata/jboss-metadata-web
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case LOCALE_ENCODING_MAPPING:
代码示例来源:origin: apache/activemq-artemis
private void processMessageQueues(ArrayList<String> queues) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
if (XmlDataConstants.QUEUE_NAME.equals(reader.getAttributeLocalName(i))) {
String queueName = reader.getAttributeValue(i);
String translation = checkPrefix(queueName);
queues.add(translation);
}
}
}
代码示例来源:origin: plutext/docx4j
XMLStreamWriter writer = factory.createXMLStreamWriter(stringWriter);
while ( reader.hasNext() ) {
int event = reader.next();
if (reader.getLocalName().equals("ins"))
else if (reader.getLocalName().equals("del"))
if (memory.equals(reader.getLocalName()))
writer.writeStartElement(reader.getPrefix(), reader.getLocalName(), reader.getNamespaceURI());
for (int i=0; i<reader.getAttributeCount() ; i++ ) {
if (reader.getAttributeNamespace(i)==null) {
reader.getAttributeLocalName(i),
reader.getAttributeValue(i) );
} else {
writer.writeAttribute(
reader.getAttributePrefix(i),
reader.getAttributeNamespace(i),
reader.getAttributeLocalName(i),
reader.getAttributeValue(i));
代码示例来源:origin: org.jboss.metadata/jboss-metadata-web
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (attributeHasNamespace(reader, i)) {
continue;
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case TYPE:
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
public static String getContentID(XMLStreamReader parser) {
if (parser.getAttributeCount() > 0 &&
parser.getAttributeLocalName(0).equals("href")) {
return getContentIDFromHref(parser.getAttributeValue(0));
} else {
throw new OMException(
"Href attribute not found in XOP:Include element");
}
}
代码示例来源:origin: Activiti/Activiti
public static ExtensionElement parseExtensionElement(XMLStreamReader xtr) throws Exception {
ExtensionElement extensionElement = new ExtensionElement();
extensionElement.setName(xtr.getLocalName());
if (StringUtils.isNotEmpty(xtr.getNamespaceURI())) {
extensionElement.setNamespace(xtr.getNamespaceURI());
for (int i = 0; i < xtr.getAttributeCount(); i++) {
ExtensionAttribute extensionAttribute = new ExtensionAttribute();
extensionAttribute.setName(xtr.getAttributeLocalName(i));
extensionAttribute.setValue(xtr.getAttributeValue(i));
if (StringUtils.isNotEmpty(xtr.getAttributeNamespace(i))) {
extensionAttribute.setNamespace(xtr.getAttributeNamespace(i));
while (!readyWithExtensionElement && xtr.hasNext()) {
xtr.next();
if (xtr.isCharacters() || XMLStreamReader.CDATA == xtr.getEventType()) {
if (StringUtils.isNotEmpty(xtr.getText().trim())) {
ExtensionElement childExtensionElement = parseExtensionElement(xtr);
extensionElement.addChildElement(childExtensionElement);
} else if (xtr.isEndElement() && extensionElement.getName().equalsIgnoreCase(xtr.getLocalName())) {
readyWithExtensionElement = true;
内容来源于网络,如有侵权,请联系作者删除!