Package org.javastro.ivoacore.common.xml
Class XMLUtils
java.lang.Object
org.javastro.ivoacore.common.xml.XMLUtils
Utility class for marshalling and unmarshalling IVOA resource XML using JAXB and Saxon.
-
Constructor Summary
ConstructorsConstructorDescriptionXMLUtils()Constructs an XMLUtils instance, initializing the JAXB context, marshaller/unmarshaller, and the namespace-normalizing XSLT stylesheet. -
Method Summary
Modifier and TypeMethodDescription<T> Stringmarshall(T a) Marshals an IVOA resource object to an XML string.marshallElement(jakarta.xml.bind.JAXBElement<?> element) Marshals aJAXBElementto 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 IVOAResourceobjects from an XML string.<T> TUnmarshals an object from a DOMElement.
-
Constructor Details
-
XMLUtils
public XMLUtils()Constructs an XMLUtils instance, initializing the JAXB context, marshaller/unmarshaller, and the namespace-normalizing XSLT stylesheet.
-
-
Method Details
-
marshall
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 IVOAResourceobjects from an XML string.- Parameters:
xml- the XML string to unmarshal.- Returns:
- a list of
Resourceobjects found in the XML. - Throws:
jakarta.xml.bind.JAXBException- if the XML cannot be parsed.
-
unmarshal
Unmarshals an object from a DOMElement.- 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
Marshals aJAXBElementto an XML string, applying namespace normalization.- Parameters:
element- the JAXB element to marshal.- Returns:
- the XML string representation of the element.
-
marshallOAI
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.
-