@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); }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (localName.equals("factory")) { String className = attributes.getValue("class"); try { addClass(className); } catch (ClassNotFoundException e) { throw new SAXException("Cannot find Matcher class : " + className); } } } });
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()); }
String foName = amap.getValue("name"); // NOI18N throw new SAXException(NbBundle.getMessage(XMLFileSystem.class, "XML_MisssingAttr")); // NOI18N throw new SAXException(NbBundle.getMessage(XMLFileSystem.class, "XML_MisssingAttr")); // NOI18N if (amap.getLength() > 1) { uri = amap.getValue("url"); // NOI18N throw new SAXException(NbBundle.getMessage(XMLFileSystem.class, "XML_MisssingAttr")); // NOI18N int len = amap.getLength(); String key = amap.getQName(i); String value = amap.getValue(i); if (MultiFileObject.WEIGHT_ATTRIBUTE.equals(amap.getValue("name"))) { String weightS = amap.getValue("intvalue"); if (weightS != null) { try {
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)); }
protected void writeAttribute(Attributes attributes, int index) throws IOException { char quote = format.getAttributeQuoteCharacter(); writer.write(" "); writer.write(attributes.getQName(index)); writer.write("="); writer.write(quote); writeEscapeAttributeEntities(attributes.getValue(index)); writer.write(quote); }
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; }
/** * Utility to safely get an attribute. If it does not exist an exception * is thrown. * @param attributes collect to get attribute from. * @param name name of the attribute to get. * @return the value of the attribute. * @throws SAXException if the attribute does not exist. */ private static String safeGet(Attributes attributes, String name) throws SAXException { final String returnValue = attributes.getValue(name); if (returnValue == null) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature // of the only method which calls the current one throw new SAXException("missing attribute " + name); } return returnValue; }
@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; } } } }
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; }
@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)); } } }
/** * Returns the suppress element, initialized from given attributes. * @param attributes the attributes of xml-tag "<suppress></suppress>", specified inside * suppression file. * @return the suppress element * @throws SAXException if an error occurs. */ private static SuppressElement getSuppressElement(Attributes attributes) throws SAXException { final String checks = attributes.getValue(ATTRIBUTE_NAME_CHECKS); final String modId = attributes.getValue(ATTRIBUTE_NAME_ID); final String message = attributes.getValue(ATTRIBUTE_NAME_MESSAGE); if (checks == null && modId == null && message == null) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature throw new SAXException("missing checks or id or message attribute"); } final SuppressElement suppress; try { final String files = attributes.getValue(ATTRIBUTE_NAME_FILES); final String lines = attributes.getValue(ATTRIBUTE_NAME_LINES); final String columns = attributes.getValue(ATTRIBUTE_NAME_COLUMNS); suppress = new SuppressElement(files, checks, message, modId, lines, columns); } catch (final PatternSyntaxException ex) { // -@cs[IllegalInstantiation] SAXException is in the overridden method signature throw new SAXException("invalid files or checks or message format", ex); } return suppress; }
for (int i = 0, n = atts.getLength(); i < n; i++) { if (atts.getLocalName(i).equals("service")) { this.service = atts.getValue(i);
@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 void checkNumber(Attributes attrs) throws SAXException { if (StringTools.isEmpty(attrs.getValue("no"))) { throw new SAXException("References cannot be empty: " + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + "."); } else if (Integer.parseInt(attrs.getValue("no")) < 1 && regex.length() == 0) { throw new SAXException("References must be larger than 0: " + attrs.getValue("no") + "\n Line: " + pLocator.getLineNumber() + ", column: " + pLocator.getColumnNumber() + "."); } }
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; }
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());