@Override public void onStart(XMLStreamReader xml, XmlContext xmlContext) throws XMLStreamException { String type = xml.getLocalName(); if (pairs.isEmpty()) { if (format == null) { format = type; } else { format = format + "|" + type; } } name = xml.getAttributeValue(null, "name"); value = xml.getAttributeValue(null, "value"); pairs.add(new AttrData.Pair(name, value)); }
private static void readTags(ReaderElement re, XMLStreamReader parser) throws XMLStreamException { int event = parser.getEventType(); while (event != XMLStreamConstants.END_DOCUMENT && parser.getLocalName().equals("tag")) { if (event == XMLStreamConstants.START_ELEMENT) { // read tag String key = parser.getAttributeValue(null, "k"); String value = parser.getAttributeValue(null, "v"); // ignore tags with empty values if (value != null && value.length() > 0) re.setTag(key, value); } event = parser.nextTag(); } }
public AttrBuffer( XMLStreamReader rd, int attrIndex ) { prefix = rd.getAttributePrefix( attrIndex ); namespace = rd.getAttributeNamespace( attrIndex ); localName = rd.getAttributeLocalName( attrIndex ); value = rd.getAttributeValue( attrIndex ); }
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; }
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));
public static Map<QName,String> getAttributes(XMLStreamReader reader) { Map<QName,String> map = new HashMap<QName,String>(); for (int i = 0; i < reader.getAttributeCount(); i++) map.put(reader.getAttributeName(i), reader.getAttributeValue(i)); return map; }
private void openXMLStream(InputStream in) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); parser = factory.createXMLStreamReader(in, "UTF-8"); int event = parser.next(); if (event != XMLStreamConstants.START_ELEMENT || !parser.getLocalName().equalsIgnoreCase("osm")) { throw new IllegalArgumentException("File is not a valid OSM stream"); } // See https://wiki.openstreetmap.org/wiki/PBF_Format#Definition_of_the_OSMHeader_fileblock String timestamp = parser.getAttributeValue(null, "osmosis_replication_timestamp"); if (timestamp == null) timestamp = parser.getAttributeValue(null, "timestamp"); if (timestamp != null) { try { fileheader = new OSMFileHeader(); fileheader.setTag("timestamp", timestamp); } catch (Exception ex) { } } eof = false; }
int attrCount = r.getAttributeCount(); if (attrCount < 1) { attrs = null; attrs = new LinkedHashMap(); for (int i = 0; i < attrCount; ++i) { QName aname = r.getAttributeName(i); attrs.put(aname, new AttributeEventImpl(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i))); if (ed == null) { // undefined? return new WEntityReference(loc, r.getLocalName()); return new WEntityReference(loc, r.getLocalName());
Integer next = xml.hasNext() ? xml.next() : null; while (next != null) { context.reset(); if (root) { String ver = xml.getAttributeValue(null, "version"); if (ver != null) { context.version(ver); next = xml.hasNext() ? xml.next() : null;
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 ""; }
protected static void processResource(final XMLStreamReader reader, final Set<String> resources) throws XMLStreamException { final int attributeCount = reader.getAttributeCount(); if (attributeCount != 1) { throw new XMLStreamException(); } final String path = reader.getAttributeValue(0); resources.add(path.trim()); if (reader.hasNext() && reader.nextTag() != END_ELEMENT) { throw new XMLStreamException("unexpected element"); } }
@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)); }
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String id = xtr.getAttributeValue(null, ATTRIBUTE_DI_BPMNELEMENT); GraphicInfo graphicInfo = new GraphicInfo(); String strIsExpanded = xtr.getAttributeValue(null, ATTRIBUTE_DI_IS_EXPANDED); if ("true".equalsIgnoreCase(strIsExpanded)) { graphicInfo.setExpanded(true); } BpmnXMLUtil.addXMLLocation(graphicInfo, xtr); while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) { graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X))); graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y))); graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH))); graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT))); model.addGraphicInfo(id, graphicInfo); break; } else if (xtr.isEndElement() && ELEMENT_DI_SHAPE.equalsIgnoreCase(xtr.getLocalName())) { break; } } }
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); } } }
private Map<String, String> parseAttributes() { int num = parser.getAttributeCount(); Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i < num; i++) { map.put(parser.getAttributeName(i).getLocalPart(), parser.getAttributeValue(i)); } return map; }
private ReaderElement getNextXML() throws XMLStreamException { int event = parser.next(); if (fileheader != null) { ReaderElement copyfileheader = fileheader; String idStr = parser.getAttributeValue(null, "id"); if (idStr != null) { String name = parser.getLocalName(); long id = 0; switch (name.charAt(0)) { event = parser.next();
private static void StAXStartElement(XMLStreamReader r, Stack<TokenNode> stack, String filePath) { String name = r.getLocalName(); TokenNode n = new TokenNode(name); n.setFilePath(filePath); stack.push(n); int len = r.getAttributeCount(); for (int i = 0; i < len; i++) { String k = r.getAttributeName(i).getLocalPart(); String v = r.getAttributeValue(i); n.putAttr(k, v); } }
NodeHandler findMatchFor(XMLStreamReader xml) { String tagName = xml.getLocalName(); ElementHandler elementHandler = subElementHandlers.get(tagName); if (elementHandler == null) { elementHandler = subElementHandlers.get("*"); } if (elementHandler != null) { for (Map.Entry<String, AttrHandler> entry : elementHandler.entrySet()) { String attrName = entry.getKey(); String attributeValue = xml.getAttributeValue(null, attrName); if (attributeValue != null) { AttrHandler attrHandler = entry.getValue(); NodeHandler nodeHandler = attrHandler.get(attributeValue); if (nodeHandler != null) { return nodeHandler; } } } return elementHandler.nodeHandler; } return null; }
private static void readNodes(ReaderWay way, XMLStreamReader parser) throws XMLStreamException { int event = parser.getEventType(); while (event != XMLStreamConstants.END_DOCUMENT && parser.getLocalName().equals("nd")) { if (event == XMLStreamConstants.START_ELEMENT) { // read node reference String ref = parser.getAttributeValue(null, "ref"); way.getNodes().add(Long.parseLong(ref)); } event = parser.nextTag(); } }
/*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(); }