For C/C++ applications the eXtremeDB schema compiler option “–x” causes 
mcocomp to generate interface functions to retrieve, create and replace (update) 
the contents of an object with the content of an XML string. In addition to the 
common use of XML interfaces for porting data, these XML interface functions 
can be used, for instance, in concert with the eXtremeDB event notifications, to 
cause live data to be shared between eXtremeDB and other systems when an 
object of interest changes in the database.
The XML interfaces can also be used to facilitate simple schema evolution by 
exporting the database to XML, adding/dropping fields, indexes, and classes, and 
importing the saved XML into the new database.
XML export and import
The XML export and import functions are used in conjunction with user-defined 
file I/O helper functions to stream eXtremeDB database contents to and from 
persistent media files: 
MCO_RET mco_db_xml_export(mco_trans_h t, 
void* stream_handle, 
mco_stream_write output_stream_writer);
MCO_RET mco_db_xml_import(mco_trans_h t, 
void* stream_handle, 
mco_stream_read input_stream_reader);
When mco_db_xml_export() is called the internal runtime implementation calls 
the user-defined handler output_stream_writer to manage the output stream. 
And likewise mco_db_xml_import() causes the handler input_stream_reader
to be called. Simple file I/O handlers look like the following:
mco_size_sig_t file_writer(void* stream_handle /* FILE* */, 
const void* from, mco_size_t nbytes)
{
return (mco_size_t) fwrite(from, 1, nbytes, (FILE*) stream_handle);
}
mco_size_sig_t file_reader(void* stream_handle /* FILE* */, 
void* to, mco_size_t max_nbytes)
{
return (mco_size_t) fread(to, 1, max_nbytes, (FILE*) stream_handle);
}
Chapter 13 : eXtremeDB XML Interfaces
264    eXtremeDB User’s Guide
Function mco_db_xml_export() may be called within a READ_ONLY transaction 
but, as expected,  mco_db_xml_import() must be called within a READ_WRITE 
transaction. When importing data into an existing database, new data will be 
added into the database and no existing data will be lost.
mco_db_xml_import()calls the internal function mco_w_xml_create_object()
to create a new object in the database for each object loaded from the XML 
stream. Since the import procedure runs in the context of single transaction, there 
are only two possible results: either the whole data set will be imported 
successfully or no data will be imported. For example, if an object being imported 
creates a duplicate for any unique index, the entire transaction will be rolled back. 
It is necessary to explain how eXtremeDB handles unique identifiers, i.e. fields of 
the types oid, autoid and autooid. As explained above, the import procedure 
only creates new objects and never updates existing objects. So if a class contains 
an oid field, the oid value from the XML stream is used in the newly created 
object. Care must be taken to assure that imported oid values do not duplicate 
values in existing database objects.
In the case of “automatic id” fields of type autoid and autooid, the import 
procedure behaves according to the current XML policy settings. The policy 
switches ignore_autoid and ignore_autooid, when set to value MCO_YES,
cause the procedure to ignore values for fields of this type in the XML stream and 
mco_w_xml_create_object() will generate the id values for the newly created 
objects just as if they were created by calling the classname_new() function. 
The default setting of the XML policy is MCO_YES for both switches as the safest

setting to preserve database integrity

Policies:

typedef struct mco_xml_policy_t_ 
{
MCO_NUM_BASE int_base;
MCO_NUM_BASE quad_base;
MCO_TEXT_CODING text_coding;
MCO_TEXT_CODING blob_coding;
MCO_FLOAT_FORMAT float_format;
mco_bool indent; 
mco_bool ignore_field;  /* ignore field in xml that is not in 
* class */
mco_bool encode_spec;  /* encode chars with code < 32, except LF */
mco_bool encode_lf;  /* encode line feeds */
mco_bool encode_nat;  /* encode national chars (code > 127) */
mco_bool truncate_sp;  /* truncate trailing spaces in chars */
mco_bool use_xml_attrs; /* alternative XML representation, using */
/* attributes */
mco_bool ignore_autoid;  /* ignore autoid value in create operations */
mco_bool ignore_autooid; /* ignore auto_oid in create operations  */

mco_xml_policy_t;

The policy default values are set as follows:
static mco_xml_policy_t default_xml_policy = { 
MCO_NUM_DEC,  /* int_base is decimal */
MCO_NUM_HEX,  /* quad_base is hexadecimal   */
MCO_TEXT_ASCII,  /* text_coding (strings) are ASCII */
MCO_TEXT_BASE64,  /* blob_coding is Base64 */
MCO_FLOAT_EXPONENT, /* float_format is exponential */
MCO_YES,  /* text is indented */
MCO_NO,  /* all fields must be present in */
/* the incoming XML */
MCO_YES,  /* encode special chars (< 32) */
MCO_YES,  /* encode line feeds */
MCO_NO,   /* encode national chars (> 127) */
MCO_YES  /* truncate trailing spaces */
MCO_NO,  /* don't use attributes */
MCO_YES,  /* ignore autoid values in input */
MCO_YES    /* ignore autooid values in input */
};

eXtremeDB XML相关推荐

  1. eXtremeDb集成开发篇(Java)

    开发语言:Java 集成框架:Maven,Spring,Mybatis 1. 先新建spring框架(ssh或者用sprintboot随意,若无此基础,请先学习相应知识点) 2. resources下 ...

  2. extremedb同步mysql_eXtremeDB相关问题解答(2)

    1,Howto set the XML policy? 如何设置xml的策略? 参加下列各参数定义,下列的结果为默认设置 The policy switches ignore_autoid andig ...

  3. eXtremeDB相关问题解答(1)

    这些问题基于eXtremeDB 4.5 1776 1, Ifthe asynchonous event happened 100 times in a short period, would all ...

  4. 利用dom4j将实体类转换为对应的xml报文

    利用dom4j生成xml报文 目标格式: <?xml version="1.0" encoding="GBK"?><Packet type=& ...

  5. mybatis的资源过滤错误及xml文件编码错误

    mybatis 解决maven项目内资源过滤的问题 写的配置文件无法被导出或者生效的问题. 解决方案: <build><resources><resource>&l ...

  6. 【spring】spring基于xml的声明式事务控制

    结构 domain package com.itheima.domain;import java.io.Serializable;public class Account implements Ser ...

  7. 【Spring】基于xml实现事务控制(银行转账)

    代码结构 domain类 package com.itheima.domain;import java.io.Serializable;/*** 账户的实体类*/ public class Accou ...

  8. 【Spring】基于XML的IOC案例

    代码结构: bean.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&quo ...

  9. Python 标准库之 xml.etree.ElementTree xml解析

    Python 标准库之 xml.etree.ElementTree Python中有多种xml处理API,常用的有xml.dom.*模块.xml.sax.*模块.xml.parser.expat模块和 ...

最新文章

  1. 自建ES迁移至阿里云ES(使用脚本及logstash同步)
  2. python怎么用excel-如何用python打开excel
  3. 【SVM最后一课】详解烧脑的Support Vector Regression
  4. git@github.com: Permission denied (publickey).
  5. linux下msmtp+mutt+shell发送邮件
  6. IDEA配置好maven后新建maven项目一直build失败的解决方法
  7. js几种生成随机颜色方法
  8. KM算法(最优匹配)
  9. 中国农田生产潜力数据集
  10. [2018.05.05 T2] 互质2
  11. Avesta飞秒光纤激光器
  12. CO-PA: 获利能力分析数据的传送(月末业务)
  13. mysql 1236 bug_【转】MySQL主从失败 错误Got fatal error 1236解决方法
  14. 为什么app会被常常攻击?如何预防攻击?
  15. 【Java学习之代码学习】 Prog28_打印出杨辉三角形的问题
  16. mtk插u盘如何休眠?_iOS13.3.1 U盘越狱卡代码问题,你也是吗?
  17. 千锋教育+计算机四级网络-计算机网络学习-02
  18. 做了6年的小猎头跟大家分享工作经验
  19. 为何安装MySQL后每天会有cmd弹窗
  20. VSCode 安装教程(超详细)

热门文章

  1. 第二语言习得实践方法
  2. Kali Linux 内核头文件安装
  3. Android 实现抖音头像底部弹框效果
  4. 穷举最小公倍数c语言,c语言求最大公约数和最小公倍数
  5. 未来计算机手机化,未来10年手机和电脑的竞争力
  6. 下载!闲鱼最新升级版 Flutter 技术电子书!
  7. golang 向上取整小技巧
  8. Linux系统中ls命令用法详解
  9. nginx配置文件 配置 多项目访问80端口
  10. 【C语言I博客作业09】