当前位置: 首页>>代码示例>>Java>>正文


Java Marshaller.setSchema方法代码示例

本文整理汇总了Java中javax.xml.bind.Marshaller.setSchema方法的典型用法代码示例。如果您正苦于以下问题:Java Marshaller.setSchema方法的具体用法?Java Marshaller.setSchema怎么用?Java Marshaller.setSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.Marshaller的用法示例。


在下文中一共展示了Marshaller.setSchema方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toXML

import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
@Override
public String toXML(T obj) {

    try {
        JAXBContext context = JAXBContext.newInstance(type);

        Marshaller m = context.createMarshaller();
        if(schemaLocation != null) {
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

            StreamSource source = new StreamSource(getClass().getResourceAsStream(schemaLocation));
            Schema schema = schemaFactory.newSchema(source);
            m.setSchema(schema);
        }

        StringWriter writer = new StringWriter();

        m.marshal(obj, writer);
        String xml = writer.toString();

        return xml;
    } catch (Exception e) {
        System.out.println("ERROR: "+e.toString());
        return null;
    }
}
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:27,代码来源:ConverterImpl.java

示例2: saveDialogRoot

import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
public static void saveDialogRoot(File dialogFile, Level root) throws JAXBException, SAXException
{

    Marshaller marshaller = getJaxbContext().createMarshaller();
    marshaller.setSchema(getSchema());
    marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

    marshaller.marshal(root, dialogFile);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:11,代码来源:DialogDataHelper.java

示例3: saveTenants

import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
private void saveTenants(final Tenants tenants) throws JAXBException {
    final Marshaller marshaller = JAXB_TENANTS_CONTEXT.createMarshaller();
    marshaller.setSchema(tenantsSchema);
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(tenants, tenantsFile);
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:7,代码来源:FileUserGroupProvider.java

示例4: saveAuthorizations

import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
private void saveAuthorizations(final Authorizations authorizations) throws JAXBException {
    final Marshaller marshaller = JAXB_AUTHORIZATIONS_CONTEXT.createMarshaller();
    marshaller.setSchema(authorizationsSchema);
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(authorizations, authorizationsFile);
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:7,代码来源:FileAccessPolicyProvider.java


注:本文中的javax.xml.bind.Marshaller.setSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。