use of org.apache.axiom.core.CoreModelException in project webservices-axiom by apache.
the class XMLReaderImpl method parse.
private void parse() throws SAXException {
XmlHandler handler = new ContentHandlerXmlHandler(contentHandler, lexicalHandler);
CoreElement contextElement = root.getContextElement();
if (contextElement != null) {
handler = new NamespaceContextPreservationFilterHandler(handler, contextElement);
}
try {
root.internalSerialize(handler, cache);
} catch (CoreModelException ex) {
throw new SAXException(ex);
} catch (StreamException ex) {
throw (SAXException) ex.getCause();
}
}
use of org.apache.axiom.core.CoreModelException in project webservices-axiom by apache.
the class NamespaceContextPreservationFilterHandler method attributesCompleted.
@Override
public void attributesCompleted() throws StreamException {
if (!done) {
try {
CoreElement current = contextElement;
while (true) {
CoreAttribute attr = current.coreGetFirstAttribute();
while (attr != null) {
if (attr instanceof CoreNamespaceDeclaration) {
CoreNamespaceDeclaration decl = (CoreNamespaceDeclaration) attr;
String prefix = decl.coreGetDeclaredPrefix();
if (prefixesAlreadyBound.add(prefix)) {
super.processNamespaceDeclaration(prefix, decl.coreGetCharacterData().toString());
}
}
attr = attr.coreGetNextAttribute();
}
CoreParentNode parent = current.coreGetParent();
if (!(parent instanceof CoreElement)) {
break;
}
current = (CoreElement) parent;
}
prefixesAlreadyBound = null;
done = true;
} catch (CoreModelException ex) {
throw new StreamException(ex);
}
}
super.attributesCompleted();
}
use of org.apache.axiom.core.CoreModelException in project webservices-axiom by apache.
the class CustomBuilderManager method getAction.
private Runnable getAction(CoreNode node, int depth, int firstCustomBuilder) {
lastCandidateElement = null;
lastCandidateDepth = -1;
if (node instanceof AxiomElement && (node instanceof AxiomSOAPHeaderBlock || !(node instanceof AxiomSOAPElement))) {
final AxiomElement element = (AxiomElement) node;
if (registrations != null) {
for (int i = firstCustomBuilder; i < registrations.size(); i++) {
CustomBuilderRegistration registration = registrations.get(i);
final String namespaceURI = element.coreGetNamespaceURI();
final String localName = element.coreGetLocalName();
if (registration.getSelector().accepts(element.getParent(), depth, namespaceURI, localName)) {
final CustomBuilder customBuilder = registration.getCustomBuilder();
if (log.isDebugEnabled()) {
log.debug("Custom builder " + customBuilder + " accepted element {" + namespaceURI + "}" + localName + " at depth " + depth);
}
return new Runnable() {
@Override
public void run() {
if (log.isDebugEnabled()) {
log.debug("Invoking custom builder " + customBuilder);
}
OMDataSource dataSource = customBuilder.create(element);
Class<? extends AxiomSourcedElement> type;
if (element instanceof AxiomSOAP11HeaderBlock) {
type = AxiomSOAP11HeaderBlock.class;
} else if (element instanceof AxiomSOAP12HeaderBlock) {
type = AxiomSOAP12HeaderBlock.class;
} else {
type = AxiomSourcedElement.class;
}
if (log.isDebugEnabled()) {
log.debug("Replacing element with new sourced element of type " + type);
}
AxiomSourcedElement newElement = element.coreCreateNode(type);
newElement.init(localName, new OMNamespaceImpl(namespaceURI, null), dataSource);
try {
element.coreReplaceWith(newElement, AxiomSemantics.INSTANCE);
} catch (CoreModelException ex) {
throw AxiomExceptionTranslator.translate(ex);
}
}
};
}
}
}
// Save a reference to the element so that we can process it when another custom builder is registered
lastCandidateElement = element;
lastCandidateDepth = depth;
}
return null;
}
use of org.apache.axiom.core.CoreModelException in project webservices-axiom by apache.
the class OMXMLParserWrapperImpl method getDocumentElement.
@Override
public final OMElement getDocumentElement(boolean discardDocument) {
try {
OMDocument document = getDocument();
OMElement element = document.getOMDocumentElement();
if (discardDocument) {
element.detach();
((AxiomDocument) document).coreDiscard(false);
}
return element;
} catch (CoreModelException ex) {
throw AxiomExceptionTranslator.translate(ex);
}
}
use of org.apache.axiom.core.CoreModelException in project webservices-axiom by apache.
the class BuildableContext method endContext.
private Context endContext() throws StreamException {
target.coreSetState(CoreParentNode.COMPLETE);
target.coreSetInputContext(null);
if (pendingCharacterData != null) {
try {
target.coreSetCharacterData(pendingCharacterData, null);
} catch (CoreModelException ex) {
throw new CoreModelStreamException(ex);
}
pendingCharacterData = null;
}
target = null;
builderHandler.decrementActiveContextCount();
return parentContext;
}
Aggregations