@@ -1618,7 +1618,21 @@ Jsonix.XML.Output = Jsonix.Class({
16181618 return node ;
16191619
16201620 } ,
1621- writeCDATA : function ( text ) {
1621+ writeCdata : function ( text ) {
1622+ var parts = text . split ( ']]>' ) ;
1623+ for ( var index = 0 ; index < parts . length ; index ++ ) {
1624+ if ( index + 1 < parts . length ) {
1625+ parts [ index ] = parts [ index ] + ']]' ;
1626+ parts [ index + 1 ] = '>' + parts [ index + 1 ] ;
1627+ }
1628+ }
1629+ var node ;
1630+ for ( var jndex = 0 ; jndex < parts . length ; jndex ++ ) {
1631+ node = this . writeCdataWithoutCdend ( parts [ jndex ] ) ;
1632+ }
1633+ return node ;
1634+ } ,
1635+ writeCdataWithoutCdend : function ( text ) {
16221636 var node ;
16231637 if ( Jsonix . Util . Type . isFunction ( this . document . createCDATASection ) ) {
16241638 node = this . document . createCDATASection ( text ) ;
@@ -1880,7 +1894,6 @@ Jsonix.Binding.Marshalls.Element = Jsonix.Class({
18801894 }
18811895 }
18821896 var typeInfo = actualTypeInfo || declaredTypeInfo ;
1883-
18841897 if ( typeInfo ) {
18851898 output . writeStartElement ( elementValue . name ) ;
18861899 if ( actualTypeInfo && declaredTypeInfo !== actualTypeInfo ) {
@@ -2160,32 +2173,32 @@ Jsonix.Model.ClassInfo = Jsonix
21602173 var n = mapping . name || mapping . n || undefined ;
21612174 Jsonix . Util . Ensure . ensureString ( n ) ;
21622175 this . name = n ;
2163-
2176+
21642177 var ln = mapping . localName || mapping . ln || null ;
21652178 this . localName = ln ;
21662179
21672180 var dens = mapping . defaultElementNamespaceURI || mapping . dens || mapping . targetNamespace || mapping . tns || '' ;
21682181 this . defaultElementNamespaceURI = dens ;
2169-
2182+
21702183 var tns = mapping . targetNamespace || mapping . tns || mapping . defaultElementNamespaceURI || mapping . dens || this . defaultElementNamespaceURI ;
21712184 this . targetNamespace = tns ;
21722185
21732186 var dans = mapping . defaultAttributeNamespaceURI || mapping . dans || '' ;
21742187 this . defaultAttributeNamespaceURI = dans ;
2175-
2188+
21762189 var bti = mapping . baseTypeInfo || mapping . bti || null ;
21772190 this . baseTypeInfo = bti ;
2178-
2191+
21792192 var inF = mapping . instanceFactory || mapping . inF || undefined ;
21802193 if ( Jsonix . Util . Type . exists ( inF ) ) {
21812194 // TODO: should we support instanceFactory as functions?
21822195 // For the pure JSON configuration?
21832196 Jsonix . Util . Ensure . ensureFunction ( inF ) ;
21842197 this . instanceFactory = inF ;
21852198 }
2186-
2199+
21872200 var tn = mapping . typeName || mapping . tn || undefined ;
2188-
2201+
21892202 if ( Jsonix . Util . Type . exists ( tn ) )
21902203 {
21912204 if ( Jsonix . Util . Type . isString ( tn ) )
@@ -2200,14 +2213,14 @@ Jsonix.Model.ClassInfo = Jsonix
22002213 {
22012214 this . typeName = new Jsonix . XML . QName ( tns , ln ) ;
22022215 }
2203-
2216+
22042217 this . properties = [ ] ;
22052218 this . propertiesMap = { } ;
22062219 var ps = mapping . propertyInfos || mapping . ps || [ ] ;
22072220 Jsonix . Util . Ensure . ensureArray ( ps ) ;
22082221 for ( var index = 0 ; index < ps . length ; index ++ ) {
22092222 this . p ( ps [ index ] ) ;
2210- }
2223+ }
22112224 } ,
22122225 getPropertyInfoByName : function ( name ) {
22132226 return this . propertiesMap [ name ] ;
@@ -2252,15 +2265,15 @@ Jsonix.Model.ClassInfo = Jsonix
22522265 unmarshal : function ( context , input ) {
22532266 this . build ( context ) ;
22542267 var result ;
2255-
2268+
22562269 if ( this . instanceFactory ) {
22572270 result = new this . instanceFactory ( ) ;
22582271 }
22592272 else
22602273 {
2261- result = { TYPE_NAME : this . name } ;
2274+ result = { TYPE_NAME : this . name } ;
22622275 }
2263-
2276+
22642277 if ( input . eventType !== 1 ) {
22652278 throw new Error ( "Parser must be on START_ELEMENT to read a class info." ) ;
22662279 }
@@ -2541,7 +2554,6 @@ Jsonix.Model.ClassInfo.prototype.propertyInfoCreators = {
25412554 "v" : Jsonix . Model . ClassInfo . prototype . v ,
25422555 "value" : Jsonix . Model . ClassInfo . prototype . v
25432556} ;
2544-
25452557Jsonix . Model . EnumLeafInfo = Jsonix . Class ( Jsonix . Model . TypeInfo , {
25462558 name : null ,
25472559 baseTypeInfo : 'String' ,
@@ -2965,8 +2977,8 @@ Jsonix.Model.ValuePropertyInfo = Jsonix.Class(Jsonix.Model.SingleTypePropertyInf
29652977 Jsonix . Util . Ensure . ensureObject ( mapping ) ;
29662978 Jsonix . Model . SingleTypePropertyInfo . prototype . initialize . apply ( this , [ mapping ] ) ;
29672979
2968- var c = mapping . asCDATA || mapping . c || false ;
2969- this . asCDATA = c ;
2980+ var cdata = mapping . asCDATA || mapping . cdata || false ;
2981+ this . asCDATA = cdata ;
29702982 } ,
29712983 unmarshal : function ( context , input , scope ) {
29722984 var text = input . getElementText ( ) ;
@@ -2978,7 +2990,7 @@ Jsonix.Model.ValuePropertyInfo = Jsonix.Class(Jsonix.Model.SingleTypePropertyInf
29782990 }
29792991
29802992 if ( this . asCDATA ) {
2981- output . writeCDATA ( this . print ( value , context , output , scope ) ) ;
2993+ output . writeCdata ( this . print ( value , context , output , scope ) ) ;
29822994 } else {
29832995 output . writeCharacters ( this . print ( value , context , output , scope ) ) ;
29842996 }
@@ -5844,15 +5856,15 @@ Jsonix.Context = Jsonix
58445856 Jsonix . Util . Ensure . ensureObject ( options ) ;
58455857 if ( Jsonix . Util . Type
58465858 . isObject ( options . namespacePrefixes ) ) {
5847- this . namespacePrefixes =
5859+ this . namespacePrefixes =
58485860 Jsonix . Util . Type . cloneObject ( options . namespacePrefixes , { } ) ;
58495861 }
58505862 if ( Jsonix . Util . Type
58515863 . isBoolean ( options . supportXsiType ) ) {
5852- this . supportXsiType = options . supportXsiType ;
5864+ this . supportXsiType = options . supportXsiType ;
58535865 }
58545866 }
5855-
5867+
58565868 // Initialize prefix/namespace mapping
58575869 for ( var ns in this . namespacePrefixes )
58585870 {
@@ -5881,7 +5893,7 @@ Jsonix.Context = Jsonix
58815893 module = mapping ;
58825894 } else {
58835895 mapping = Jsonix . Util . Type . cloneObject ( mapping ) ;
5884- module = new this . mappingStyle . module ( mapping ,
5896+ module = new this . mappingStyle . module ( mapping ,
58855897 {
58865898 mappingStyle : this . mappingStyle
58875899 } ) ;
@@ -6122,7 +6134,6 @@ Jsonix.Context = Jsonix
61226134 Jsonix . Schema . XSD . UnsignedShort . INSTANCE ] ,
61236135 CLASS_NAME : 'Jsonix.Context'
61246136 } ) ;
6125-
61266137 // Complete Jsonix script is included above
61276138 return { Jsonix : Jsonix } ;
61286139} ;
0 commit comments