怎样用Google APIs和Google的应用系统进行集成(5)----怎样把Google Tasks的JSON Schema转换成XML的Schema(XSD)?
前面说了一些Google API的介绍,可是在实际的开发其中,我们可能须要把Google RESTful API返回的JSON数据转换成XML数据输入到第三方系统,这在企业应用集成里面很的常见。
那么里面就有一个问题,怎样确保转换后的XML数据格式是规范的。这就须要XML Schema(XML)来进行校验。如今关键是,我们仅仅知道Google API的JSON的schema,可是Google RESTful并没有提供返回数据的XML的schema。那么XML的Schema将会是什么样子的呢?让我以Google
Tasks API为样例。
从以下的URL我们能够看到Google Tasks RESTFul的API JSON Schema的信息:https://www.googleapis.com/discovery/v1/apis/tasks/v1/rest
那么。怎样把Google Tasks的JSON Schema转换成XML的XSD Schema?XML的Schema将会是什么样子的呢?请參考以下转换实现。
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Task">
<xs:sequence>
<xs:element name="completed" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="deleted" form="unqualified" type="xs:boolean" minOccurs="0"/>
<xs:element name="due" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="etag" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="hidden" form="unqualified" type="xs:boolean" minOccurs="0"/>
<xs:element name="id" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="kind" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="links" form="unqualified" type="Tasklinks" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="notes" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="parent" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="position" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="selfLink" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="status" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="title" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="updated" form="unqualified" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TaskList">
<xs:sequence>
<xs:element name="etag" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="id" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="kind" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="selfLink" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="title" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="updated" form="unqualified" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TaskLists">
<xs:sequence>
<xs:element name="etag" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="items" form="unqualified" type="TaskList" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="kind" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="nextPageToken" form="unqualified" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Taskitems">
<xs:sequence>
<xs:element name="description" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="link" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="type" form="unqualified" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Tasklinks">
<xs:sequence>
<xs:element name="items" form="unqualified" type="Taskitems" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Tasks">
<xs:sequence>
<xs:element name="etag" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="items" form="unqualified" type="Task" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="kind" form="unqualified" type="xs:string" minOccurs="0"/>
<xs:element name="nextPageToken" form="unqualified" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Task" type="Task"/>
<xs:element name="TaskList" type="TaskList"/>
<xs:element name="TaskLists" type="TaskLists"/>
<xs:element name="Tasks" type="Tasks"/>
</xs:schema>
怎样用Google APIs和Google的应用系统进行集成(5)----怎样把Google Tasks的JSON Schema转换成XML的Schema(XSD)?的更多相关文章
- 怎样用Google APIs和Google的应用系统进行集成(8)----怎样把Google Blogger(博客)的JSON Schema转换成XML的Schema(XSD)?
在Google RESTFul API中,Google Blogger API(Google博客API)应该和我们的生活离得近期:由于差点儿非常多人每天都在看博客,都在写博客,都听说过博客.在前面的G ...
- 怎样用Google APIs和Google的应用系统进行集成(4)----获得Access Token以通过一些Google APIs的OAuth2认证
在上篇文章中: "怎样用Google APIs和Google的应用系统进行集成(3)----调用发现Google APIs的RESTful的服务"一文中,我们直接用jdk的java ...
- GPS模块输出的NMEA数据ddmm.mmmm转换成dd.ddddd并在google Earth Pro中描点
GPS模块输出的数据是NMEA格式,其中GPGGA字段包含我们需要的经纬度信息. 例:$GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,12 ...
- 谷歌正式发布Google APIs Client Library for .NET
好消息,特大好消息! 英文原文:Google API library for .NET paves the way for Google services on Windows phone 本月 17 ...
- Android SDK Manager Google Apis 下载
本意是想利用google的gcm来实装android推送功能的,很遗憾, google貌似已经停止提供啥服务给国内了,或者说国内想继续使用google 服务暂时变得几乎不可能了.找了个代理来进行goo ...
- 怎样用Google APIs和Google的应用系统进行集成(3)----调用Google 发现(Discovery)API的RESTful服务
说了这么多,那么首先同意我以Google Discovery RESTful服务为例,给大家演示怎样用最普通的Java代码调用Google Discovery RESTful服务. 引言: 在&quo ...
- 怎样用Google APIs和Google的应用系统进行集成(1)----Google APIs简介
Google的应用系统提供了非常多的应用,比方 Google广告.Google 任务,Google 日历.Google blogger,Google Plus,Google 地图等等非常的多的应用,请 ...
- 如何使用Google APIs和Google应用系统集成(7)----在里面JSON兑换XML数据处理,JSON数据包括违规XML数据规范:XML节点名称不支持号码Java解
笔者电话Google Calendar APIs的GetColors方法,其中(有关详细信息Google Calendar API已经Google API看到我的博文介绍的其余部分,目前,我们只取Go ...
- 怎样用Google APIs和Google的应用系统进行集成(2)----Google APIs的全部的RESTFul服务一览
上篇文章,我提到了,Google APIs暴露了86种不同种类和版本号的API.我们能够通过在浏览器里面输入https://www.googleapis.com/discovery/v1/apis这个 ...
随机推荐
- (转)Android项目重构之路:实现篇
前两篇文章Android项目重构之路:架构篇和Android项目重构之路:界面篇已经讲了我的项目开始搭建时的架构设计和界面设计,这篇就讲讲具体怎么实现的,以实现最小化可用产品(MVP)的目标,用最简单 ...
- 往aws中的s3上传数据
在官网下载对应的sdk http://aws.amazon.com/cn/sdk-for-net/ 然后再aws上为s3上的bucket生成密钥对 access_key和secret_key 调用对应 ...
- 使用Sublime经验分享
Sublime轻量级.可是绝对是神一样的编辑器. 1.代码清晰美观 2.能够选择文件夹作为文件结构文件夹显示在左側 3.以tab的形式打开多个页面在同一个窗体内 设置方法例如以下: Preferenc ...
- C# socket 编程入门
http://www.cnblogs.com/chenxizhang/archive/2011/09/10/2172994.html
- 算法笔记_071:SPFA算法简单介绍(Java)
目录 1 问题描述 2 解决方案 2.1 具体编码 1 问题描述 何为spfa(Shortest Path Faster Algorithm)算法? spfa算法功能:给定一个加权连通图,选取一个 ...
- CVTE电话面试
Cvte电话面试 1. SVM和逻辑回归的相同不同点 2. 特征值和奇异值的区别 3. 如何找到全局最优解,梯度下降和牛顿法区别 4. 防止过拟合的方法 5. 随机森林和ADBOOST方差和偏置 6. ...
- 用Web API Client 调用 Web API
安装Web API客户端库 右键单击项目,选择管理 NuGet程序包,选择联机选项,选择全部,在搜索框中输入“Microsoft.AspNet.WebApi.Client”, 搜索结果就是要安装的类库 ...
- Android数据格式解析对象JSON用法
1.JSON概念: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性,从而可以在不同平台间进行数据交换.JSON采用兼容性很高的文本格式,同时也具备类似于C语言体系的行为. JSON可以将 ...
- js操作注意事项
1.函数赋值给变量时,不能加括号 function fun() { ... } var str=fun; 2.js创建构造函数和调用对象,对象内不能用var 变量,只能用this function f ...
- Linux I/O复用中select poll epoll模型的介绍及其优缺点的比較
关于I/O多路复用: I/O多路复用(又被称为"事件驱动"),首先要理解的是.操作系统为你提供了一个功能.当你的某个socket可读或者可写的时候.它能够给你一个通知.这样当配合非 ...