Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ xsd4jVersion=1.6.3
apacheXmlSchemaVersion=1.4.7
picocliVersion=4.0.1
junitVersion=4.13.1
junitEngineVersion=5.8.2
junitEngineVersion=5.10.0
junitParamVersion=5.10.1
testngVersion=7.7.0

Expand Down
4 changes: 2 additions & 2 deletions module-ballerina-xsd/BalTool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
id = "xsd"

[[dependency]]
path = "../xsd-cli/build/libs/xsd-cli-1.1.1.jar"
path = "../xsd-cli/build/libs/xsd-cli-1.1.2-SNAPSHOT.jar"

[[dependency]]
path = "../xsd-core/build/libs/xsd-core-1.1.1.jar"
path = "../xsd-core/build/libs/xsd-core-1.1.2-SNAPSHOT.jar"

2 changes: 1 addition & 1 deletion module-ballerina-xsd/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
distribution = "2201.11.0"
org = "ballerina"
name = "xsdtool"
version = "1.1.1"
version = "1.1.2"
authors = ["Ballerina"]
keywords = ["xsd", "xsd-tool"]
repository = "https://github.com/ballerina-platform/xsd-tools"
Expand Down
2 changes: 1 addition & 1 deletion module-ballerina-xsd/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ distribution-version = "2201.11.0"
[[package]]
org = "ballerina"
name = "xsdtool"
version = "1.1.1"
version = "1.1.2"
modules = [
{org = "ballerina", packageName = "xsdtool", moduleName = "xsdtool"}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public final class Utils {
public static final String G_YEAR_MONTH = "gYearMonth";
public static final String G_YEAR = "gYear";
public static final String G_MONTH_DAY = "gMonthDay";
public static final String G_DAY = "gDay";
public static final String G_MONTH = "gMonth";
public static final String NORMALIZED_STRING = "normalizedString";
public static final String TOKEN = "token";
public static final String NCNAME = "NCName";
public static final String QNAME = "QName";
public static final String NOTATION = "NOTATION";
public static final String STRING = "string";
public static final String INTEGER = "integer";
public static final String LONG = "long";
Expand Down Expand Up @@ -175,13 +182,23 @@ public static String deriveType(Node node) {
public static String typeGenerator(String typeName) {
switch (typeName) {
case TIME, DATE_TIME, DATE, G_YEAR_MONTH, G_YEAR, STRING, LANGUAGE,
DURATION, ANY_URI, G_MONTH_DAY, NMTOKEN, IDREF -> {
DURATION, ANY_URI, G_MONTH_DAY, NMTOKEN, IDREF, G_DAY, G_MONTH, NORMALIZED_STRING,
TOKEN, NCNAME, QNAME, NOTATION -> {
return STRING;
}
case INTEGER, LONG, NEGATIVE_INTEGER, NON_POSITIVE_INTEGER, POSITIVE_INTEGER, SHORT,
UNSIGNED_LONG, UNSIGNED_INT, UNSIGNED_SHORT, UNSIGNED_BYTE, INT, NON_NEGATIVE_INTEGER -> {
return INT;
}
case DOUBLE, FLOAT -> {
return FLOAT;
}
case BOOLEAN -> {
return BOOLEAN;
}
case DECIMAL -> {
return DECIMAL;
}
case BASE64_BINARY -> {
return BYTE_ARRAY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ private static Stream<Object[]> provideTestPaths() {
new Object[] {"34_elements_with_simple_types.xml", "34_elements_with_simple_types.bal"},
new Object[] {"35_unions_of_simple_types.xsd", "35_unions_of_simple_types.bal"},
new Object[] {"36_elements_with_byte_type.xsd", "36_elements_with_byte_type.bal"},
new Object[] {"37_elements_with_nested_complex_type.xml", "37_elements_with_nested_complex_type.bal"}
new Object[] {"37_elements_with_nested_complex_type.xml", "37_elements_with_nested_complex_type.bal"},
new Object[] {"38_elements_with_double_values.xml", "38_elements_with_double_values.bal"},
new Object[] {"39_elements_with_primitive_types.xsd", "39_elements_with_primitive_types.bal"}
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import ballerina/data.xmldata;

@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
public type AddRequest record {|
@xmldata:Sequence {minOccurs: 1, maxOccurs: 1}
SequenceGroup sequenceGroup;
|};

@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
public type AddResponse record {|
@xmldata:Sequence {minOccurs: 1, maxOccurs: 1}
SequenceGroup1 sequenceGroup1;
|};

@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
public type SequenceGroup record {|
@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
@xmldata:SequenceOrder {value: 1}
float a;
@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
@xmldata:SequenceOrder {value: 2}
float b;
|};

@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
public type SequenceGroup1 record {|
@xmldata:Namespace {uri: "http://example.com/CalculatorService"}
@xmldata:SequenceOrder {value: 1}
float result;
|};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import ballerina/data.xmldata;

@xmldata:Namespace {uri: "http://example.com/types"}
public type normalizedString record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type token record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type NCName record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type QName record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type NOTATION record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type gDay record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type gMonth record {|
string \#content;
|};

@xmldata:Name {value: "hexBinary"}
@xmldata:Namespace {uri: "http://example.com/types"}
public type string1 record {|
string \#content;
|};

@xmldata:Namespace {uri: "http://example.com/types"}
public type booleanValue record {|
boolean \#content;
|};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<xs:schema targetNamespace="http://example.com/CalculatorService"
elementFormDefault="qualified"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com/CalculatorService"
name="CalculatorService">

<!-- Input element -->
<xs:element name="AddRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="a" type="xs:double"/>
<xs:element name="b" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<!-- Output element -->
<xs:element name="AddResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="result" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/types"
xmlns="http://example.com/types"
elementFormDefault="qualified">

<!-- String / Name types -->
<xs:element name="normalizedString" type="xs:normalizedString"/>
<xs:element name="token" type="xs:token"/>
<xs:element name="NCName" type="xs:NCName"/>
<xs:element name="QName" type="xs:QName"/>
<xs:element name="NOTATION" type="xs:NOTATION"/>

<!-- Date types -->
<xs:element name="gDay" type="xs:gDay"/>
<xs:element name="gMonth" type="xs:gMonth"/>

<!-- Binary types -->
<xs:element name="hexBinary" type="xs:hexBinary"/>

<!-- Boolean type -->
<xs:element name="booleanValue" type="xs:boolean"/>

</xs:schema>