Search in sources :

Example 6 with XmlElements

use of eu.esdihumboldt.hale.io.xsd.constraint.XmlElements in project hale by halestudio.

the class XmlElementsFactory method restore.

@Override
public XmlElements restore(Value value, Definition<?> definition, TypeResolver typeResolver, ClassResolver classResolver) throws Exception {
    XmlElements result = new XmlElements();
    ValueList list = value.as(ValueList.class);
    if (list != null) {
        for (Value val : list) {
            XmlElement element = valueToElement(val, definition, typeResolver);
            if (element != null) {
                result.addElement(element);
            }
        }
    }
    return result;
}
Also used : XmlElements(eu.esdihumboldt.hale.io.xsd.constraint.XmlElements) ValueList(eu.esdihumboldt.hale.common.core.io.ValueList) Value(eu.esdihumboldt.hale.common.core.io.Value) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement)

Example 7 with XmlElements

use of eu.esdihumboldt.hale.io.xsd.constraint.XmlElements in project hale by halestudio.

the class XmlTypeDefinition method getDescription.

@Override
public String getDescription() {
    String desc = super.getDescription();
    if (desc != null && !desc.isEmpty()) {
        return desc;
    }
    // if no description is present, try the description of the associated
    // element
    XmlElements elements = getConstraint(XmlElements.class);
    if (elements.getElements().size() == 1) {
        // only use element description if it's unique
        XmlElement element = elements.getElements().iterator().next();
        return element.getDescription();
    }
    return desc;
}
Also used : XmlElements(eu.esdihumboldt.hale.io.xsd.constraint.XmlElements) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement)

Example 8 with XmlElements

use of eu.esdihumboldt.hale.io.xsd.constraint.XmlElements in project hale by halestudio.

the class XslTransformationUtil method selectInstances.

/**
 * Create a XPath statement to select instances specified by the given type
 * entity definition.
 *
 * @param ted the type entity definition
 * @param context the context for the XPath expression, e.g. the empty
 *            string for the document root or <code>/</code> for anywhere in
 *            the document
 * @param namespaces the namespace context
 * @return the XPath expression or <code>null</code> if there are no
 *         elements that match the type
 */
public static String selectInstances(TypeEntityDefinition ted, String context, NamespaceContext namespaces) {
    TypeDefinition type = ted.getDefinition();
    // get the XML elements associated to the type
    XmlElements elements = type.getConstraint(XmlElements.class);
    if (elements.getElements().isEmpty()) {
        /*
			 * XXX dirty hack
			 * 
			 * In CityGML 1.0 no element for AppearanceType is defined, only a
			 * property that is not detected in this way. The source route
			 * element is not known here, so we also cannot do a search based on
			 * the type. Thus for now we handle it as a special case.
			 */
        QName typeName = ted.getDefinition().getName();
        if ("http://www.opengis.net/citygml/appearance/1.0".equals(typeName.getNamespaceURI()) && "AppearanceType".equals(typeName.getLocalPart())) {
            // create a dummy XML element
            elements = new XmlElements();
            elements.addElement(new XmlElement(new QName("http://www.opengis.net/citygml/appearance/1.0", "Appearance"), ted.getDefinition(), null));
        } else
            // XXX dirty hack end
            return null;
    }
    // XXX which elements should be used?
    // for now use all elements
    StringBuilder select = new StringBuilder();
    boolean first = true;
    for (XmlElement element : elements.getElements()) {
        if (first) {
            first = false;
        } else {
            select.append(" | ");
        }
        select.append(context);
        select.append('/');
        String ns = element.getName().getNamespaceURI();
        if (ns != null && !ns.isEmpty()) {
            String prefix = namespaces.getPrefix(ns);
            if (prefix != null && !prefix.isEmpty()) {
                select.append(prefix);
                select.append(':');
            }
        }
        select.append(element.getName().getLocalPart());
    }
    // filter
    if (ted.getFilter() != null) {
        String filterxpath = FilterToXPath.toXPath(ted.getDefinition(), namespaces, ted.getFilter());
        if (filterxpath != null && !filterxpath.isEmpty()) {
            select.insert(0, '(');
            select.append(")[");
            select.append(StringEscapeUtils.escapeXml(filterxpath));
            select.append(']');
        }
    }
    return select.toString();
}
Also used : XmlElements(eu.esdihumboldt.hale.io.xsd.constraint.XmlElements) QName(javax.xml.namespace.QName) XmlElement(eu.esdihumboldt.hale.io.xsd.model.XmlElement) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

XmlElements (eu.esdihumboldt.hale.io.xsd.constraint.XmlElements)8 XmlElement (eu.esdihumboldt.hale.io.xsd.model.XmlElement)8 QName (javax.xml.namespace.QName)6 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)5 SchemaSpace (eu.esdihumboldt.hale.common.schema.model.SchemaSpace)2 XmlIndex (eu.esdihumboldt.hale.io.xsd.model.XmlIndex)2 HashSet (java.util.HashSet)2 Value (eu.esdihumboldt.hale.common.core.io.Value)1 ValueList (eu.esdihumboldt.hale.common.core.io.ValueList)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)1 Group (eu.esdihumboldt.hale.common.instance.model.Group)1 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)1 GroupPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.GroupPropertyDefinition)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)1 WFSCapabilities (eu.esdihumboldt.hale.io.wfs.capabilities.WFSCapabilities)1 WFSOperation (eu.esdihumboldt.hale.io.wfs.capabilities.WFSOperation)1 AbstractWFSCapabilitiesPage (eu.esdihumboldt.hale.io.wfs.ui.capabilities.AbstractWFSCapabilitiesPage)1 XmlAttribute (eu.esdihumboldt.hale.io.xsd.model.XmlAttribute)1