use of org.apache.axiom.om.OMMetaFactory in project webservices-axiom by apache.
the class ImplementationFactory method parseImplementation.
private static Implementation parseImplementation(Loader loader, Element implementation) {
String name = implementation.getAttributeNS(null, "name");
if (name.length() == 0) {
log.error("Encountered " + QNAME_IMPLEMENTATION + " element without name attribute");
return null;
}
String loaderClassName = implementation.getAttributeNS(null, "loader");
if (loaderClassName.length() == 0) {
log.error("Encountered " + QNAME_IMPLEMENTATION + " element without loader attribute");
return null;
}
OMMetaFactory metaFactory = ((OMMetaFactoryLoader) load(loader, loaderClassName)).load(null);
if (metaFactory == null) {
return null;
}
List<Feature> features = new ArrayList<Feature>();
Node child = implementation.getFirstChild();
while (child != null) {
if (child instanceof Element) {
QName childQName = getQName(child);
if (childQName.equals(QNAME_FEATURE)) {
Feature feature = parseFeature(loader, (Element) child);
if (feature != null) {
features.add(feature);
}
} else {
log.warn("Skipping unexpected element " + childQName + "; only " + QNAME_FEATURE + " is expected");
}
}
child = child.getNextSibling();
}
return new Implementation(name, metaFactory, features.toArray(new Feature[features.size()]));
}
use of org.apache.axiom.om.OMMetaFactory in project webservices-axiom by apache.
the class ValidateSample method validateUsingDOM.
// START SNIPPET: dom
public void validateUsingDOM(InputStream in, URL schemaUrl) throws Exception {
OMMetaFactory mf = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(mf, in, "UTF-8");
SOAPEnvelope envelope = builder.getSOAPEnvelope();
OMElement bodyContent = envelope.getBody().getFirstElement();
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(schemaUrl);
Validator validator = schema.newValidator();
validator.validate(new DOMSource((Element) bodyContent));
}
use of org.apache.axiom.om.OMMetaFactory in project webservices-axiom by apache.
the class DOMFeatureTest method test.
public void test() {
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
assertTrue(metaFactory instanceof OMDOMMetaFactory);
}
Aggregations