for (Iterator<?> itr = attributesAsElements.iterator(); itr.hasNext();) { QName q = (QName) itr.next(); jsonAttributesAsElements.add(createAttributeKey(q.getPrefix(), q.getNamespaceURI(), q.getLocalPart()));
public void writeAttribute(String prefix, String ns, String local, String value) throws XMLStreamException { String key = convention.isElement(prefix, ns, local) ? convention.createKey(prefix, ns, local) : convention.createAttributeKey(prefix, ns, local); JSONPropertyString prop = new JSONPropertyString(key, null); prop.addText(value); current = current.withProperty(prop, false); }
public MappedNamespaceConvention(Configuration config) { super(); this.xnsToJns = config.getXmlToJsonNamespaces(); this.attributesAsElements = config.getAttributesAsElements(); for (Iterator itr = xnsToJns.entrySet().iterator(); itr.hasNext();) { Map.Entry entry = (Map.Entry) itr.next(); jnsToXns.put(entry.getValue(), entry.getKey()); } jsonAttributesAsElements = new ArrayList(); if (attributesAsElements != null) { for (Iterator itr = attributesAsElements.iterator(); itr.hasNext();) { QName q = (QName) itr.next(); jsonAttributesAsElements.add(createAttributeKey(q.getPrefix(), q.getNamespaceURI(), q.getLocalPart())); } } }
public void writeAttribute(String p, String ns, String local, String value) throws XMLStreamException { if (convention.isElement(p, ns, local)) { writeStartElement(p, local, ns); writeCharacters(value); writeEndElement(); return; } String key = convention.createAttributeKey(p, ns, local); try { if (current instanceof JSONArray) { JSONArray array = ((JSONArray) current); current = array.get(array.length() - 1); } makeCurrentJSONObject(); if (current instanceof JSONObject) { Object o = ((JSONObject) current).opt(key); if (o == null) { ((JSONObject) current).put(key, value); } } } catch (JSONException e) { throw new XMLStreamException(e); } }