How to integrate with Google APIs and Google Apps (5)----How do I convert the JSON schema of Google tasks to XML Schema (XSD)?

Source: Internet
Author: User

There are some Google API introductions, but in actual development we may need to convert the JSON data returned by the Google RESTful API into XML data input into a third-party system, which is very common in enterprise application integration. Then there is the question of how to ensure that the converted XML data format is canonical, which requires XML Schema (XML) for validation. Now the point is, we only know the JSON schema of the Google API, but Google restful does not provide the XML schema that returns the data, so what will the XML schema look like? Let me take the Google Tasks API as an example. From the URL below we can see information about the Google Tasks RESTful API JSON schema: Https://www.googleapis.com/discovery/v1/apis/tasks/v1/rest

So how do you translate the JSON schema for Google tasks into an XSD schema for XML? What will the XML schema look like? Please refer to the conversion implementation below.

<?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" t Ype= "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 "/&G            T <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=" x S:string "minoccurs=" 0 "/> <xs:element name=" updated "form=" unqualified "type=" xs:string "minoccurs=" 0 "/&G        T            </xs:sequence> </xs:complexType> <xs:complextype name= "tasklists" > <xs:sequence> <xs:element name= "ETag" form= "unqualified" type= "xs:string" minoccurs= "0"/> <xs:element name= "I TEMs "form=" unqualified "type=" TaskList "minoccurs=" 0 "maxoccurs=" unbounded "/> <xs:element name=" kind "fo Rm= "Unqualified" type= "xs:string" minoccurs= "0"/> <xs:element name= "Nextpagetoken" form= "unqualified" Typ E= "xs:string" minoccurs= "0"/> </xs:sequence> </xs:complexType> <xs:complextype name= "Taskit      EMS ">  <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 nam    E= "type" form= "unqualified" type= "xs:string" minoccurs= "0"/> </xs:sequence> </xs:complexType> <xs:complextype name= "Tasklinks" > <xs:sequence> <xs:element name= "items" form= "Unqualifie D "type=" TaskItems "minoccurs=" 0 "maxoccurs=" unbounded "/> </xs:sequence> </xs:complexType> &lt ; 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" MAXOCCU            rs= "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&gt    ; <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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.