怎样用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这个 ...
随机推荐
- Linux 进程学习
1.linux进程间通讯 继承unix进程间通讯:管道 信号 AT&T :system V IPC 通讯进程只能在单个计算机 :信号量 消息队列 共享内存 ...
- OIT
https://matthewwellings.com/blog/depth-peeling-order-independent-transparency-in-vulkan/ depth peeli ...
- (转)NIO 文件锁定
文件锁定 概述 文件锁定初看起来可能让人迷惑.它 似乎 指的是防止程序或者用户访问特定文件.事实上,文件锁就像常规的 Java 对象锁 ― 它们是 劝告式的(advisory) 锁.它们不阻止任何形式 ...
- XAMPP + Xdebug+Zend Studio
建立php开发环境(XAMPP + Xdebug+Zend Studio) 大家知道,运行php可以在apache上运行,但是要在apache上配置php解释器模块,懒得麻烦.就用XAMPP吧,它已经 ...
- 云计算之路-试用Azure:竟然无法重置虚拟机的管理员密码
在忘记管理员密码的情况下,可以远程重置服务器的管理员密码是云计算服务的一个优势,这是使用自己的物理服务器无法实现的. 但是,在使用Azure的时候,我们找遍Azure管理控制台也没找到可以重置虚拟机( ...
- wamp server php环境绑定域名
思路: 用花生壳做动态域名解析 用wamp server 在本机上做一个 php web server; 这样就可以让一台内网电脑做一个测试用的服务器: 一:wamp server php环境绑定域名 ...
- JS判断一个字符串是否包含一个子串函数.
微信小程序 JS判断一个字符串是否包含一个子串函数. //str 字符串,name子串 contains:function(str,name){ if(str.indexOf( ...
- js 终止 forEach 循环
1.因为 forEach() 无法通过正常流程终止,所以可以通过抛出异常的方式实现终止. try{ var array = ["first","second", ...
- java基础讲解10-----类的高级特性
一.final关键字 1.final关键字修饰变量,表示变量不可以被改变,如果想修改,编译器不会接受的. 注意:final关键字定义的变量必须赋值 public static final 修饰 白 ...
- C#指南,重温基础,展望远方!(2)程序结构
C# 中的关键组织结构概念包括程序.命名空间.类型.成员和程序集. C# 程序由一个或多个源文件组成. 程序声明类型,而类型则包含成员,并被整理到命名空间中. 类型示例包括类和接口. 成员示例包括字段 ...