@@ -877,9 +877,16 @@ Jsonix.XML.QName.fromString = function(qNameAsString, namespaceContext, defaultN
877
877
localPart = prefixedName ;
878
878
}
879
879
// If namespace URI was not set and we have a namespace context, try to find the namespace URI via this context
880
- if ( namespaceURI === null && namespaceContext )
880
+ if ( namespaceURI === null )
881
881
{
882
- namespaceURI = namespaceContext . getNamespaceURI ( prefix ) ;
882
+ if ( prefix === '' && Jsonix . Util . Type . isString ( defaultNamespaceURI ) )
883
+ {
884
+ namespaceURI = defaultNamespaceURI ;
885
+ }
886
+ else if ( namespaceContext )
887
+ {
888
+ namespaceURI = namespaceContext . getNamespaceURI ( prefix ) ;
889
+ }
883
890
}
884
891
// If we don't have a namespace URI, assume '' by default
885
892
// TODO document the assumption
@@ -4052,10 +4059,13 @@ Jsonix.Schema.XSD.AnySimpleType = Jsonix.Class(Jsonix.Model.TypeInfo, {
4052
4059
Jsonix . Model . TypeInfo . prototype . initialize . apply ( this , [ ] ) ;
4053
4060
} ,
4054
4061
print : function ( value , context , output , scope ) {
4055
- throw new Error ( 'Abstract method [print].' ) ;
4062
+ return value ;
4056
4063
} ,
4057
4064
parse : function ( text , context , input , scope ) {
4058
- throw new Error ( 'Abstract method [parse].' ) ;
4065
+ return text ;
4066
+ } ,
4067
+ isInstance : function ( value , context , scope ) {
4068
+ return true ;
4059
4069
} ,
4060
4070
reprint : function ( value , context , output , scope ) {
4061
4071
// Only reprint when the value is a string but not an instance
@@ -4089,7 +4099,7 @@ Jsonix.Schema.XSD.AnySimpleType = Jsonix.Class(Jsonix.Model.TypeInfo, {
4089
4099
} ,
4090
4100
CLASS_NAME : 'Jsonix.Schema.XSD.AnySimpleType'
4091
4101
} ) ;
4092
-
4102
+ Jsonix . Schema . XSD . AnySimpleType . INSTANCE = new Jsonix . Schema . XSD . AnySimpleType ( ) ;
4093
4103
Jsonix . Schema . XSD . List = Jsonix
4094
4104
. Class (
4095
4105
Jsonix . Schema . XSD . AnySimpleType ,
@@ -5308,6 +5318,20 @@ Jsonix.Schema.XSD.Duration.INSTANCE.LIST = new Jsonix.Schema.XSD.List(Jsonix.Sch
5308
5318
Jsonix . Schema . XSD . DateTime = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5309
5319
name : 'DateTime' ,
5310
5320
typeName : Jsonix . Schema . XSD . qname ( 'dateTime' ) ,
5321
+ parse : function ( value , context , input , scope ) {
5322
+ return this . parseDateTime ( value ) ;
5323
+ } ,
5324
+ print : function ( value , context , output , scope ) {
5325
+ return this . printDateTime ( value ) ;
5326
+ } ,
5327
+ CLASS_NAME : 'Jsonix.Schema.XSD.DateTime'
5328
+ } ) ;
5329
+ Jsonix . Schema . XSD . DateTime . INSTANCE = new Jsonix . Schema . XSD . DateTime ( ) ;
5330
+ Jsonix . Schema . XSD . DateTime . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . DateTime . INSTANCE ) ;
5331
+
5332
+ Jsonix . Schema . XSD . DateTimeAsDate = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5333
+ name : 'DateTimeAsDate' ,
5334
+ typeName : Jsonix . Schema . XSD . qname ( 'dateTime' ) ,
5311
5335
parse : function ( value , context , input , scope ) {
5312
5336
var calendar = this . parseDateTime ( value ) ;
5313
5337
var date = new Date ( ) ;
@@ -5396,14 +5420,27 @@ Jsonix.Schema.XSD.DateTime = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
5396
5420
isInstance : function ( value , context , scope ) {
5397
5421
return Jsonix . Util . Type . isDate ( value ) ;
5398
5422
} ,
5399
- CLASS_NAME : 'Jsonix.Schema.XSD.DateTime '
5423
+ CLASS_NAME : 'Jsonix.Schema.XSD.DateTimeAsDate '
5400
5424
} ) ;
5401
- Jsonix . Schema . XSD . DateTime . INSTANCE = new Jsonix . Schema . XSD . DateTime ( ) ;
5402
- Jsonix . Schema . XSD . DateTime . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . DateTime . INSTANCE ) ;
5425
+ Jsonix . Schema . XSD . DateTimeAsDate . INSTANCE = new Jsonix . Schema . XSD . DateTimeAsDate ( ) ;
5426
+ Jsonix . Schema . XSD . DateTimeAsDate . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . DateTimeAsDate . INSTANCE ) ;
5403
5427
5404
5428
Jsonix . Schema . XSD . Time = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5405
5429
name : 'Time' ,
5406
5430
typeName : Jsonix . Schema . XSD . qname ( 'time' ) ,
5431
+ parse : function ( value , context , input , scope ) {
5432
+ return this . parseTime ( value ) ;
5433
+ } ,
5434
+ print : function ( value , context , output , scope ) {
5435
+ return this . printTime ( value ) ;
5436
+ } ,
5437
+ CLASS_NAME : 'Jsonix.Schema.XSD.Time'
5438
+ } ) ;
5439
+ Jsonix . Schema . XSD . Time . INSTANCE = new Jsonix . Schema . XSD . Time ( ) ;
5440
+ Jsonix . Schema . XSD . Time . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . Time . INSTANCE ) ;
5441
+ Jsonix . Schema . XSD . TimeAsDate = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5442
+ name : 'TimeAsDate' ,
5443
+ typeName : Jsonix . Schema . XSD . qname ( 'time' ) ,
5407
5444
parse : function ( value , context , input , scope ) {
5408
5445
var calendar = this . parseTime ( value ) ;
5409
5446
var date = new Date ( ) ;
@@ -5475,7 +5512,7 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
5475
5512
correctedValue = value ;
5476
5513
}
5477
5514
var correctedTime = correctedValue . getTime ( ) ;
5478
- if ( correctedTime >= 0 ) {
5515
+ if ( correctedTime >= ( - localTimezone * 60000 ) ) {
5479
5516
return this . printTime ( new Jsonix . XML . Calendar ( {
5480
5517
hour : correctedValue . getHours ( ) ,
5481
5518
minute : correctedValue . getMinutes ( ) ,
@@ -5485,10 +5522,17 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
5485
5522
} ) ) ;
5486
5523
} else {
5487
5524
var timezoneHours = Math . ceil ( - correctedTime / 3600000 ) ;
5525
+
5526
+ var correctedTimeInSeconds = correctedValue . getSeconds ( ) +
5527
+ correctedValue . getMinutes ( ) * 60 +
5528
+ correctedValue . getHours ( ) * 3600 +
5529
+ timezoneHours * 3600 -
5530
+ timezone * 60 ;
5531
+
5488
5532
return this . printTime ( new Jsonix . XML . Calendar ( {
5489
- hour : ( correctedValue . getHours ( ) + timezoneHours - timezone / 60 ) % 24 ,
5490
- minute : correctedValue . getMinutes ( ) ,
5491
- second : correctedValue . getSeconds ( ) ,
5533
+ hour : correctedTimeInSeconds % 86400 ,
5534
+ minute : correctedTimeInSeconds % 3600 ,
5535
+ second : correctedTimeInSeconds % 60 ,
5492
5536
fractionalSecond : ( correctedValue . getMilliseconds ( ) / 1000 ) ,
5493
5537
timezone : timezoneHours * 60
5494
5538
} ) ) ;
@@ -5498,13 +5542,26 @@ Jsonix.Schema.XSD.Time = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
5498
5542
isInstance : function ( value , context , scope ) {
5499
5543
return Jsonix . Util . Type . isDate ( value ) && value . getTime ( ) > - 86400000 && value . getTime ( ) < 86400000 ;
5500
5544
} ,
5501
- CLASS_NAME : 'Jsonix.Schema.XSD.Time '
5545
+ CLASS_NAME : 'Jsonix.Schema.XSD.TimeAsDate '
5502
5546
} ) ;
5503
- Jsonix . Schema . XSD . Time . INSTANCE = new Jsonix . Schema . XSD . Time ( ) ;
5504
- Jsonix . Schema . XSD . Time . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . Time . INSTANCE ) ;
5547
+ Jsonix . Schema . XSD . TimeAsDate . INSTANCE = new Jsonix . Schema . XSD . TimeAsDate ( ) ;
5548
+ Jsonix . Schema . XSD . TimeAsDate . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . TimeAsDate . INSTANCE ) ;
5505
5549
Jsonix . Schema . XSD . Date = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5506
5550
name : 'Date' ,
5507
5551
typeName : Jsonix . Schema . XSD . qname ( 'date' ) ,
5552
+ parse : function ( value , context , input , scope ) {
5553
+ return this . parseDate ( value ) ;
5554
+ } ,
5555
+ print : function ( value , context , output , scope ) {
5556
+ return this . printDate ( value ) ;
5557
+ } ,
5558
+ CLASS_NAME : 'Jsonix.Schema.XSD.Date'
5559
+ } ) ;
5560
+ Jsonix . Schema . XSD . Date . INSTANCE = new Jsonix . Schema . XSD . Date ( ) ;
5561
+ Jsonix . Schema . XSD . Date . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . Date . INSTANCE ) ;
5562
+ Jsonix . Schema . XSD . DateAsDate = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5563
+ name : 'DateAsDate' ,
5564
+ typeName : Jsonix . Schema . XSD . qname ( 'date' ) ,
5508
5565
parse : function ( value , context , input , scope ) {
5509
5566
var calendar = this . parseDate ( value ) ;
5510
5567
var date = new Date ( ) ;
@@ -5613,10 +5670,10 @@ Jsonix.Schema.XSD.Date = Jsonix.Class(Jsonix.Schema.XSD.Calendar, {
5613
5670
isInstance : function ( value , context , scope ) {
5614
5671
return Jsonix . Util . Type . isDate ( value ) ;
5615
5672
} ,
5616
- CLASS_NAME : 'Jsonix.Schema.XSD.Date '
5673
+ CLASS_NAME : 'Jsonix.Schema.XSD.DateAsDate '
5617
5674
} ) ;
5618
- Jsonix . Schema . XSD . Date . INSTANCE = new Jsonix . Schema . XSD . Date ( ) ;
5619
- Jsonix . Schema . XSD . Date . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . Date . INSTANCE ) ;
5675
+ Jsonix . Schema . XSD . DateAsDate . INSTANCE = new Jsonix . Schema . XSD . DateAsDate ( ) ;
5676
+ Jsonix . Schema . XSD . DateAsDate . INSTANCE . LIST = new Jsonix . Schema . XSD . List ( Jsonix . Schema . XSD . DateAsDate . INSTANCE ) ;
5620
5677
Jsonix . Schema . XSD . GYearMonth = Jsonix . Class ( Jsonix . Schema . XSD . Calendar , {
5621
5678
name : 'GYearMonth' ,
5622
5679
typeName : Jsonix . Schema . XSD . qname ( 'gYearMonth' ) ,
@@ -5984,12 +6041,15 @@ Jsonix.Context = Jsonix
5984
6041
*/
5985
6042
builtinTypeInfos : [
5986
6043
Jsonix . Schema . XSD . AnyType . INSTANCE ,
6044
+ Jsonix . Schema . XSD . AnySimpleType . INSTANCE ,
5987
6045
Jsonix . Schema . XSD . AnyURI . INSTANCE ,
5988
6046
Jsonix . Schema . XSD . Base64Binary . INSTANCE ,
5989
6047
Jsonix . Schema . XSD . Boolean . INSTANCE ,
5990
6048
Jsonix . Schema . XSD . Byte . INSTANCE ,
5991
6049
Jsonix . Schema . XSD . Calendar . INSTANCE ,
6050
+ Jsonix . Schema . XSD . DateAsDate . INSTANCE ,
5992
6051
Jsonix . Schema . XSD . Date . INSTANCE ,
6052
+ Jsonix . Schema . XSD . DateTimeAsDate . INSTANCE ,
5993
6053
Jsonix . Schema . XSD . DateTime . INSTANCE ,
5994
6054
Jsonix . Schema . XSD . Decimal . INSTANCE ,
5995
6055
Jsonix . Schema . XSD . Double . INSTANCE ,
@@ -6022,6 +6082,7 @@ Jsonix.Context = Jsonix
6022
6082
Jsonix . Schema . XSD . Short . INSTANCE ,
6023
6083
Jsonix . Schema . XSD . String . INSTANCE ,
6024
6084
Jsonix . Schema . XSD . Strings . INSTANCE ,
6085
+ Jsonix . Schema . XSD . TimeAsDate . INSTANCE ,
6025
6086
Jsonix . Schema . XSD . Time . INSTANCE ,
6026
6087
Jsonix . Schema . XSD . Token . INSTANCE ,
6027
6088
Jsonix . Schema . XSD . UnsignedByte . INSTANCE ,
0 commit comments