Created
September 18, 2014 04:44
-
-
Save itsrifat/12baccd7e2b9eba333ad to your computer and use it in GitHub Desktop.
client code for generating metadata that conforms to ISO 19115 using APache SIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
// output pretty printed | |
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); | |
jaxbMarshaller.marshal(mi_Metadata, file); | |
jaxbMarshaller.marshal(mi_Metadata, System.out); | |
} catch (JAXBException e) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This client code generates this xml https://gist.github.com/itsrifat/826d901868c37c20b314