Java 类javax.xml.bind.util.JAXBSource 实例源码

项目:OpenDiabetes    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implementation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attributes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw JDBCUtil.invalidArgument("sourceClass: " + sourceClass);
}
项目:sstore-soft    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implmentation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attrbutes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw Util.invalidArgument("sourceClass: " + sourceClass);
}
项目:s-store    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implmentation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attrbutes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw Util.invalidArgument("sourceClass: " + sourceClass);
}
项目:dev-courses    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implmentation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attrbutes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw JDBCUtil.invalidArgument("sourceClass: " + sourceClass);
}
项目:mycore    文件:MCRUserResolver.java   
@Override
public Source resolve(String href, String base) throws TransformerException {
    String[] hrefParts = href.split(":");
    String userID = hrefParts[1];
    MCRUser user = null;
    try {
        if ("current".equals(userID)) {
            user = MCRUserManager.getCurrentUser();
        } else if ("getOwnedUsers".equals(userID)) {
            return getOwnedUsers(hrefParts[2]);
        } else {
            user = MCRUserManager.getUser(userID);
        }
        if (user == null) {
            return null;
        }
        return new JAXBSource(MCRUserTransformer.JAXB_CONTEXT, user.getSafeCopy());
    } catch (JAXBException e) {
        throw new TransformerException(e);
    }
}
项目:imf-conversion    文件:TtmlParagraphResolver.java   
private static <T> T deepCopy(T object, Class<T> clazz, String packages) {
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(packages);

        //  create marshaller which disable validation step
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setEventHandler(event -> true);

        //  create unmarshaller which disable validation step
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        unmarshaller.setEventHandler(event -> true);

        JAXBElement<T> contentObject = new JAXBElement<>(new QName(clazz.getName()), clazz, object);
        return unmarshaller.unmarshal(new JAXBSource(marshaller, contentObject), clazz).getValue();
    } catch (JAXBException e) {
        throw new ParseException("Time overlaps in <p> cannot be resolved.", e);
    }
}
项目:imf-conversion    文件:TtmlUtils.java   
/**
 * Does TTML document transformation to another TTML document.
 *
 * @param tt          source TTML document root element
 * @param transformer transformer
 * @return TTML document after transformation
 */
public static TtEltype transformTtmlDocument(TtEltype tt, Transformer transformer) {
    JAXBElement<TtEltype> ttJaxb = new ObjectFactory().createTt(tt);
    try {
        JAXBContext jaxbc = createTtmlJaxbContext();
        JAXBSource source = new JAXBSource(jaxbc, ttJaxb);
        JAXBResult result = new JAXBResult(jaxbc);

        // transform
        transformer.transform(source, result);

        return (TtEltype) ((JAXBElement<TtEltype>) result.getResult()).getValue();
    } catch (JAXBException | TransformerException e) {
        throw new ConvertException(e);
    }
}
项目:VoltDB    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implmentation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attrbutes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw Util.invalidArgument("sourceClass: " + sourceClass);
}
项目:proarc    文件:DcStreamEditor.java   
@Deprecated
public void write(DigitalObjectHandler handler, ModsDefinition mods, String model, long timestamp, String message) throws DigitalObjectException {
    try {
        JAXBSource jaxbSource = new JAXBSource(ModsUtils.defaultMarshaller(false),
                new cz.cas.lib.proarc.mods.ObjectFactory().createMods(mods));
        // DO NOT include schemaLocation. Fedora validator does not accept it.
        Transformer t = DcUtils.modsTransformer(model);
        EditorResult result = editor.createResult();
        JAXBResult jaxbResult = new JAXBResult(DcUtils.defaultUnmarshaller());
        t.transform(jaxbSource, jaxbResult);
        JAXBElement<OaiDcType> elm = (JAXBElement<OaiDcType>) jaxbResult.getResult();
        OaiDcType dc = elm.getValue();
        addDigitalObjectMetadata(handler, dc);
        DcUtils.marshal(result, dc, false);
        editor.write(result, timestamp, message);
    } catch (TransformerException | JAXBException ex) {
        throw new DigitalObjectException(object.getPid(), ex);
    }
}
项目:proarc    文件:DcStreamEditorTest.java   
@Test
public void testTransformation() throws Exception {
    ModsDefinition mods = ModsUtils.unmarshalModsType(new StreamSource(DcStreamEditorTest.class.getResource("periodical.xml").toExternalForm()));
    Transformer t = DcUtils.modsTransformer("model:periodical");
    JAXBSource jaxbSource = new JAXBSource(ModsUtils.defaultMarshaller(false),
            new ObjectFactory().createMods(mods));
    StringWriter dump = new StringWriter();
    t.transform(jaxbSource, new StreamResult(dump));
    String toXml = dump.toString();
    System.out.println(toXml);

    HashMap<String, String> namespaces = new HashMap<String, String>();
    namespaces.put("oai_dc", DcStreamEditor.DATASTREAM_FORMAT_URI);
    namespaces.put("dc", "http://purl.org/dc/elements/1.1/");
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='main']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='key']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:title[text()='alternative']", toXml);
    XMLAssert.assertXpathEvaluatesTo("3", "count(/oai_dc:dc/dc:title)", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:creator[text()='Boleslav']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:description[text()='poznámka']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='uuid:40d13cb2-811f-468c-a6d3-1ad6b01f06f7']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='isbn:0eaa6730']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='issn-l:idIssn-l']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='idWitEmptyType']", toXml);
    XMLAssert.assertXpathExists("/oai_dc:dc/dc:identifier[text()='idWithoutType']", toXml);
    // XXX needs more test
}
项目:jbossws-cxf    文件:ProviderBeanJAXB.java   
public Source invoke(Source request)
{
   try
   {
      JAXBContext jc = JAXBContext.newInstance(new Class[] { UserType.class });
      UserType user = (UserType)jc.createUnmarshaller().unmarshal(request);

      log.info("[string=" + user.getString() + ",qname=" + user.getQname() + "]");

      return new JAXBSource(jc, user);
   }
   catch (RuntimeException rte)
   {
      throw rte;
   }
   catch (Exception e)
   {
      throw new WebServiceException(e);
   }
}
项目:jbossws-cxf    文件:ProviderBeanJAXB.java   
public Source invoke(Source request)
{
   try
   {
      JAXBContext jc = JAXBContext.newInstance(new Class[] { UserType.class });
      UserType user = (UserType)jc.createUnmarshaller().unmarshal(request);

      log.info("[string=" + user.getString() + ",qname=" + user.getQname() + "]");

      return new JAXBSource(jc, user);
   }
   catch (RuntimeException rte)
   {
      throw rte;
   }
   catch (Exception e)
   {
      throw new WebServiceException(e);
   }
}
项目:Tournament    文件:XSLTRenderer.java   
/**
 * Render a jaxbElement with given xslt resource and
 * @param writer write result to this writer
 * @param jaxbModel date to render
 * @param stylesheet xslt stylesheet resource
 * @param parameters parameter for style sheet, like localizer, uriInfo (depends on stylesheet)
 * @throws IOException
 */
public void render(Writer writer, Object jaxbModel, String stylesheet, Map<String, Object> parameters) throws IOException
{
    try
    {
        // Create Transformer
        Transformer transformer = transformerFactory.newTransformer(getStreamSource(stylesheet));
        for(Entry<String, Object> entry : parameters.entrySet())
        {
            transformer.setParameter(entry.getKey(), entry.getValue());
        }
        // Source
        JAXBContext jc = JAXBContext.newInstance(jaxbModel.getClass());

        // Transform
        transformer.transform(new JAXBSource(jc, jaxbModel), new StreamResult(writer));
    }
    catch(JAXBException | TransformerException e)
    {
        throw new IOException("Can't process stylesheet: " + stylesheet, e);
    }
}
项目:Pegasus    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implmentation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attrbutes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw Util.invalidArgument("sourceClass: " + sourceClass);
}
项目:wso2-axis2    文件:SourceBlockImpl.java   
/**
 * Constructor called from factory
 *
 * @param busObject
 * @param qName
 * @param factory
 */
SourceBlockImpl(Source busObject, QName qName, BlockFactory factory)
        throws WebServiceException {
    super(busObject, null, qName, factory);

    // Check validity of Source
    if (busObject instanceof DOMSource ||
            busObject instanceof SAXSource ||
            busObject instanceof StreamSource ||
            (busObject.getClass().equals(staxSource)) ||
            busObject instanceof JAXBSource) {
        // Okay, these are supported Source objects
        if (log.isDebugEnabled()) {
            log.debug("data object is a " + busObject.getClass().getName());
        }
    } else {
        throw ExceptionFactory.makeWebServiceException(
                Messages.getMessage("SourceNotSupported", busObject.getClass().getName()));
    }
}
项目:StoryBear    文件:JDBCSQLXML.java   
/**
 * Returns a Source for reading the XML value designated by this SQLXML
 * instance. <p>
 *
 * @param sourceClass The class of the source, or null.  If null, then a
 *      DOMSource is returned.
 * @return a Source for reading the XML value.
 * @throws SQLException if there is an error processing the XML value
 *   or if the given <tt>sourceClass</tt> is not supported.
 */
protected <T extends Source>T getSourceImpl(
        Class<T> sourceClass) throws SQLException {

    if (JAXBSource.class.isAssignableFrom(sourceClass)) {

        // Must go first presently, since JAXBSource extends SAXSource
        // (purely as an implmentation detail) and it's not possible
        // to instantiate a valid JAXBSource with a Zero-Args
        // constructor(or any subclass thereof, due to the finality of
        // its private marshaller and context object attrbutes)
        // FALL THROUGH... will throw an exception
    } else if (StreamSource.class.isAssignableFrom(sourceClass)) {
        return createStreamSource(sourceClass);
    } else if ((sourceClass == null)
               || DOMSource.class.isAssignableFrom(sourceClass)) {
        return createDOMSource(sourceClass);
    } else if (SAXSource.class.isAssignableFrom(sourceClass)) {
        return createSAXSource(sourceClass);
    } else if (StAXSource.class.isAssignableFrom(sourceClass)) {
        return createStAXSource(sourceClass);
    }

    throw JDBCUtil.invalidArgument("sourceClass: " + sourceClass);
}
项目:halite    文件:OutputTransformMessageBodyWriter.java   
@Override
public void writeTo(
        final Resource paramT,
        final Class<?> paramClass,
        final Type paramType,
        final Annotation[] paramArrayOfAnnotation,
        final MediaType paramMediaType,
        final MultivaluedMap<String, Object> paramMultivaluedMap,
        final OutputStream paramOutputStream)
        throws IOException, WebApplicationException {

    try {
        final Source input = new JAXBSource(newJAXBContext(), paramT);
        final Result result = new StreamResult(paramOutputStream);
        this.transformer.transform(input, result);
    } catch (JAXBException | TransformerException e) {
        LOG.error("Could not produce result", e);
    }

}
项目:xmlunit    文件:JaxbBuilder.java   
@Override
public Source build() {
    try {
        if (marshaller == null) {
            createDefaultMarshaller();
        }

        final Object jaxbObject = getPreparedJaxbObject();
        final JAXBSource jaxbSource = new JAXBSource(marshaller, jaxbObject);
        // the fake InputSource cannot be used (the Convert.java
        // will create a working one if it is null)
        jaxbSource.setInputSource(null);
        return jaxbSource;
    } catch (final JAXBException e) {
        throw new DataBindingException(e);
    }
}
项目:edct-formbuilder    文件:ExportToExcel.java   
@Test
public void export() throws JAXBException, TransformerException
{
    JAXBContext jc = JAXBContext.newInstance("com.healthcit.cacure.export.model");
    File iFile = new File("C:\\temp\\moduleTest1.xml");
    //File iFile = new File("C:\\temp\\formExportTest.xml");
    //File iFile = new File("C:\\temp\\section1.1.xml");
    //File iFile = new File("C:\\temp\\complexSkip2.xml");
    //File iFile = new File("C:\\temp\\section3.1.xml");
    File oFile = new File("C:\\temp\\Book2.xml");
    Unmarshaller m = jc.createUnmarshaller();
    Cure xml = (Cure)m.unmarshal(iFile);
    StreamSource xslSource = new StreamSource("src//main//resources//xls.xsl");
    //long formId = 9979;

    //Cure xml = dataExporter.constructFormXML(formId);
    JAXBSource xmlSource = new JAXBSource(jc, xml);
    Transformer transformer = TransformerFactory.newInstance().newTransformer(xslSource);
    transformer.transform(xmlSource,new StreamResult(oFile));
}
项目:fluentxml4j    文件:JaxbUtils.java   
public static JAXBSource newJAXBSource(JAXBContext jaxbContext, Object object)
{
    try
    {
        return new JAXBSource(jaxbContext, object);
    }
    catch (JAXBException ex)
    {
        throw new FluentXmlProcessingException(ex);
    }
}
项目:OpenJSharp    文件:LogicalMessageImpl.java   
@Override
public Source getPayload() {
    JAXBContext context = ctxt;
    if (context == null) {
        context = defaultJaxbContext.getJAXBContext();
    }
    try {
        return new JAXBSource(context, o);
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
项目:openjdk-jdk10    文件:LogicalMessageImpl.java   
@Override
public Source getPayload() {
    JAXBContext context = ctxt;
    if (context == null) {
        context = defaultJaxbContext.getJAXBContext();
    }
    try {
        return new JAXBSource(context, o);
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
项目:openjdk9    文件:LogicalMessageImpl.java   
@Override
public Source getPayload() {
    JAXBContext context = ctxt;
    if (context == null) {
        context = defaultJaxbContext.getJAXBContext();
    }
    try {
        return new JAXBSource(context, o);
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
项目:mycore    文件:MCRUserResolver.java   
private Source getOwnedUsers(String userName) throws JAXBException {
    MCRUser owner = MCRUserManager.getUser(userName);
    List<MCRUser> listUsers = MCRUserManager.listUsers(owner);
    MCROwns mcrOwns = new MCROwns();
    int userCount = listUsers.size();
    mcrOwns.users = new MCRUser[userCount];
    for (int i = 0; i < userCount; i++) {
        mcrOwns.users[i] = listUsers.get(i).getBasicCopy();
    }
    return new JAXBSource(MCRUserTransformer.JAXB_CONTEXT, mcrOwns);
}
项目:mycore    文件:MCRJAXBContent.java   
@Override
public Source getSource() throws IOException {
    try {
        Marshaller marshaller = getMarshaller();
        return new JAXBSource(marshaller, jaxbObject);
    } catch (JAXBException e) {
        throw new IOException(e);
    }
}
项目:restlet-framework    文件:JaxbRepresentation.java   
/**
 * Returns a JAXB SAX source.
 *
 * @return A JAXB SAX source.
 */
public JAXBSource getJaxbSource() throws IOException {
    try {
        return new JAXBSource(getContext(), getObject());
    } catch (JAXBException e) {
        throw new IOException(
                "JAXBException while creating the JAXBSource: "
                        + e.getMessage());
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:LogicalMessageImpl.java   
@Override
public Source getPayload() {
    JAXBContext context = ctxt;
    if (context == null) {
        context = defaultJaxbContext.getJAXBContext();
    }
    try {
        return new JAXBSource(context, o);
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
项目:imf-conversion    文件:MetadataXmlProvider.java   
/**
 * Transform metadata.xml into a set of parameter files for BMXLib tool.
 * The parameter files are created within the provided working directory.
 */
public void createBmxDppParameterFiles() {
    JAXBSource source = dppToJaxbSource(dpp);

    bmxDppParameters = new HashMap<>();
    bmxDppParameters.put(DMFramework.UKDPP, createBmxFrameworkParameterFile(source, DMFramework.UKDPP, workingDir));
    bmxDppParameters.put(DMFramework.AS11CORE, createBmxFrameworkParameterFile(source, DMFramework.AS11CORE, workingDir));
    bmxDppParameters.put(DMFramework.AS11Segmentation, createBmxFrameworkParameterFile(
            source, DMFramework.AS11Segmentation, workingDir));
}
项目:imf-conversion    文件:MetadataXmlProvider.java   
private JAXBSource dppToJaxbSource(DppType dpp) {
    try {
        JAXBElement<DppType> dppJaxb = new ObjectFactory().createDpp(dpp);
        return new JAXBSource(JAXBContext.newInstance(METADATA_PACKAGE), dppJaxb);
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}
项目:incubator-openaz    文件:XACMLObjectCopy.java   
static public <T> T deepCopy(T object) {
    if (object == null)
        return null;

    try {
        @SuppressWarnings("unchecked")
        Class<T> clazz = (Class<T>)object.getClass();
        JAXBContext context = JAXBContext.newInstance(clazz);
        JAXBElement<T> contentObject = new JAXBElement<T>(new QName(clazz.getSimpleName()), clazz, object);
        JAXBSource source = new JAXBSource(context, contentObject);
        return context.createUnmarshaller().unmarshal(source, clazz).getValue();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}
项目:jbossws-cxf    文件:ProviderImpl.java   
public Source invoke(final Source request)
{
   try
   {
      JAXBContext jc = JAXBContext.newInstance(UserType.class);
      UserType user = (UserType)jc.createUnmarshaller().unmarshal(request);
      System.out.println("[string=" + user.getString() + ",qname=" + user.getQname() + "]");
      return new JAXBSource(jc, user);
   }
   catch (JAXBException e)
   {
      throw new WebServiceException(e);
   }
}
项目:infobip-open-jdk-8    文件:LogicalMessageImpl.java   
@Override
public Source getPayload() {
    JAXBContext context = ctxt;
    if (context == null) {
        context = defaultJaxbContext.getJAXBContext();
    }
    try {
        return new JAXBSource(context, o);
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
项目:opencfdi-api    文件:CFDv3.java   
public void validar(ErrorHandler handler) throws Exception {
  SchemaFactory sf =
    SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Source[] schemas = new Source[] {
    new StreamSource(getClass().getResourceAsStream(XSD)),
    new StreamSource(getClass().getResourceAsStream(XSD_TFD))  
  };
  Schema schema = sf.newSchema(schemas);
  Validator validator = schema.newValidator();
  if (handler != null) {
    validator.setErrorHandler(handler);
  }
  validator.validate(new JAXBSource(context, document));
}
项目:opencfdi-api    文件:CFDv3.java   
byte[] getOriginalBytes() throws Exception {
  JAXBSource in = new JAXBSource(context, document);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Result out = new StreamResult(baos);
  TransformerFactory factory = tf;
  if (factory == null) {
    factory = TransformerFactory.newInstance();
    factory.setURIResolver(new URIResolverImpl());
  }     
  Transformer transformer = factory
    .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
  transformer.transform(in, out);
  return baos.toByteArray();
}
项目:opencfdi-api    文件:CFDv32.java   
public void validar(ErrorHandler handler) throws Exception {
  SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  sf.setResourceResolver(new ResourceResolver());
  Source schemaFile = new StreamSource(getClass().getResourceAsStream("/xsd/v32/cfdv32.xsd"));
  Schema schemas = sf.newSchema(schemaFile);
  Validator validator = schemas.newValidator();
  if (handler != null) {
    validator.setErrorHandler(handler);
  }
  validator.validate(new JAXBSource(context, document));
}
项目:opencfdi-api    文件:CFDv32.java   
byte[] getOriginalBytes() throws Exception {
  JAXBSource in = new JAXBSource(context, document);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Result out = new StreamResult(baos);
  TransformerFactory factory = tf;
  if (factory == null) {
    factory = TransformerFactory.newInstance();
    factory.setURIResolver(new URIResolverImpl());
  }     
  Transformer transformer = factory
    .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
  transformer.transform(in, out);
  return baos.toByteArray();
}
项目:opencfdi-api    文件:TFDv1.java   
public void validar(ErrorHandler handler) throws Exception {
  SchemaFactory sf =
    SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Schema schema = sf.newSchema(getClass().getResource(XSD));
  Validator validator = schema.newValidator();
  if (handler != null) {
    validator.setErrorHandler(handler);
  }
  validator.validate(new JAXBSource(CONTEXT, tfd));
}
项目:opencfdi-api    文件:TFDv1.java   
byte[] getOriginalBytes() throws Exception {
  JAXBSource in = new JAXBSource(CONTEXT, tfd);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Result out = new StreamResult(baos);
  TransformerFactory factory = tf;
  if (factory == null) {
    factory = TransformerFactory.newInstance();
  } 
  Transformer transformer = factory
    .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
  transformer.transform(in, out);
  return baos.toByteArray();
}
项目:opencfdi-api    文件:TFDv1c32.java   
public void validar(ErrorHandler handler) throws Exception {
  SchemaFactory sf =
    SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Schema schema = sf.newSchema(getClass().getResource(XSD));
  Validator validator = schema.newValidator();
  if (handler != null) {
    validator.setErrorHandler(handler);
  }
  validator.validate(new JAXBSource(CONTEXT, tfd));
}
项目:opencfdi-api    文件:TFDv1c32.java   
byte[] getOriginalBytes() throws Exception {
  JAXBSource in = new JAXBSource(CONTEXT, tfd);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Result out = new StreamResult(baos);
  TransformerFactory factory = tf;
  if (factory == null) {
    factory = TransformerFactory.newInstance();
  } 
  Transformer transformer = factory
    .newTransformer(new StreamSource(getClass().getResourceAsStream(XSLT)));
  transformer.transform(in, out);
  return baos.toByteArray();
}