Search in sources :

Example 1 with AxiomAttribute

use of org.apache.axiom.om.impl.intf.AxiomAttribute in project webservices-axiom by apache.

the class OMFactoryImpl method importAttribute.

private AxiomAttribute importAttribute(OMAttribute attribute) {
    AxiomAttribute importedAttribute = createNode(AxiomAttribute.class);
    copyName(attribute, importedAttribute);
    importedAttribute.setAttributeValue(attribute.getAttributeValue());
    return importedAttribute;
}
Also used : AxiomAttribute(org.apache.axiom.om.impl.intf.AxiomAttribute)

Example 2 with AxiomAttribute

use of org.apache.axiom.om.impl.intf.AxiomAttribute in project webservices-axiom by apache.

the class OMFactoryImpl method createOMAttribute.

@Override
public final OMAttribute createOMAttribute(String localName, OMNamespace ns, String value) {
    if (ns != null && ns.getPrefix() == null) {
        String namespaceURI = ns.getNamespaceURI();
        if (namespaceURI.length() == 0) {
            ns = null;
        } else {
            ns = new OMNamespaceImpl(namespaceURI, generatePrefix(namespaceURI));
        }
    }
    if (ns != null) {
        if (ns.getNamespaceURI().length() == 0) {
            if (ns.getPrefix().length() > 0) {
                throw new IllegalArgumentException("Cannot create a prefixed attribute with an empty namespace name");
            } else {
                ns = null;
            }
        } else if (ns.getPrefix().length() == 0) {
            throw new IllegalArgumentException("Cannot create an unprefixed attribute with a namespace");
        }
    }
    AxiomAttribute attr = createNode(AxiomAttribute.class);
    attr.internalSetLocalName(localName);
    try {
        attr.coreSetCharacterData(value, AxiomSemantics.INSTANCE);
    } catch (CoreModelException ex) {
        throw AxiomExceptionTranslator.translate(ex);
    }
    attr.internalSetNamespace(ns);
    attr.coreSetType("CDATA");
    return attr;
}
Also used : CoreModelException(org.apache.axiom.core.CoreModelException) AxiomAttribute(org.apache.axiom.om.impl.intf.AxiomAttribute) OMNamespaceImpl(org.apache.axiom.om.impl.common.OMNamespaceImpl)

Aggregations

AxiomAttribute (org.apache.axiom.om.impl.intf.AxiomAttribute)2 CoreModelException (org.apache.axiom.core.CoreModelException)1 OMNamespaceImpl (org.apache.axiom.om.impl.common.OMNamespaceImpl)1