Refine search
/** * Creates a new instance that uses the specified * JAXBContext to unmarshal. * * @param context The JAXBContext that will be used to create the * necessary Unmarshaller. This parameter must not be null. * @exception JAXBException if an error is encountered while creating the * JAXBResult or if the context parameter is null. */ public JAXBResult( JAXBContext context ) throws JAXBException { this( ( context == null ) ? assertionFailed() : context.createUnmarshaller() ); }
/** * Prepare a JAXB transformation result for some given context. * @param context The JAXB context. * @return The result data structure created. * @throws Docx4JException In case of configuration errors. */ public static JAXBResult prepareJAXBResult(final JAXBContext context) throws Docx4JException { final JAXBResult result; try { final Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setEventHandler(new JaxbValidationEventHandler()); result = new JAXBResult(unmarshaller); } catch (JAXBException e) { throw new Docx4JException("Error preparing empty JAXB result", e); } return result; }
Unmarshaller u = jc.createUnmarshaller(); new StreamSource(new java.io.StringReader(str)), mcPreprocessorXslt, null, result); return result.getResult(); } catch (Exception e) { throw new JAXBException("Preprocessing exception", e);
public Word2003XmlConverter(Source source) throws JAXBException, Docx4JException { // Use 2003-import.xsl to convert to a Transition03To06 object java.lang.ClassLoader classLoader = Word2003XmlConverter.class.getClassLoader(); JAXBResult result = new JAXBResult( JAXBContext.newInstance("org.docx4j.convert.in.word2003xml", classLoader) ); XmlUtils.transform(source, xslt, null, result); // set the unmarshalled content tree transitionContainer = (Transition03To06)result.getResult(); }
JAXBResult result = new JAXBResult(Context.jc ); java.util.HashMap<String, Object> settings = new java.util.HashMap<String, Object>(); Object ddJaxb = result.getResult(); DiagramDataPart.setFriendlyIds(XmlUtils.unwrap(ddJaxb));
Marshaller marshaller=jc.createMarshaller(); org.w3c.dom.Document doc = org.docx4j.XmlUtils.neww3cDomDocument(); marshaller.marshal(pkg, doc); Unmarshaller u = jc.createUnmarshaller(); u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); javax.xml.bind.util.JAXBResult result = new javax.xml.bind.util.JAXBResult(u ); org.docx4j.xmlPackage.Package wmlPackageEl = (org.docx4j.xmlPackage.Package)XmlUtils.unwrap(result.getResult());
public void prepare(Path path) throws ValidatorException { try { transformer = transformerFactory.newTransformer(new StreamSource(Files.newInputStream(path))); jaxbResult = new JAXBResult(JAXBContext.newInstance(SchematronOutput.class)); } catch (Exception e) { throw new ValidatorException(e.getMessage(), e); } }
@Override public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException { JAXBResult out = new JAXBResult(unmarshaller); // since the bridge only produces fragments, we need to fire start/end document. try { out.getHandler().startDocument(); if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.TRUE); m.marshal(jaxbObject,out); } else bridge.marshal(jaxbObject,out); out.getHandler().endDocument(); } catch (SAXException e) { throw new JAXBException(e); } return (T)out.getResult(); }
public <T> T readAsJAXB(Unmarshaller unmarshaller) throws JAXBException { try { JAXBResult r = new JAXBResult(unmarshaller); // bridge marshals a fragment, so we need to add start/endDocument by ourselves r.getHandler().startDocument(); bridge.marshal(jaxbObject,r); r.getHandler().endDocument(); return (T)r.getResult(); } catch (SAXException e) { throw new JAXBException(e); } } /** @deprecated */
public void setJaxbElement(JAXBResult result) throws JAXBException { setJaxbElement((E)result.getResult()); }
Marshaller marshaller=jc.createMarshaller(); org.w3c.dom.Document doc = org.docx4j.XmlUtils.neww3cDomDocument(); marshaller.marshal(pkg, doc); Unmarshaller u = jc.createUnmarshaller(); u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); javax.xml.bind.util.JAXBResult result = new javax.xml.bind.util.JAXBResult(u ); org.docx4j.xmlPackage.Package wmlPackageEl = (org.docx4j.xmlPackage.Package)XmlUtils.unwrap(result.getResult());
public Word2003XmlConverter(Source source) throws JAXBException, Docx4JException { // Use 2003-import.xsl to convert to a Transition03To06 object java.lang.ClassLoader classLoader = Word2003XmlConverter.class.getClassLoader(); JAXBResult result = new JAXBResult( JAXBContext.newInstance("org.docx4j.convert.in.word2003xml", classLoader) ); XmlUtils.transform(source, xslt, null, result); // set the unmarshalled content tree transitionContainer = (Transition03To06)result.getResult(); }
@Override public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException { JAXBResult out = new JAXBResult(unmarshaller); // since the bridge only produces fragments, we need to fire start/end document. try { out.getHandler().startDocument(); if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.TRUE); m.marshal(jaxbObject,out); } else bridge.marshal(jaxbObject,out); out.getHandler().endDocument(); } catch (SAXException e) { throw new JAXBException(e); } return (T)out.getResult(); }
JAXBResult result = new JAXBResult(Context.jc ); java.util.HashMap<String, Object> settings = new java.util.HashMap<String, Object>(); Object ddJaxb = result.getResult(); DiagramDataPart.setFriendlyIds(XmlUtils.unwrap(ddJaxb));
public <T> T readAsJAXB(Unmarshaller unmarshaller) throws JAXBException { try { JAXBResult r = new JAXBResult(unmarshaller); // bridge marshals a fragment, so we need to add start/endDocument by ourselves r.getHandler().startDocument(); bridge.marshal(jaxbObject,r); r.getHandler().endDocument(); return (T)r.getResult(); } catch (SAXException e) { throw new JAXBException(e); } } /** @deprecated */
@Override public T getResult() { try { return (T) result.getResult(); } catch (JAXBException e) { throw new RuntimeException(e); } }
/** * Creates a new instance that uses the specified * JAXBContext to unmarshal. * * @param context The JAXBContext that will be used to create the * necessary Unmarshaller. This parameter must not be null. * @exception JAXBException if an error is encountered while creating the * JAXBResult or if the context parameter is null. */ public JAXBResult( JAXBContext context ) throws JAXBException { this( ( context == null ) ? assertionFailed() : context.createUnmarshaller() ); }
Unmarshaller u = jc.createUnmarshaller(); javax.xml.bind.util.JAXBResult result = new javax.xml.bind.util.JAXBResult(u ); org.docx4j.XmlUtils.transform(doc, xslt, transformParameters, result); part.setJaxbElement(result);
Unmarshaller u = jc.createUnmarshaller(); mcPreprocessorXslt, null, result); return //XmlUtils.unwrap( result.getResult() ; } catch (Exception e) { throw new JAXBException("Preprocessing exception", e);
import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.util.JAXBResult; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; public class Demo { public static void main(String[] args) throws Exception { TransformerFactory tf = TransformerFactory.newInstance(); File xsltFile = new File("transform.xsl"); StreamSource xsltSource = new StreamSource(xsltFile); Transformer transformer = tf.newTransformer(xsltSource); File xml = new File("input.xml"); StreamSource xmlSource = new StreamSource(xml); JAXBContext jc = JAXBContext.newInstance(Filter.class); JAXBResult jaxbResult = new JAXBResult(jc); transformer.transform(xmlSource, jaxbResult); Filter filter = (Filter) jaxbResult.getResult(); } }