in SdmxDataParser/src/main/java/org/sdmxsource/sdmx/dataparser/transform/impl/SchemaGeneratorUtility.java [57:216]
public void transform(OutputStream out, String targetNamespace, SDMX_SCHEMA targetSchemaVersion, DataStructureSuperBean keyFamily, Map<String, Set<String>> validCodes) {
this.validCodeMap = validCodes;
if (out == null) {
throw new IllegalArgumentException("No output stream provided");
}
try {
// write out the initial xml schema information common to all xsd types
// this includes the CODELISTS
targetNamespace = keyFamily.getUrn() + ":utility";
init(out, UTILITY, targetNamespace, targetSchemaVersion, keyFamily);
//////////////////DATASET////////////////////////////////////////////////////////////////////////////////
//ADD ELEMENT
// only changing compact to utility in 3rd arg
addElement("DataSet", "DataSetType", "utility:DataSet");
// again just change compact to utility
addComplexType("DataSetType", "utility:DataSetType");
//START SEQUENCE
writer.writeStartElement(SCHEMA_NS, "sequence");
//START CHOICE
//addChoice("unbounded");
addChoice(UTILITY, "", "unbounded");
//ADD GROUPS
for (GroupSuperBean currentGroup : keyFamily.getGroups()) {
//START ELEMENT
writer.writeStartElement(SCHEMA_NS, "element");
writer.writeAttribute("ref", currentGroup.getId());
//END ELEMENT
writer.writeEndElement();
}
//START ELEMENT
writer.writeStartElement(SCHEMA_NS, "element");
writer.writeAttribute("ref", "Series");
writer.writeEndElement();
//END CHOICE ELEMENT
writer.writeEndElement();
addAnnotations();
//END SEQUENCE
writer.writeEndElement();
for (AttributeSuperBean bean : keyFamily.getDatasetAttributes()) {
addComponentBean(bean);
}
// END DATASET
endComplexType(writer);
for (GroupSuperBean currentGroup : keyFamily.getGroups()) {
//////////////////GROUP////////////////////////////////////////////////////////////////////////////////
addElement(currentGroup.getId(), currentGroup.getId() + "Type", "utility:Group");
addComplexType(currentGroup.getId() + "Type", "utility:GroupType");
//START SEQUENCE
writer.writeStartElement(SCHEMA_NS, "sequence");
//START ELEMENT
writer.writeStartElement(SCHEMA_NS, "element");
writer.writeAttribute("ref", "Series");
writer.writeAttribute("maxOccurs", "unbounded");
//END ELEMENT
writer.writeEndElement();
addAnnotations();
//END SEQUENCE
writer.writeEndElement();
writeGroupAttributes(currentGroup);
endComplexType(writer);
}
//////////////////SERIES////////////////////////////////////////////////////////////////////////////////
addElement("Series", "SeriesType", "utility:Series");
addComplexType("SeriesType", "utility:SeriesType");
//START SEQUENCE
writer.writeStartElement(SCHEMA_NS, "sequence");
writer.writeStartElement(SCHEMA_NS, "element");
writer.writeAttribute("ref", "Key");
writer.writeEndElement();
writer.writeStartElement(SCHEMA_NS, "element");
writer.writeAttribute("ref", "Obs");
writer.writeAttribute("maxOccurs", "unbounded");
writer.writeEndElement();
addAnnotations();
//END SEQUENCE
writer.writeEndElement();
for (AttributeSuperBean bean : keyFamily.getSeriesAttributes()) {
addComponentBean(bean);
}
endComplexType(writer);
//////////////////KEY////////////////////////////////////////////////////////////////
addElement("Key", "KeyType", "utility:Key");
addComplexType("KeyType", "utility:KeyType");
//START SEQUENCE
writer.writeStartElement(SCHEMA_NS, "sequence");
for (DimensionSuperBean bean : keyFamily.getDimensions()) {
addElement(bean);
}
//END SEQUENCE
writer.writeEndElement();
endComplexType(writer);
//////////////////OBSERVATION////////////////////////////////////////////////////////////////////////////////
addElement("Obs", "ObsType", "utility:Obs");
addComplexType("ObsType", "utility:ObsType");
//START SEQUENCE
writer.writeStartElement(SCHEMA_NS, "sequence");
if (keyFamily.getTimeDimension() != null) {
addElement(keyFamily.getTimeDimension());
}
if (keyFamily.getPrimaryMeasure() != null) {
addElement(keyFamily.getPrimaryMeasure());
}
addAnnotations();
//END SEQUENCE
writer.writeEndElement();
for (AttributeSuperBean bean : keyFamily.getObservationAttributes()) {
addComponentBean(bean);
}
endComplexType(writer);
//END documentation
writer.writeEndElement();
} catch (Throwable th) {
throw new RuntimeException(th);
} finally {
close();
}
}