This is a sample client code that generates a partial xml file using Apache SIS that conforms to ISO 19115 schema:
package edu.unr.nccp;
import org.apache.sis.internal.jaxb.gmi.MI_Metadata;
import org.apache.sis.metadata.iso.citation.DefaultContact;
import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.citation.Contact;
import org.opengis.metadata.identification.CharacterSet;
import org.opengis.metadata.maintenance.ScopeCode;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class GenerateMetadataXml {
public static void main(String[] args) {
MI_Metadata mi_Metadata = new MI_Metadata();
mi_Metadata.setLanguage(Locale.ENGLISH);
mi_Metadata.setCharacterSet(CharacterSet.UTF_8);
List scopeCodes = new ArrayList<ScopeCode>();
scopeCodes.add(ScopeCode.DATASET);
mi_Metadata.setHierarchyLevels(scopeCodes);
try {
File file = new File("file.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(MI_Metadata.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(mi_Metadata, file);
}
catch (JAXBException e) {
}
}
}
This is the xml output the above client code produces:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmi:MI_Metadata xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:ns9="http://www.w3.org/1999/xlink">
<gmd:language>
<gmd:LanguageCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#LanguageCode" codeListValue="eng" codeSpace="eng">English</gmd:LanguageCode>
</gmd:language>
<gmd:characterSet>
<gmd:MD_CharacterSetCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" codeListValue="utf8">UTF-8</gmd:MD_CharacterSetCode>
</gmd:characterSet>
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset" codeSpace="eng">Dataset</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
</gmi:MI_Metadata>