public void startElement(String namespace, String localName, String qName, Attributes attrs) final Element tmp = (Element)_document.createElementNS(namespace, qName); final int nDecls = _namespaceDecls.size(); for (int i = 0; i < nDecls; i++) { final String prefix = (String) _namespaceDecls.elementAt(i++); tmp.setAttributeNS(XMLNS_URI, XMLNS_PREFIX, (String) _namespaceDecls.elementAt(i)); tmp.setAttributeNS(XMLNS_URI, XMLNS_STRING + prefix, (String) _namespaceDecls.elementAt(i)); final int nattrs = attrs.getLength(); for (int i = 0; i < nattrs; i++) { if (attrs.getLocalName(i) == null) { tmp.setAttribute(attrs.getQName(i), attrs.getValue(i)); tmp.setAttributeNS(attrs.getURI(i), attrs.getQName(i), attrs.getValue(i)); Node last = (Node)_nodeStk.peek(); _nodeStk.push(tmp); _lastSibling = null;
@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 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; }
final Stack<Element> elementStack = new Stack<Element>(); final StringBuilder textBuffer = new StringBuilder(); final DefaultHandler handler = new DefaultHandler() { throws SAXException { addTextIfNeeded(); final Element el = doc.createElement(qName); for (int i = 0; i < attributes.getLength(); i++) { el.setAttribute(attributes.getQName(i), attributes.getValue(i)); elementStack.push(el); public void endElement(final String uri, final String localName, final String qName) { addTextIfNeeded(); final Element closedEl = elementStack.pop(); if (elementStack.isEmpty()) { // Is this the root element? doc.appendChild(closedEl); } else { if (textBuffer.length() > 0) { final Element el = elementStack.peek(); final Node textNode = doc.createTextNode(textBuffer.toString()); el.appendChild(textNode); textBuffer.delete(0, textBuffer.length());
private void createElement(String tagName, Attributes attributes) { Element element = fParent.getOwnerDocument().createElement(tagName); for (int i = 0; i < attributes.getLength(); i++) { element.setAttribute(attributes.getQName(i), attributes.getValue(i)); } ((Element)fOpenElements.peek()).appendChild(element); fOpenElements.push(element); }
elem = m_doc.createElementNS(null,name); else elem = m_doc.createElementNS(ns, name); int nAtts = atts.getLength(); if (atts.getType(i).equalsIgnoreCase("ID")) setIDAttribute(atts.getValue(i), elem); String attrNS = atts.getURI(i); String attrQName = atts.getQName(i); elem.setAttributeNS(attrNS,attrQName, atts.getValue(i)); int nDecls = m_prefixMappings.size(); prefix = (String) m_prefixMappings.elementAt(i); declURL = (String) m_prefixMappings.elementAt(i + 1); elem.setAttributeNS("http://www.w3.org/2000/xmlns/", prefix, declURL); m_elemStack.push(elem); throw new org.xml.sax.SAXException(de);
@Override public final void startElement( final String ns, final String localName, final String qName, final Attributes atts) throws SAXException { try { closeElement(); writeIdent(); w.write('<' + qName); if (atts != null && atts.getLength() > 0) { writeAttributes(atts); } if (optimizeEmptyElements) { openElement = true; } else { w.write(">\n"); } ident += 2; } catch (IOException ex) { throw new SAXException(ex); } }
public void handleLibraryState(String elementName, Attributes attributes) { if (elementName.equals(LIBRARY_EXPORT)) { stateStack.push(new Integer(LIBRARY_EXPORT_STATE)); String currentLib = (String) objectStack.peek(); if (attributes == null) return; String maskValue = attributes.getValue("", LIBRARY_EXPORT_MASK); //$NON-NLS-1$ objectStack.pop(); Vector exportMask = (Vector) objectStack.peek(); while (tok.hasMoreTokens()) { String value = tok.nextToken(); if (!exportMask.contains(maskValue)) exportMask.addElement(value.trim());
@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("xml:base")) { try { xmlBase = new URI(atts.getValue(i)); throw new SAXParseCompletedException(); } catch (URISyntaxException e) { logger.error("URI syntax error", e); } } } throw new SAXException("No xml base"); } }
logger.fine("ADDING NAMESPACES: " + schemaProxy.size()); String t = atts.getValue("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); t = atts.getValue("", "schemaLocation"); throw new SAXException( "Bad Schema location attribute: you must have an even number of terms"); XMLElementHandler parent = ((XMLElementHandler) handlers.peek()); logger.finest( "Parent Node = " URI uri = new URI(namespaceURI); XMLElementHandler eh = parent.getHandler(uri, localName, hints); handlers.push(eh); eh.startElement(new URI(namespaceURI), localName, atts); } catch (Exception e) { new SAXException( e.getMessage() + " at Line " + qName, e); exception.initCause(e); throw exception;
String sl = atts.getValue("", "schemaLocation"); sl = atts.getValue(namespaceURI, "schemaLocation"); schemaLocation = sl != null ? new URI(sl) : null; } catch (URISyntaxException e) { logger.warning(e.toString()); throw new SAXException(e); String namespace1 = atts.getValue("", "namespace"); namespace1 = atts.getValue(namespaceURI, "namespace"); this.namespace = new URI(namespace1); } catch (URISyntaxException e) { logger.warning(e.toString()); throw new SAXException(e); throw new SAXException( "You may not import a namespace with the same name as the current namespace");
public void startElement(String namespace, String localName, String qName, Attributes attrs) { Node parent = nodeStack.peek(); Element element = document.createElementNS(namespace, qName); int length = attrs.getLength(); for (int i = 0; i < length; i++) { String namespaceuri = attrs.getURI(i); String value = attrs.getValue(i); String qname = attrs.getQName(i); element.setAttributeNS(namespaceuri, qname, value); nodeStack.push(element);
throws SAXException { if (value.length != 1) { throw new SAXException( "Internal error, ElementValues require an associated Element."); String cs; String ts; dec = attrs.getValue("", "decimal"); dec = attrs.getValue(GMLSchema.NAMESPACE.toString(), "decimal"); cs = attrs.getValue("", "cs"); cs = attrs.getValue(GMLSchema.NAMESPACE.toString(), "cs"); ts = attrs.getValue("", "ts"); ts = attrs.getValue(GMLSchema.NAMESPACE.toString(), "ts");
String indicesString = null; for (int i = 0; i < atts.getLength(); i++) { String lName = atts.getLocalName(i); String value = atts.getValue(i); value = (value == null) ? "" : value.trim(); originX = Float.parseFloat(atts.getValue(i)); } catch (NumberFormatException e) { throw new SAXException(e); originY = Float.parseFloat(atts.getValue(i)); } catch (NumberFormatException e) { throw new SAXException(e); unicodeString = atts.getValue(i); } else if (BIDI_LEVEL.equals(lName) && value.length() > 0) { try { bidilevel = Integer.parseInt(atts.getValue(i)); } catch (NumberFormatException e) { throw new SAXException(e); indicesString = atts.getValue(i); } else if (NAME.equals(lName)) { name = value;
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (mTagStack.empty()) throw new SAXException("Tag stack is empty when it shouldn't be."); Node currentNode = new Node(qName); mTagStack.peek().children.add(currentNode); mTagStack.push(currentNode); for (int i = 0; i < attributes.getLength(); ++i) { String attributeName = attributes.getLocalName(i); String attributeValue = attributes.getValue(attributeName); currentNode.attributes.put(attributeName, attributeValue); } }
@Override public void startElement(String uri, String localName, String qName, Attributes attribs) throws SAXException { if (qName.equals("scene")) { if (elementStack.size() != 0) { throw new SAXException("dotScene parse error: 'scene' element must be the root XML element"); String version = attribs.getValue("formatVersion"); if (version == null || (!version.equals("1.0.0") && !version.equals("1.0.1"))) { logger.log(Level.WARNING, "Unrecognized version number" throw new SAXException("dotScene parse error: nodes element was specified twice"); String curElement = elementStack.peek(); if (!curElement.equals("node") && !curElement.equals("nodes")) { throw new SAXException("dotScene parse error: " + "node element can only appear under 'node' or 'nodes'"); } else if (qName.equals("property")) { if (node != null) { String type = attribs.getValue("type"); String name = attribs.getValue("name"); String data = attribs.getValue("data"); if (type.equals("BOOL")) { node.setUserData(name, Boolean.parseBoolean(data) || data.equals("1"));
void startElement(Attributes attributes, String localName) throws SAXException { FlexViews.Element element = null; for (int i=0; i<elementCache.length; i++) { if (elementCache[i].isElement(localName)) { element = elementCache[i]; break; } } if (element == null) throw new SAXException("Undefined FlexViews Element: " + localName); elements.push(element); String id = attributes.getValue(FlexViews.Attribute.ID.tagName()); if (element.isViewGroup()) { if (id == null) throw new SAXException("All ViewGroups require that a \"" + FlexViews.Attribute.ID.tagName() + "\" attribute is defined."); ids.push(id); views.push(new ArrayList<FlexView>()); } else { if (!views.isEmpty()) views.peek().add(new FlexView(attributes, element)); } if (id != null) { if (!viewMap.containsKey(id)) viewMap.put(id, new FlexView(attributes, element)); else throw new SAXException("Views cannot have the same ID: " + id); } }