parseXMLEvent(next, currentNode, document);
}
@SuppressWarnings("unchecked")
Iterator<XMLSecAttribute> attributesIterator = xmlSecStartElement.getAttributes();
while (attributesIterator.hasNext()) {
XMLSecAttribute next = attributesIterator.next();
parseXMLEvent(next, currentNode, document);
}
//add namespace which is not declared on current element but must be on a parent element:
String elementNs = document.lookupNamespaceURI(xmlSecStartElement.getName().getPrefix());
if (elementNs == null) {
parseXMLEvent(xmlSecStartElement.getElementNamespace(), currentNode, document);
}
break;
case XMLStreamConstants.END_ELEMENT:
if (currentNode.getParentNode() != null) {
currentNode = currentNode.getParentNode();
}
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
Node piNode = document.createProcessingInstruction(
((ProcessingInstruction) xmlSecEvent).getTarget(),
((ProcessingInstruction) xmlSecEvent).getTarget()
);
currentNode.appendChild(piNode);
break;
case XMLStreamConstants.CHARACTERS:
Node characterNode = document.createTextNode(xmlSecEvent.asCharacters().getData());
currentNode.appendChild(characterNode);
break;
case XMLStreamConstants.COMMENT:
Node commentNode = document.createComment(((Comment) xmlSecEvent).getText());
currentNode.appendChild(commentNode);
break;
case XMLStreamConstants.START_DOCUMENT:
break;
case XMLStreamConstants.END_DOCUMENT:
return currentNode;
case XMLStreamConstants.ATTRIBUTE:
final XMLSecAttribute xmlSecAttribute = (XMLSecAttribute) xmlSecEvent;
Attr attributeNode = document.createAttributeNS(
xmlSecAttribute.getName().getNamespaceURI(),
xmlSecAttribute.getName().getLocalPart());
attributeNode.setPrefix(xmlSecAttribute.getName().getPrefix());
attributeNode.setValue(xmlSecAttribute.getValue());
((Element) currentNode).setAttributeNodeNS(attributeNode);
//add namespace which is not declared on current element but must be on a parent element:
String attrNs = document.lookupNamespaceURI(xmlSecAttribute.getName().getPrefix());
if (attrNs == null) {
parseXMLEvent(xmlSecAttribute.getAttributeNamespace(), currentNode, document);
}
break;
case XMLStreamConstants.DTD:
//todo?:
/*