Class SchemaModuleUtil


  • public class SchemaModuleUtil
    extends java.lang.Object
    Utilities for working with SchemaModules, including marshalling and unmarshalling with JAXB.
    • Constructor Detail

      • SchemaModuleUtil

        public SchemaModuleUtil()
    • Method Detail

      • createResourceResolver

        @Nullable
        public static org.w3c.dom.ls.LSResourceResolver createResourceResolver​(@NonNull
                                                                               java.util.Set<SchemaModule<?>> modules,
                                                                               @NonNull
                                                                               ProgressIndicator progress)
        Create an LSResourceResolver that will use the supplied SchemaModules to find an XSD from its namespace. This must be used when marshalling/unmarshalling if any SchemaModules contain XSDs which import others without specifying a complete schemaLocation.
      • unmarshal

        @Nullable
        public static java.lang.Object unmarshal​(@NonNull
                                                 java.io.InputStream xml,
                                                 @NonNull
                                                 java.util.Collection<SchemaModule<?>> possibleModules,
                                                 boolean strict,
                                                 @NonNull
                                                 ProgressIndicator progress)
                                          throws javax.xml.bind.JAXBException
        Use JAXB to create POJOs from the given XML.
        Parameters:
        xml - The XML to read. The stream will be closed after being read.
        possibleModules - The SchemaModules that are available to parse the XML.
        progress - For logging.
        Returns:
        The unmarshalled object.
        Throws:
        javax.xml.bind.JAXBException - if there is an error during unmarshalling.

        TODO: maybe templatize and return a nicer type.

      • marshal

        public static void marshal​(@NonNull
                                   javax.xml.bind.JAXBElement element,
                                   @NonNull
                                   java.util.Collection<SchemaModule<?>> possibleModules,
                                   @NonNull
                                   java.io.OutputStream out,
                                   @Nullable
                                   org.w3c.dom.ls.LSResourceResolver resourceResolver,
                                   @NonNull
                                   ProgressIndicator progress)
        Transform the given JAXBElement into xml, using JAXB and the schemas provided by the given SchemaModules.