Search in sources :

Example 6 with PropertyType

use of eu.esdihumboldt.hale.common.align.io.impl.internal.generated.PropertyType in project hale by halestudio.

the class DOMEntityDefinitionHelper method propertyFromDOM.

/**
 * Converts the given element to a property entity definition. If any
 * exception occurs <code>null</code> is returned.
 *
 * @param fragment the fragment to convert
 * @param types the type index to use for unmarshalling
 * @param ssid the schema space to use for unmarshalling
 * @return the type entity definition or <code>null</code>
 */
public static PropertyEntityDefinition propertyFromDOM(Element fragment, TypeIndex types, SchemaSpaceID ssid) {
    try {
        JAXBContext jc = JAXBContext.newInstance(JaxbAlignmentIO.ALIGNMENT_CONTEXT, PropertyType.class.getClassLoader());
        Unmarshaller u = jc.createUnmarshaller();
        // it will debug problems while unmarshalling
        u.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
        JAXBElement<PropertyType> root = u.unmarshal(fragment, PropertyType.class);
        return resolver.resolveProperty(root.getValue(), types, ssid).getDefinition();
    } catch (Exception e) {
        return null;
    }
}
Also used : JAXBContext(javax.xml.bind.JAXBContext) PropertyType(eu.esdihumboldt.hale.common.align.io.impl.internal.generated.PropertyType) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

PropertyType (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.PropertyType)6 Element (org.w3c.dom.Element)4 JAXBContext (javax.xml.bind.JAXBContext)3 Unmarshaller (javax.xml.bind.Unmarshaller)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 Test (org.junit.Test)2 ClassType (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.ClassType)1 ObjectFactory (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.ObjectFactory)1 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)1 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 DefaultPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition)1 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)1 JAXBElement (javax.xml.bind.JAXBElement)1 Marshaller (javax.xml.bind.Marshaller)1 QName (javax.xml.namespace.QName)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1