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 @@ -131,6 +131,25 @@ class TestCommon {
131
131
assertEquals(contentText, serialized)
132
132
}
133
133
134
+
135
+ @Test
136
+ fun deserializeXmlWithEntity () {
137
+ val xml = XML {
138
+ repairNamespaces = true
139
+ policy = DefaultXmlSerializationPolicy (pedantic = false , autoPolymorphic = false )
140
+ }
141
+
142
+ val expected = StringWithMarkup (" Chloroacetic acid, >=99%" )
143
+
144
+ val actual = xml.decodeFromString<StringWithMarkup >(
145
+ " <StringWithMarkup xmlns=\" http://pubchem.ncbi.nlm.nih.gov/pug_view\" >\n " +
146
+ " <String>Chloroacetic acid, >=99%</String>\n " +
147
+ " </StringWithMarkup>"
148
+ )
149
+ assertEquals(expected, actual)
150
+ }
151
+
152
+
134
153
@Serializable
135
154
data class IntList (val values : List <Int >)
136
155
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