當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。