Converting From One JAXB Object to Another Using the XSLT Template

Is there a way to convert a JAXB generated object to another JAXB object using an XSLT template file. Two objects are generated by two different JAXB bindings.

I know that I can arrange an object into strings, and then use the XSLT processor to convert it to another format. After that, cancel it to another JAXB object.

The question is, is it possible to do this in JAXB.

+2
source share
2 answers

, - , imho. , , TransformerHandler, xsl dom. . () , , :

Source xsl = ...
SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance();
TransformerHandler handler = factory.newTransformerHandler(xsl);

DOMResult result = new DOMResult();

handler.setResult(result);

marshaller.marshal(inputObject, handler);

transformedObject = unmarshaller.unmarshal(result.getNode());
+3

, . JAXB Java XML XML Java. XML, XSLT . Java, Java . .

+1

Source: https://habr.com/ru/post/1536783/


All Articles