File tree 3 files changed +27
-0
lines changed
core/src/commonMain/kotlin/nl/adaptivity/xmlutil
serialization/src/commonTest/kotlin/nl/adaptivity/xml/serialization
3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ fun XmlReader.readSimpleElement(): String {
348
348
EventType .PROCESSING_INSTRUCTION -> {
349
349
}
350
350
EventType .TEXT ,
351
+ EventType .ENTITY_REF ,
351
352
EventType .CDSECT -> append(t.text)
352
353
else -> throw XmlException (
353
354
" Expected text content or end tag, found: ${t.eventType} "
Original file line number Diff line number Diff line change @@ -132,6 +132,25 @@ class TestCommon {
132
132
assertEquals(contentText, serialized)
133
133
}
134
134
135
+
136
+ @Test
137
+ fun deserializeXmlWithEntity () {
138
+ val xml = XML {
139
+ repairNamespaces = true
140
+ policy = DefaultXmlSerializationPolicy (pedantic = false , autoPolymorphic = false )
141
+ }
142
+
143
+ val expected = StringWithMarkup (" Chloroacetic acid, >=99%" )
144
+
145
+ val actual = xml.decodeFromString<StringWithMarkup >(
146
+ " <StringWithMarkup xmlns=\" http://pubchem.ncbi.nlm.nih.gov/pug_view\" >\n " +
147
+ " <String>Chloroacetic acid, >=99%</String>\n " +
148
+ " </StringWithMarkup>"
149
+ )
150
+ assertEquals(expected, actual)
151
+ }
152
+
153
+
135
154
@Serializable
136
155
data class IntList (val values : List <Int >)
137
156
Original file line number Diff line number Diff line change
1
+
2
+ @XmlSerialName(" StringWithMarkup" , " http://pubchem.ncbi.nlm.nih.gov/pug_view" , " " )
3
+ @Serializable
4
+ data class StringWithMarkup (
5
+ @XmlElement(true ) @SerialName(" String" ) val string : String = " " ,
6
+ val markup : List <String > = emptyList()
7
+ )
You can’t perform that action at this time.
0 commit comments