eXtremeDB XML[通俗易懂]

eXtremeDB XML[通俗易懂]ForC/C++applicationstheeXtremeDBschemacompileroption“–x”causes mcocomptogenerateinterfacefunctionstoretrieve,createandreplace(update) thecontentsofanobjectwiththecontent


Jetbrains全系列IDE稳定放心使用
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 */
};

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/182063.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长

相关推荐

  • 新建移动apn让网速变快(移动apn接入点哪个快)

    4G网络可以给我们带来畅快的网速体验,其实我们目前使用的LTE网络根据网速还分为多个标准,标准对4G网络的支持也不太一样,但是有时我们任然可以感觉到在有4G基站的地方上网网速也不是那么的满意,这是怎么回事儿呢?TD-LTE和FDD-LTE尽管被宣传为4G无线标准,但它其实并未被3GPP认可为国际电信联盟所描述的下一代无线通讯标准IMT-Advanced,因此在严格意义上其还未达到4G的标准。APN…

    2022年4月12日
  • 测试一下博客行吗

    测试一下博客行吗;;;;;;;;;——————-iK7VUYG0yF6lS3QNNmW4Gw==tRymiHsi9AbKpr3tTFXxup1GFhuX0czs73gSv/E7b5c=uk29oXxJxAg+D0WGWLg/LaJ5+a4y4SSHbrMB4JywbGg=eIWSkIow/vo+D0WGWLg/LaJ5+a4y4SSHbrMB4JywbGg=pcL609

    2022年7月11日
  • perl 正则表达式 匹配字符串 或逻辑

    perl 正则表达式 匹配字符串 或逻辑mark,备忘#!/usr/local/bin/perlusestrict;usewarnings;my@data=qw(nihaowohao);foreach(@data){if($_=~/^(ni|wo)hao$/){print$_}}

    2022年5月18日
  • 51单片机最小系统原理图、PCB及组成原理详解「建议收藏」

    51单片机最小系统原理图、PCB及组成原理详解「建议收藏」单片机:单片机(Microcontrollers)是一种集成电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU、随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计数器等功能(可能还包括显示驱动电路、脉宽调制电路、模拟多路转换器、A/D转换器等电路)集成到一块硅片上构成的一个小而完善的微型计算机系统,在工业控制领域广泛应用。先上原理图和PCB,原理介绍…

    2022年6月2日
  • Java基础学习教程,eclipse简单使用教程(Java集成开发工具)

    Java基础学习教程,eclipse简单使用教程(Java集成开发工具)使用集成开发工具eclipse1、java的集成开发工具很多,包括:eclipse、IntellijIDEA、netbeans….. eclipse: IBM开发的。eclipse翻译为:日食。寓意吞并SUN公司(SUN是太阳。)最终没有成功,SUN公司在2009年的时候被oracle甲骨文公司收购。eclipse在以前的开发中使用非常多,但是由于IDEA工具的出现,让eclipse的用户大大减少,目前eclipse占市场份额30%。IDEA占市场份额60%,剩下10%是其他的开

    2022年6月28日
  • 矩阵行列式的几何意义是什么_矩阵的几何意义和物理意义

    矩阵行列式的几何意义是什么_矩阵的几何意义和物理意义矩阵行列式的几何意义 行列式的定义: 行列式是由一些数据排列成的方阵经过规定的计算方法而得到的一个数。当然,如果行列式中含有未知数,那么行列式就是一个多项式。它本质上代表一个数值,这点请与矩阵区别开来。矩阵只是一个数表,行列式还要对这个数表按照规则进一步计算,最终得到一个实数、复数或者多项式。 一阶行列式 (注意不是绝对值) …

    2022年10月30日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号