Skip to content

Commit fcddd4a

Browse files
authored
Merge pull request #212 from highsource/issue-210
Fixes issue 210
2 parents 9e23d75 + c3f2364 commit fcddd4a

File tree

10 files changed

+69
-26
lines changed

10 files changed

+69
-26
lines changed

dist/Jsonix-all.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ Jsonix.XML.QName.key = function(namespaceURI, localPart) {
921921
Jsonix.Util.Ensure.ensureString(localPart);
922922
if (namespaceURI) {
923923
var colonPosition = localPart.indexOf(':');
924+
var localName;
924925
if (colonPosition > 0 && colonPosition < localPart.length) {
925926
localName = localPart.substring(colonPosition + 1);
926927
} else {
@@ -4901,7 +4902,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49014902
};
49024903
return new Jsonix.XML.Calendar(data);
49034904
}
4904-
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
4905+
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
49054906
},
49064907
parseDate : function(text, context, input, scope) {
49074908
Jsonix.Util.Ensure.ensureString(text);
@@ -4916,7 +4917,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49164917
};
49174918
return new Jsonix.XML.Calendar(data);
49184919
}
4919-
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
4920+
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
49204921
},
49214922
parseTime : function(text, context, input, scope) {
49224923
Jsonix.Util.Ensure.ensureString(text);
@@ -4932,7 +4933,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49324933
};
49334934
return new Jsonix.XML.Calendar(data);
49344935
}
4935-
throw new Error('Value [' + value + '] does not match the xs:time pattern.');
4936+
throw new Error('Value [' + text + '] does not match the xs:time pattern.');
49364937
},
49374938
parseTimezoneString : function(text) {
49384939
// (('+' | '-') hh ':' mm) | 'Z'
@@ -4955,7 +4956,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49554956
var minute = parseInt(results[5], 10);
49564957
return sign * (hour * 60 + minute);
49574958
}
4958-
throw new Error('Value [' + value + '] does not match the timezone pattern.');
4959+
throw new Error('Value [' + text + '] does not match the timezone pattern.');
49594960
}
49604961
},
49614962
print : function(value, context, output, scope) {

dist/Jsonix-min.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,12 @@ return new Jsonix.XML.QName(e,f,g)
331331
Jsonix.XML.QName.fromObjectOrString=function(f,d,e){if(Jsonix.Util.Type.isString(f)){return Jsonix.XML.QName.fromString(f,d,e)
332332
}else{return Jsonix.XML.QName.fromObject(f)
333333
}};
334-
Jsonix.XML.QName.key=function(f,e){Jsonix.Util.Ensure.ensureString(e);
335-
if(f){var d=e.indexOf(":");
336-
if(d>0&&d<e.length){localName=e.substring(d+1)
337-
}else{localName=e
338-
}return"{"+f+"}"+localName
334+
Jsonix.XML.QName.key=function(g,e){Jsonix.Util.Ensure.ensureString(e);
335+
if(g){var h=e.indexOf(":");
336+
var f;
337+
if(h>0&&h<e.length){f=e.substring(h+1)
338+
}else{f=e
339+
}return"{"+g+"}"+f
339340
}else{return e
340341
}};
341342
Jsonix.XML.Calendar=Jsonix.Class({year:NaN,month:NaN,day:NaN,hour:NaN,minute:NaN,second:NaN,fractionalSecond:NaN,timezone:NaN,date:null,initialize:function(f){Jsonix.Util.Ensure.ensureObject(f);
@@ -1939,19 +1940,19 @@ var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATETIME_PATTERN+"$");
19391940
var h=j.match(k);
19401941
if(h!==null){var l={year:parseInt(h[1],10),month:parseInt(h[5],10),day:parseInt(h[7],10),hour:parseInt(h[9],10),minute:parseInt(h[10],10),second:parseInt(h[11],10),fractionalSecond:(h[12]?parseFloat(h[12]):0),timezone:this.parseTimezoneString(h[14])};
19411942
return new Jsonix.XML.Calendar(l)
1942-
}throw new Error("Value ["+value+"] does not match the xs:date pattern.")
1943+
}throw new Error("Value ["+j+"] does not match the xs:date pattern.")
19431944
},parseDate:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j);
19441945
var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.DATE_PATTERN+"$");
19451946
var h=j.match(k);
19461947
if(h!==null){var l={year:parseInt(h[1],10),month:parseInt(h[5],10),day:parseInt(h[7],10),timezone:this.parseTimezoneString(h[9])};
19471948
return new Jsonix.XML.Calendar(l)
1948-
}throw new Error("Value ["+value+"] does not match the xs:date pattern.")
1949+
}throw new Error("Value ["+j+"] does not match the xs:date pattern.")
19491950
},parseTime:function(j,n,i,m){Jsonix.Util.Ensure.ensureString(j);
19501951
var k=new RegExp("^"+Jsonix.Schema.XSD.Calendar.TIME_PATTERN+"$");
19511952
var h=j.match(k);
19521953
if(h!==null){var l={hour:parseInt(h[1],10),minute:parseInt(h[2],10),second:parseInt(h[3],10),fractionalSecond:(h[4]?parseFloat(h[4]):0),timezone:this.parseTimezoneString(h[6])};
19531954
return new Jsonix.XML.Calendar(l)
1954-
}throw new Error("Value ["+value+"] does not match the xs:time pattern.")
1955+
}throw new Error("Value ["+j+"] does not match the xs:time pattern.")
19551956
},parseTimezoneString:function(i){if(!Jsonix.Util.Type.isString(i)){return NaN
19561957
}else{if(i===""){return NaN
19571958
}else{if(i==="Z"){return 0
@@ -1963,7 +1964,7 @@ if(l!==null){var g=l[1]==="+"?1:-1;
19631964
var h=parseInt(l[4],10);
19641965
var k=parseInt(l[5],10);
19651966
return g*(h*60+k)
1966-
}throw new Error("Value ["+value+"] does not match the timezone pattern.")
1967+
}throw new Error("Value ["+i+"] does not match the timezone pattern.")
19671968
}}}}}},print:function(g,e,f,h){Jsonix.Util.Ensure.ensureObject(g);
19681969
if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)&&Jsonix.Util.NumberUtils.isInteger(g.hour)&&Jsonix.Util.NumberUtils.isInteger(g.minute)&&Jsonix.Util.NumberUtils.isInteger(g.second)){return this.printDateTime(g)
19691970
}else{if(Jsonix.Util.NumberUtils.isInteger(g.year)&&Jsonix.Util.NumberUtils.isInteger(g.month)&&Jsonix.Util.NumberUtils.isInteger(g.day)){return this.printDate(g)

nodejs/scripts/jsonix.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ Jsonix.XML.QName.key = function(namespaceURI, localPart) {
921921
Jsonix.Util.Ensure.ensureString(localPart);
922922
if (namespaceURI) {
923923
var colonPosition = localPart.indexOf(':');
924+
var localName;
924925
if (colonPosition > 0 && colonPosition < localPart.length) {
925926
localName = localPart.substring(colonPosition + 1);
926927
} else {
@@ -4901,7 +4902,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49014902
};
49024903
return new Jsonix.XML.Calendar(data);
49034904
}
4904-
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
4905+
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
49054906
},
49064907
parseDate : function(text, context, input, scope) {
49074908
Jsonix.Util.Ensure.ensureString(text);
@@ -4916,7 +4917,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49164917
};
49174918
return new Jsonix.XML.Calendar(data);
49184919
}
4919-
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
4920+
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
49204921
},
49214922
parseTime : function(text, context, input, scope) {
49224923
Jsonix.Util.Ensure.ensureString(text);
@@ -4932,7 +4933,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49324933
};
49334934
return new Jsonix.XML.Calendar(data);
49344935
}
4935-
throw new Error('Value [' + value + '] does not match the xs:time pattern.');
4936+
throw new Error('Value [' + text + '] does not match the xs:time pattern.');
49364937
},
49374938
parseTimezoneString : function(text) {
49384939
// (('+' | '-') hh ':' mm) | 'Z'
@@ -4955,7 +4956,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
49554956
var minute = parseInt(results[5], 10);
49564957
return sign * (hour * 60 + minute);
49574958
}
4958-
throw new Error('Value [' + value + '] does not match the timezone pattern.');
4959+
throw new Error('Value [' + text + '] does not match the timezone pattern.');
49594960
}
49604961
},
49614962
print : function(value, context, output, scope) {

nodejs/scripts/tests/xsd.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,46 @@ module.exports =
222222
test.equal(-733, gd.timezone);
223223
test.equal('---06-12:13', Jsonix.Schema.XSD.Calendar.INSTANCE.print(gd));
224224

225+
test.throws(
226+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parse('nomatch'); },
227+
/Value \[nomatch\] does not match xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth or xs:gDay patterns\./);
228+
229+
test.throws(
230+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGYearMonth('201002'); },
231+
/Value \[201002\] does not match the xs:gYearMonth pattern\./);
232+
233+
test.throws(
234+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGYear('10'); },
235+
/Value \[10\] does not match the xs:gYear pattern\./);
236+
237+
test.throws(
238+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGMonthDay('02-10'); },
239+
/Value \[02-10\] does not match the xs:gMonthDay pattern\./);
240+
241+
test.throws(
242+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGMonth('02'); },
243+
/Value \[02\] does not match the xs:gMonth pattern\./);
244+
245+
test.throws(
246+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseGDay('01'); },
247+
/Value \[01\] does not match the xs:gDay pattern\./);
248+
249+
test.throws(
250+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseDateTime('2010-02-01 12:23:0'); },
251+
/Value \[2010-02-01 12:23:0\] does not match the xs:date pattern\./);
252+
253+
test.throws(
254+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseDate('20100201'); },
255+
/Value \[20100201\] does not match the xs:date pattern\./);
256+
257+
test.throws(
258+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseTime('12:23:0'); },
259+
/Value \[12:23:0\] does not match the xs:time pattern\./);
260+
261+
test.throws(
262+
function() { Jsonix.Schema.XSD.Calendar.INSTANCE.parseTimezoneString('PDT'); },
263+
/Value \[PDT\] does not match the timezone pattern\./);
264+
225265
test.done();
226266
},
227267

nodejs/tests/ar/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/tests/basic/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/tests/browserify/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/tests/po/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/tests/wps/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Schema/XSD/Calendar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
102102
};
103103
return new Jsonix.XML.Calendar(data);
104104
}
105-
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
105+
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
106106
},
107107
parseDate : function(text, context, input, scope) {
108108
Jsonix.Util.Ensure.ensureString(text);
@@ -117,7 +117,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
117117
};
118118
return new Jsonix.XML.Calendar(data);
119119
}
120-
throw new Error('Value [' + value + '] does not match the xs:date pattern.');
120+
throw new Error('Value [' + text + '] does not match the xs:date pattern.');
121121
},
122122
parseTime : function(text, context, input, scope) {
123123
Jsonix.Util.Ensure.ensureString(text);
@@ -133,7 +133,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
133133
};
134134
return new Jsonix.XML.Calendar(data);
135135
}
136-
throw new Error('Value [' + value + '] does not match the xs:time pattern.');
136+
throw new Error('Value [' + text + '] does not match the xs:time pattern.');
137137
},
138138
parseTimezoneString : function(text) {
139139
// (('+' | '-') hh ':' mm) | 'Z'
@@ -156,7 +156,7 @@ Jsonix.Schema.XSD.Calendar = Jsonix.Class(Jsonix.Schema.XSD.AnySimpleType, {
156156
var minute = parseInt(results[5], 10);
157157
return sign * (hour * 60 + minute);
158158
}
159-
throw new Error('Value [' + value + '] does not match the timezone pattern.');
159+
throw new Error('Value [' + text + '] does not match the timezone pattern.');
160160
}
161161
},
162162
print : function(value, context, output, scope) {

0 commit comments

Comments
 (0)