@Override public void startElement(String uri, String localName, String qName, Attributes attributes) { Node parent = getParent(); Element element = this.document.createElementNS(uri, qName); for (int i = 0; i < attributes.getLength(); i++) { String attrUri = attributes.getURI(i); String attrQname = attributes.getQName(i); String value = attributes.getValue(i); if (!attrQname.startsWith("xmlns")) { element.setAttributeNS(attrUri, attrQname, value); } } element = (Element) parent.appendChild(element); this.elements.add(element); }
private final void writeAttributes(final Attributes atts) throws IOException { StringBuilder sb = new StringBuilder(); int len = atts.getLength(); for (int i = 0; i < len; i++) { sb.append(' ') .append(atts.getLocalName(i)) .append("=\"") .append(esc(atts.getValue(i))) .append('\"'); } w.write(sb.toString()); }
public void startElement(String uri, String localName, String qName, Attributes attributes){ int[] magic = new int[2]; String serial; String mac; if(attributes.getLength() == 0) return; ArrayList<AliceMagicInfo> supported = supportedAlices.get(qName); if(supported == null){ supported = new ArrayList<AliceMagicInfo>(5); supportedAlices.put(qName, supported); } serial = attributes.getValue("sn"); mac = attributes.getValue("mac"); magic[0] = Integer.parseInt(attributes.getValue("q")); magic[1] = Integer.parseInt(attributes.getValue("k")); supported.add(new AliceMagicInfo(qName, magic, serial, mac)); }
private List<Attribute> getAttributes(Attributes attributes) { int attrLength = attributes.getLength(); List<Attribute> result = new ArrayList<>(attrLength); for (int i = 0; i < attrLength; i++) { QName attrName = toQName(attributes.getURI(i), attributes.getQName(i)); if (!isNamespaceDeclaration(attrName)) { result.add(this.eventFactory.createAttribute(attrName, attributes.getValue(i))); } } return result; }
@Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { if (localName.equalsIgnoreCase(SHEET)) { String name = null; String id = null; for (int i = 0; i < attrs.getLength(); i++) { final String attrName = attrs.getLocalName(i); if (attrName.equalsIgnoreCase(NAME)) { name = attrs.getValue(i); } else if (attrName.equalsIgnoreCase(ID)) { id = attrs.getValue(i); } if (name != null && id != null) { sheetRefs.add(new XSSFSheetRef(id, name)); break; } } } }
/** * When a <code>primary-key</code> element is encounter, we pop the IndexCreationData object from * the Stack. Set the required parameters in the IndexCreationData object & set it in * RegionCreation object. * */ private void startPrimaryKeyIndex(Attributes atts) { IndexCreationData icd = (IndexCreationData) this.stack.peek(); // icd.setIndexType(PRIMARY_KEY); boolean throwExcep = false; if (atts.getLength() == 1) { String field = atts.getValue(FIELD); if (field == null) { throwExcep = true; } else { icd.setIndexData(IndexType.PRIMARY_KEY, null, field, null); } } else { throwExcep = true; } if (throwExcep) { throw new InternalGemFireException( "CacheXmlParser::startPrimaryKeyIndex:Primary-Key Index creation field is null."); } }
@Override protected void startElementInternal(QName name, Attributes attributes, Map<String, String> namespaceMapping) throws XMLStreamException { this.streamWriter.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI()); for (Map.Entry<String, String> entry : namespaceMapping.entrySet()) { String prefix = entry.getKey(); String namespaceUri = entry.getValue(); this.streamWriter.writeNamespace(prefix, namespaceUri); if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) { this.streamWriter.setDefaultNamespace(namespaceUri); } else { this.streamWriter.setPrefix(prefix, namespaceUri); } } for (int i = 0; i < attributes.getLength(); i++) { QName attrName = toQName(attributes.getURI(i), attributes.getQName(i)); if (!isNamespaceDeclaration(attrName)) { this.streamWriter.writeAttribute(attrName.getPrefix(), attrName.getNamespaceURI(), attrName.getLocalPart(), attributes.getValue(i)); } } }
for (int i = 0, n = atts.getLength(); i < n; i++) { if (atts.getLocalName(i).equals("service")) { this.service = atts.getValue(i);
/** * Processes field members that have been collected during the characters * and startElement method to construct a PropertyType object. * * @return a PropertyType object */ private PropertyType processPropertyType() { final PropertyType pt = new PropertyType(); pt.setValue(currentText.toString()); if (currentAttributes != null && currentAttributes.getLength() > 0) { final String regex = currentAttributes.getValue("regex"); if (regex != null) { pt.setRegex(Boolean.parseBoolean(regex)); } final String caseSensitive = currentAttributes.getValue("caseSensitive"); if (caseSensitive != null) { pt.setCaseSensitive(Boolean.parseBoolean(caseSensitive)); } } return pt; } }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) { Node parent = getParent(); Element element = this.document.createElementNS(uri, qName); for (int i = 0; i < attributes.getLength(); i++) { String attrUri = attributes.getURI(i); String attrQname = attributes.getQName(i); String value = attributes.getValue(i); if (!attrQname.startsWith("xmlns")) { element.setAttributeNS(attrUri, attrQname, value); } } element = (Element) parent.appendChild(element); this.elements.add(element); }
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (namespaceURI != null) { print.addElementNS(namespaceURI); } if ("".equals(localName)) localName = null; //#16484 //NOI18N print.addElementName(localName != null ? localName : qName); for (int i = 0; i<atts.getLength(); i++) { print.addElementAtt(atts.getQName(i), atts.getValue(i)); } throw STOP; }
private void addToOutgoingUrls(String href, String tag, Attributes attributes) { curUrl = new ExtractedUrlAnchorPair(); curUrl.setHref(href); curUrl.setTag(tag); for (int x = 0; x < attributes.getLength(); x++) { String attrName = attributes.getLocalName(x); String attrVal = attributes.getValue(attrName); curUrl.setAttribute(attrName, attrVal); } outgoingUrls.add(curUrl); }
protected Loader selectLoader(UnmarshallingContext.State state, TagName ea) throws SAXException { int idx = ea.atts.getIndex(WellKnownNamespace.XML_SCHEMA_INSTANCE,"nil"); if (idx!=-1) { Boolean b = DatatypeConverterImpl._parseBoolean(ea.atts.getValue(idx)); if (b != null && b) { onNil(state); boolean hasOtherAttributes = (ea.atts.getLength() - 1) > 0; // see issues 6759703 and 565 - need to preserve attributes even if the element is nil; only when the type is stored in JAXBElement if (!(hasOtherAttributes && (state.getPrev().getTarget() instanceof JAXBElement))) { return Discarder.INSTANCE; } } } return defaultLoader; }
private List<Attribute> getAttributes(Attributes attributes) { int attrLength = attributes.getLength(); List<Attribute> result = new ArrayList<>(attrLength); for (int i = 0; i < attrLength; i++) { QName attrName = toQName(attributes.getURI(i), attributes.getQName(i)); if (!isNamespaceDeclaration(attrName)) { result.add(this.eventFactory.createAttribute(attrName, attributes.getValue(i))); } } return result; }
/** Render a {@link org.xml.sax.Attributes}. */ public String doRender(Object o) { if(o instanceof Attributes) { StringBuffer sbuf = new StringBuffer(); Attributes a = (Attributes) o; int len = a.getLength(); boolean first = true; for(int i = 0; i < len; i++) { if(first) { first = false; } else { sbuf.append(", "); } sbuf.append(a.getQName(i)); sbuf.append('='); sbuf.append(a.getValue(i)); } return sbuf.toString(); } else { try { return o.toString(); } catch(Exception ex) { return ex.toString(); } } } }
throws SAXException { if (LitePalParser.NODE_DB_NAME.equalsIgnoreCase(localName)) { for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setDbName(attributes.getValue(i).trim()); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setVersion(Integer.parseInt(attributes.getValue(i).trim())); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_CLASS.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.addClassName(attributes.getValue(i).trim()); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setCases(attributes.getValue(i).trim()); for (int i = 0; i < attributes.getLength(); i++) { if (LitePalParser.ATTR_VALUE.equalsIgnoreCase(attributes.getLocalName(i))) { litePalAttr.setStorage(attributes.getValue(i).trim());
/** * Add the given attributes to the currently collected ones. These * attributes are always added, regardless of whether on not an element * is currently open. * @param atts List of attributes to add to this list */ public void addAttributes(Attributes atts) throws SAXException { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; addAttributeAlways( uri, atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i), false); } }