use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class XmlSchemaReaderTest method testRead_shiporder_types_cycle.
/**
* Test reading a simple XML schema that uses several custom named types and
* has a cycle.
*
* @throws Exception if reading the schema fails
*/
@Test
public void testRead_shiporder_types_cycle() throws Exception {
URI location = getClass().getResource("/testdata/shiporder/shiporder-types-cycle.xsd").toURI();
LocatableInputSupplier<? extends InputStream> input = new DefaultInputSupplier(location);
XmlIndex schema = (XmlIndex) readSchema(input);
String ns = "http://www.example.com";
assertEquals(ns, schema.getNamespace());
// shiporder element
Collection<XmlElement> elements = getElementsWithNS(ns, schema.getElements().values());
assertEquals(1, elements.size());
XmlElement shiporder = elements.iterator().next();
assertNotNull(shiporder);
TypeDefinition type = shiporder.getType();
assertEquals(5, type.getChildren().size());
// contained shiporder element
PropertyDefinition s2 = type.getChild(new QName(ns, "shiporder")).asProperty();
assertNotNull(s2);
assertEquals(type, s2.getPropertyType());
}
use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class XmlSchemaReaderTest method testRead_shiporder_types_reverse.
/**
* Test reading a simple XML schema that uses several custom named types.
* The types are referenced before they are declared.
*
* @throws Exception if reading the schema fails
*/
@Test
public void testRead_shiporder_types_reverse() throws Exception {
URI location = getClass().getResource("/testdata/shiporder/shiporder-types-r.xsd").toURI();
LocatableInputSupplier<? extends InputStream> input = new DefaultInputSupplier(location);
XmlIndex schema = (XmlIndex) readSchema(input);
String ns = "http://www.example.com";
assertEquals(ns, schema.getNamespace());
// shiporder element
Collection<XmlElement> elements = getElementsWithNS(ns, schema.getElements().values());
assertEquals(1, elements.size());
XmlElement shiporder = elements.iterator().next();
testShiporderStructure(shiporder, ns);
}
use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class XmlSchemaReaderTest method testRead_shiporder_divided.
/**
* Test reading a simple XML schema that contains several elements
*
* @throws Exception if reading the schema fails
*/
@Test
public void testRead_shiporder_divided() throws Exception {
URI location = getClass().getResource("/testdata/shiporder/shiporder-divided.xsd").toURI();
LocatableInputSupplier<? extends InputStream> input = new DefaultInputSupplier(location);
XmlIndex schema = (XmlIndex) readSchema(input);
String ns = "http://www.example.com";
assertEquals(ns, schema.getNamespace());
// element count
Collection<XmlElement> elements = getElementsWithNS(ns, schema.getElements().values());
assertEquals(12, elements.size());
// shiporder element
XmlElement shiporder = schema.getElements().get(new QName(ns, "shiporder"));
testShiporderStructure(shiporder, ns);
}
use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class XmlSchemaReaderTest method testRead_shiporder_one.
/**
* Test reading a simple XML schema that contains one big element. Focuses
* on structure, simple type bindings and cardinalities.
*
* @throws Exception if reading the schema fails
*/
@Test
public void testRead_shiporder_one() throws Exception {
URI location = getClass().getResource("/testdata/shiporder/shiporder-one.xsd").toURI();
LocatableInputSupplier<? extends InputStream> input = new DefaultInputSupplier(location);
XmlIndex schema = (XmlIndex) readSchema(input);
String ns = "http://www.example.com";
assertEquals(ns, schema.getNamespace());
// shiporder element
Collection<XmlElement> elements = getElementsWithNS(ns, schema.getElements().values());
assertEquals(1, elements.size());
XmlElement shiporder = elements.iterator().next();
testShiporderStructure(shiporder, ns);
}
use of eu.esdihumboldt.hale.io.xsd.model.XmlElement in project hale by halestudio.
the class XmlElementsFactory method store.
@Override
public Value store(XmlElements constraint, TypeReferenceBuilder refBuilder) throws Exception {
Collection<? extends XmlElement> elements = constraint.getElements();
if (elements == null) {
return null;
}
ValueList result = new ValueList();
for (XmlElement element : elements) {
result.add(elementToValue(element, refBuilder));
}
return result.toValue();
}
Aggregations