Class XMLUtils

java.lang.Object
org.javastro.ivoacore.common.xml.XMLUtils

public class XMLUtils extends Object
Utility class for marshalling and unmarshalling IVOA resource XML using JAXB and Saxon.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an XMLUtils instance, initializing the JAXB context, marshaller/unmarshaller, and the namespace-normalizing XSLT stylesheet.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> String
    marshall(T a)
    Marshals an IVOA resource object to an XML string.
    marshallElement(jakarta.xml.bind.JAXBElement<?> element)
    Marshals a JAXBElement to an XML string, applying namespace normalization.
    marshallOAI(org.javastro.ivoa.entities.resource.registry.oaipmh.OAIPMH element)
    Marshals an OAI-PMH element to an XML string.
    List<org.javastro.ivoa.entities.resource.Resource>
    Unmarshals a list of IVOA Resource objects from an XML string.
    <T> T
    unmarshal(Element xml, Class<T> clazz)
    Unmarshals an object from a DOM Element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XMLUtils

      public XMLUtils()
      Constructs an XMLUtils instance, initializing the JAXB context, marshaller/unmarshaller, and the namespace-normalizing XSLT stylesheet.
  • Method Details

    • marshall

      public <T> String marshall(T a)
      Marshals an IVOA resource object to an XML string.
      Type Parameters:
      T - the type of the object to marshal.
      Parameters:
      a - the object to marshal.
      Returns:
      the XML string representation of the object.
    • unmarshal

      public List<org.javastro.ivoa.entities.resource.Resource> unmarshal(String xml) throws jakarta.xml.bind.JAXBException
      Unmarshals a list of IVOA Resource objects from an XML string.
      Parameters:
      xml - the XML string to unmarshal.
      Returns:
      a list of Resource objects found in the XML.
      Throws:
      jakarta.xml.bind.JAXBException - if the XML cannot be parsed.
    • unmarshal

      public <T> T unmarshal(Element xml, Class<T> clazz) throws jakarta.xml.bind.JAXBException
      Unmarshals an object from a DOM Element.
      Type Parameters:
      T - the type to unmarshal into.
      Parameters:
      xml - the DOM element to unmarshal.
      clazz - the class of the target type.
      Returns:
      the unmarshalled object.
      Throws:
      jakarta.xml.bind.JAXBException - if the element cannot be unmarshalled.
    • marshallElement

      public String marshallElement(jakarta.xml.bind.JAXBElement<?> element)
      Marshals a JAXBElement to an XML string, applying namespace normalization.
      Parameters:
      element - the JAXB element to marshal.
      Returns:
      the XML string representation of the element.
    • marshallOAI

      public String marshallOAI(org.javastro.ivoa.entities.resource.registry.oaipmh.OAIPMH element)
      Marshals an OAI-PMH element to an XML string.
      Parameters:
      element - the OAI-PMH element to marshal.
      Returns:
      the XML string representation of the OAI-PMH element.