-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into java21_sync
- Loading branch information
Showing
80 changed files
with
12,602 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="Book" type="xs:string"/> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="Library"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="Book" maxOccurs="unbounded"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="Title" type="xs:string"/> | ||
<xs:element name="Author" type="xs:string"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="Person"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="Name" type="xs:string"/> | ||
<xs:element name="Age" type="xs:int"/> | ||
</xs:sequence> | ||
<xs:attribute name="id" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="Vehicle"> | ||
<xs:complexType> | ||
<xs:choice> | ||
<xs:element name="Car" type="xs:string"/> | ||
<xs:element name="Bike" type="xs:string"/> | ||
</xs:choice> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="Order"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="OrderID" type="xs:int"/> | ||
<xs:element name="Product" type="xs:string"/> | ||
</xs:all> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
1 change: 1 addition & 0 deletions
1
ballerina/tests/resources/xsd_tests/xml_values/schema_1_invalid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<Book><Title>Sample</Title></Book> |
1 change: 1 addition & 0 deletions
1
ballerina/tests/resources/xsd_tests/xml_values/schema_1_valid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<Book>Sample</Book> |
5 changes: 5 additions & 0 deletions
5
ballerina/tests/resources/xsd_tests/xml_values/schema_2_invalid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Library> | ||
<Book> | ||
<Title>Sample Title</Title> | ||
</Book> | ||
</Library> |
6 changes: 6 additions & 0 deletions
6
ballerina/tests/resources/xsd_tests/xml_values/schema_2_valid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Library> | ||
<Book> | ||
<Title>Sample Title</Title> | ||
<Author>Sample Author</Author> | ||
</Book> | ||
</Library> |
4 changes: 4 additions & 0 deletions
4
ballerina/tests/resources/xsd_tests/xml_values/schema_3_invalid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Person> | ||
<Name>John Doe</Name> | ||
<Age>30</Age> | ||
</Person> |
4 changes: 4 additions & 0 deletions
4
ballerina/tests/resources/xsd_tests/xml_values/schema_3_valid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Person id="123"> | ||
<Name>John Doe</Name> | ||
<Age>30</Age> | ||
</Person> |
4 changes: 4 additions & 0 deletions
4
ballerina/tests/resources/xsd_tests/xml_values/schema_4_invalid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Vehicle> | ||
<Car>Toyota</Car> | ||
<Bike>Yamaha</Bike> | ||
</Vehicle> |
3 changes: 3 additions & 0 deletions
3
ballerina/tests/resources/xsd_tests/xml_values/schema_4_valid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Vehicle> | ||
<Car>Toyota</Car> | ||
</Vehicle> |
3 changes: 3 additions & 0 deletions
3
ballerina/tests/resources/xsd_tests/xml_values/schema_5_invalid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Order> | ||
<OrderID>12345</OrderID> | ||
</Order> |
4 changes: 4 additions & 0 deletions
4
ballerina/tests/resources/xsd_tests/xml_values/schema_5_valid_xml.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<Order> | ||
<OrderID>12345</OrderID> | ||
<Product>Laptop</Product> | ||
</Order> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ballerina/test; | ||
|
||
@test:Config {groups: ["xsd", "to_xml"], dataProvider: fromJsonDataProvider} | ||
function testFromJson(json value, xml expected) returns error?{ | ||
xml|Error xmlResult = fromJson(value); | ||
test:assertEquals(xmlResult, expected); | ||
} | ||
|
||
function fromJsonDataProvider() returns [json, xml][] { | ||
return [ | ||
[{a: {b: 2, c: 3}}, xml `<a><b>2</b><c>3</c></a>`], | ||
[{a: {a: 1}}, xml `<a><a>1</a></a>`], | ||
[{a: {d: 4, e: {f: 5, g: "text"}}}, xml `<a><d>4</d><e><f>5</f><g>text</g></e></a>`], | ||
[{root: {nested: {value1: "example", value2: 10}}}, xml `<root><nested><value1>example</value1><value2>10</value2></nested></root>`], | ||
[{book: {title: "XML Guide", author: "John Doe", year: 2024}}, xml `<book><title>XML Guide</title><author>John Doe</author><year>2024</year></book>`], | ||
[{library: {section: {book1: "Book A", book2: "Book B"}}}, xml `<library><section><book1>Book A</book1><book2>Book B</book2></section></library>`], | ||
[{person: {name: "Alice", details: {age: 30, city: "Wonderland"}}}, xml `<person><name>Alice</name><details><age>30</age><city>Wonderland</city></details></person>`], | ||
[{catalog: {item: [{id: 1, name: "Item 1"}, {id: 2, name: "Item 2"}]}}, xml `<catalog><item><id>1</id><name>Item 1</name></item><item><id>2</id><name>Item 2</name></item></catalog>`], | ||
[{company: {employee: {id: 1001, name: "Bob", department: "Engineering"}}}, xml `<company><employee><id>1001</id><name>Bob</name><department>Engineering</department></employee></company>`], | ||
[{'order: {orderId: 5001, items: {item1: "Widget", item2: "Gadget"}}}, xml `<order><orderId>5001</orderId><items><item1>Widget</item1><item2>Gadget</item2></items></order>`], | ||
[{menu: {dish: [{name: "Pasta", price: 12.5}, {name: "Salad", price: 8.0}]}}, xml `<menu><dish><name>Pasta</name><price>12.5</price></dish><dish><name>Salad</name><price>8.0</price></dish></menu>`], | ||
[{report: {entries: [{date: "2024-10-01", detail: "Entry 1"}, {date: "2024-10-02", detail: "Entry 2"}]}}, xml `<report><entries><date>2024-10-01</date><detail>Entry 1</detail></entries><entries><date>2024-10-02</date><detail>Entry 2</detail></entries></report>`], | ||
[{shoppingList: {items: [{item: "Apples", quantity: 5}, {item: "Bananas", quantity: 3}]}}, xml `<shoppingList><items><item>Apples</item><quantity>5</quantity></items><items><item>Bananas</item><quantity>3</quantity></items></shoppingList>`], | ||
[{conference: {session: [{topic: "AI Trends", speaker: "Dr. Smith"}, {topic: "Web 3.0", speaker: "Jane Doe"}]}}, xml `<conference><session><topic>AI Trends</topic><speaker>Dr. Smith</speaker></session><session><topic>Web 3.0</topic><speaker>Jane Doe</speaker></session></conference>`], | ||
[{project: {tasks: [{title: "Setup Environment", status: "Completed"}, {title: "Develop Module", status: "In Progress"}]}}, xml `<project><tasks><title>Setup Environment</title><status>Completed</status></tasks><tasks><title>Develop Module</title><status>In Progress</status></tasks></project>`], | ||
[{school: {students: [{name: "Emily", grade: "A"}, {name: "Michael", grade: "B"}]}}, xml `<school><students><name>Emily</name><grade>A</grade></students><students><name>Michael</name><grade>B</grade></students></school>`], | ||
[{portfolio: {stocks: [{symbol: "AAPL", shares: 50}, {symbol: "TSLA", shares: 30}]}}, xml `<portfolio><stocks><symbol>AAPL</symbol><shares>50</shares></stocks><stocks><symbol>TSLA</symbol><shares>30</shares></stocks></portfolio>`], | ||
[{university: {course: [{name: "Mathematics", credits: 4}, {name: "History", credits: 3}]}}, xml `<university><course><name>Mathematics</name><credits>4</credits></course><course><name>History</name><credits>3</credits></course></university>`], | ||
[{research: {papers: [{title: "Quantum Computing", author: "Alice Cooper"}, {title: "Blockchain Advances", author: "John Smith"}]}}, xml `<research><papers><title>Quantum Computing</title><author>Alice Cooper</author></papers><papers><title>Blockchain Advances</title><author>John Smith</author></papers></research>`], | ||
[{movieCollection: {movies: [{title: "Inception", director: "Nolan"}, {title: "Interstellar", director: "Nolan"}]}}, xml `<movieCollection><movies><title>Inception</title><director>Nolan</director></movies><movies><title>Interstellar</title><director>Nolan</director></movies></movieCollection>`], | ||
[{library: {books: [{title: "XML Guide", author: "John Doe", year: 2024}, {title: "JSON Primer", author: "Jane Smith", year: 2023}]}}, xml `<library><books><title>XML Guide</title><author>John Doe</author><year>2024</year></books><books><title>JSON Primer</title><author>Jane Smith</author><year>2023</year></books></library>`], | ||
[{shoppingList: {items: [{item: "Apples", quantity: 5}, {item: "Bananas", quantity: 3}]}}, xml `<shoppingList><items><item>Apples</item><quantity>5</quantity></items><items><item>Bananas</item><quantity>3</quantity></items></shoppingList>`], | ||
[{project: {tasks: [{title: "Setup Environment", status: "Completed"}, {title: "Develop Module", status: "In Progress"}]}}, xml `<project><tasks><title>Setup Environment</title><status>Completed</status></tasks><tasks><title>Develop Module</title><status>In Progress</status></tasks></project>`], | ||
[{school: {students: [{name: "Emily", grade: "A"}, {name: "Michael", grade: "B"}]}}, xml `<school><students><name>Emily</name><grade>A</grade></students><students><name>Michael</name><grade>B</grade></students></school>`], | ||
[{conference: {sessions: [{topic: "AI Trends", speaker: "Dr. Smith"}, {topic: "Web 3.0", speaker: "Jane Doe"}]}}, xml `<conference><sessions><topic>AI Trends</topic><speaker>Dr. Smith</speaker></sessions><sessions><topic>Web 3.0</topic><speaker>Jane Doe</speaker></sessions></conference>`], | ||
[{catalog: {items: [{id: 1, name: "Item 1"}, {id: 2, name: "Item 2"}]}}, xml `<catalog><items><id>1</id><name>Item 1</name></items><items><id>2</id><name>Item 2</name></items></catalog>`] | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.