use of groovy.util.slurpersupport.Node in project groovy by apache.
the class XmlSlurper method startElement.
/* (non-Javadoc)
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(final String namespaceURI, final String localName, final String qName, final Attributes atts) throws SAXException {
addCdata();
final Map<String, String> attributes = new NamespaceAwareHashMap();
final Map<String, String> attributeNamespaces = new HashMap<String, String>();
for (int i = atts.getLength() - 1; i != -1; i--) {
if (atts.getURI(i).length() == 0) {
attributes.put(atts.getQName(i), atts.getValue(i));
} else {
String key = new QName(atts.getURI(i), atts.getLocalName(i)).toString();
attributes.put(key, atts.getValue(i));
attributeNamespaces.put(key, atts.getURI(i));
}
}
final Node newElement;
if (namespaceURI.length() == 0) {
newElement = new Node(currentNode, qName, attributes, attributeNamespaces, namespaceURI);
} else {
newElement = new Node(currentNode, localName, attributes, attributeNamespaces, namespaceURI);
}
if (currentNode != null) {
currentNode.addChild(newElement);
}
stack.push(currentNode);
currentNode = newElement;
}
use of groovy.util.slurpersupport.Node in project groovy by apache.
the class XmlSlurper method endElement.
/* (non-Javadoc)
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
public void endElement(final String namespaceURI, final String localName, final String qName) throws SAXException {
addCdata();
Node oldCurrentNode = stack.pop();
if (oldCurrentNode != null) {
currentNode = oldCurrentNode;
}
}
use of groovy.util.slurpersupport.Node in project groovy-core by groovy.
the class XmlSlurper method endElement.
/* (non-Javadoc)
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
public void endElement(final String namespaceURI, final String localName, final String qName) throws SAXException {
addCdata();
Node oldCurrentNode = stack.pop();
if (oldCurrentNode != null) {
currentNode = oldCurrentNode;
}
}
use of groovy.util.slurpersupport.Node in project groovy-core by groovy.
the class XmlSlurper method startElement.
/* (non-Javadoc)
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(final String namespaceURI, final String localName, final String qName, final Attributes atts) throws SAXException {
addCdata();
final Map<String, String> attributes = new NamespaceAwareHashMap();
final Map<String, String> attributeNamespaces = new HashMap<String, String>();
for (int i = atts.getLength() - 1; i != -1; i--) {
if (atts.getURI(i).length() == 0) {
attributes.put(atts.getQName(i), atts.getValue(i));
} else {
String key = new QName(atts.getURI(i), atts.getLocalName(i)).toString();
attributes.put(key, atts.getValue(i));
attributeNamespaces.put(key, atts.getURI(i));
}
}
final Node newElement;
if (namespaceURI.length() == 0) {
newElement = new Node(currentNode, qName, attributes, attributeNamespaces, namespaceURI);
} else {
newElement = new Node(currentNode, localName, attributes, attributeNamespaces, namespaceURI);
}
if (currentNode != null) {
currentNode.addChild(newElement);
}
stack.push(currentNode);
currentNode = newElement;
}
Aggregations