zoukankan      html  css  js  c++  java
  • XML Publisher Using API’s(转)

    原文地址:XML Publisher Using API’s

    Applications Layer APIs
    The applications layer of XML Publisher allows you to store and manager data sources
    and templates through the Template Manager user interface via the XML Publisher
    Administrator responsibility. You can also access and manipulate these objects via an
    application program interfaces.


    Data sources and templates are stored in the database. This includes the metadata
    describing the object and the physical object itself (for example, an RTF file). Use these
    APIs to register, update, and retrieve information about datasources and templates. You
    can also call use the APIs to call XML Publisher to apply a template to a data source to
    generate output documents directly (without going through the concurrent manager).


    Datasource APIs
    The following APIs are provided to access and manipulate the data definitions
    programmatically:
    • DataSource Class
    The data source acts as a placeholder object against which you register templates. The
    DataSource class represents a single data source definition entry.
    • DataSourceHelper Class
    This is a utility class that can be used to manage data source definition entries in the
    Template Manager repository.


    Getting AppsContext
    All methods require the AppsContext instance to communicate with the Applications
    database like If you are using this class in a Java concurrent program, pass CpContext as an
    AppsContext.


    Creating Data Source Definition Entries
    Add a new data source definition entry to the Template Manager repository as follows:
    1. Create an instance of the DataSource class by calling the
    DataSource.createInstance() method.
    2. Set the attributes of the instance.
    3. Pass it to the DataSourceHelper.createDataSource()method.


    Adding, Updating, and Deleting Schema Files and Sample Files
    You can add, update and delete the data source schema definition file and the sample
    XML file by calling methods defined in the DataSourceHelper class. Please note that
    unlike the deleteDataSource() method described above, these methods actually
    delete the schema file and sample records from the repository.
    Example
    // Add a schema definition file
    DataSourceHelper.addSchemaFile(ctx, “XDO”, “TestDataSource”,
    “schema.xsd”, new FileInputStream(“/path/to/schema.xsd”));
    // Add a sample xml data file
    DataSourceHelper.addSampleFile(ctx, “XDO”, “TestDataSource”,
    “sample.xml”, new FileInputStream(“/path/to/sample.xml”));
    // Update a schema definition file
    DataSourceHelper.addSchemaFile(ctx, “XDO”, “TestDataSource”,
    new FileInputStream(“/path/to/new_schema.xsd”));
    // Update a sample xml data file
    DataSourceHelper.addSampleFile(ctx, “XDO”, “TestDataSource”,
    new FileInputStream(“/path/to/new_sample.xml”));
    // Delete a schema definition file
    DataSourceHelper.deleteSchemaFile(ctx, “XDO”, “TestDataSource”);
    // Delete a sample xml data file
    DataSourceHelper.deleteSampleFile(ctx, “XDO”, “TestDataSource”);


    Getting Schema Files and Sample Files from the Repository
    You can download schema files or sample files from the repository by calling the
    getSchemaFile() or the getSampleFile() method. These methods return an
    InputStream connected to the file contents as a return value.
    The sample code is as follows:
    Example
    // Download the schema definition file from the repository
    InputStream schemaFile = DataSourceHelper.getSchemaFile(ctx, “XDO”, “TestDataSource”, );
    // Download the XML sample data file from the repository
    InputStream sampleFile = DataSourceHelper.getSampleFile(ctx, “XDO”, “TestDataSource”, );


    Template APIs
    Multiple template objects can be associated with a single data source. The Template
    class represents a single template instance. The TemplateHelper class is a utility class
    used to create and update template objects in the Template Manager.


    The Template Class
    The Template class represents a single template object in the template manager. It is
    associated with a data source object. The class has several get and set methods to
    manipulate the template object.
    TemplateHelper Class
    The TemplateHelper class is a utility class to manage the template entries in the
    Template Manager repository. It consists of a set of static utility methods.


    Creating Template EntriesTo add a new template entry to the Template Manager repository:
    1. Create an instance of the Template class by calling the
    Template.createInstance() method
    2. Set the attributes of the instance.
    3. Pass it to the TemplateHelper.createTemplate() method
    Example
    // Create an instance
    Template t = Template.createInstance(appsContext, “XDO”,”TestTemplate”,
    TypeDefinitions.TEMPLATE_TYPE_PDF, “XDO”, “TestTemplate”);
    // Set properties
    t.setDescription(“This is the test template entry.”);
    t.setStartDate(new java.sql.Date(System.currentTimeMillis()));
    t.setName(“Test template !”);
    t.setStatus(TypeDefinitions.TEMPLATE_STATUS_ENABLED);
    // Call createTemplate() to create an entry into the repository
    TemplateHelper.createTemplate(am, t);


    Where am = oracle apps module.


    Adding, Updating, and Deleting Template Files
    You can add, update and delete template files by calling methods defined in the
    TemplateHelper class.


    Example
    // Add English template file to the template entry
    TemplateHelper.addTemplateFile(
    appsContext, // AppsContext
    “XDO”, // Application short name of the template
    “TestTemplate”, // Template code of the template
    “en”, // ISO language code of the template
    “US”, // ISO territory code of the template
    Template.TEMPLATE_TYPE_PDF, // Type of the template file
    “us.pdf”, // Filename of the template file
    new FileInputStream(“/path/to/us.pdf”)); // Template file


    // Add Japanese template file to the template entry
    TemplateHelper.addTemplateFile(
    appsContext, // AppsContext
    “XDO”, // Application short name of the template
    “TestTemplate”, // Template code of the template
    “ja”, // ISO language code of the template
    “JP”, // ISO territory code of the template
    Template.TEMPLATE_TYPE_PDF, // Type of the template file
    “ja.pdf”, // Filename of the template file
    new FileInputStream(“/path/to/ja.pdf”)); // Template file


    // Update English template file to the template entry
    TemplateHelper.updateTemplateFile(
    appsContext, // AppsContext
    “XDO”, // Application short name of the template
    “TestTemplate”, // Template code of the template
    “en”, // ISO language code of the template
    “US”, // ISO territory code of the template
    Template.TEMPLATE_TYPE_PDF, // Type of the template file
    “us.pdf”, // Filename of the template file
    new FileInputStream(“/path/to/new/us.pdf”)); // Template file


    // Delete Japanese template file to the template entry
    TemplateHelper.deleteTemplateFile(
    appsContext, // AppsContext
    “XDO”, // Application short name of the template
    “TestTemplate”, // Template code of the template
    “ja”, // ISO language code of the template
    “JP”); // ISO territory code of the template


    Getting Template FilesDownload template file contents from the repository by calling the getTemplateFile() methods. These methods return an InputStream connected to
    the template file as a return value.
    Example
    // Download the English template file from the repository
    InputStream in = TemplateHelper.getTemplateFile(
    appsContext, // AppsContext
    “XDO”, // Application short name of the template
    “TestTemplate”, // Template code of the template
    “en”, // ISO language code of the template
    “US”); // ISO territory code of the template


    Processing TemplatesYou can apply a template, stored in the Template Manager, to an XML data source by
    calling one of the processTemplate() methods. You need to pass the OutputStream
    object for the destination of the processed document.
    Example
    // Process template
    TemplateHelper.processTemplateFile(
    appsContext, // AppsContext
    “XDO”, // Application short name of the template
    “TestTemplate”, // Template code of the template
    “en”, // ISO language code of the template
    “US”, // ISO territory code of the template
    dataInputStream, // XML data for the template
    TemplateHelper.OUTPUT_TYPE_PDF, // Output type of the procesed
    document
    properties, // Properties for the template processing
    docOutputStream) // OutputStream where the processed document goes.

  • 相关阅读:
    课堂作业之公文流转
    统计字符出现频率(java)
    课堂测试第八周
    HTML学习笔记——语法+骨架
    HTTP协议
    MVC架构模式概述
    CodeIgniter框架——CI中视图路径问题
    CodeIgniter框架——CI组件间信息流走向
    CodeIgniter框架——数据库类(配置+快速入门)
    chm文件无法阅读
  • 原文地址:https://www.cnblogs.com/huanghongbo/p/4828121.html
Copyright © 2011-2022 走看看