Skip to content

Commit 0bef29d

Browse files
Handle XML non-root content
1 parent 8688879 commit 0bef29d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public final class TypeConverter {
113113
public static final String ERROR_MESSAGE_UNION_START = "{";
114114
public static final String ERROR_MESSAGE_UNION_END = "}";
115115
public static final String ERROR_MESSAGE_UNION_SEPARATOR = "or";
116-
public static final String XML_START_ELEMENT = "<";
116+
public static final String XML_DECLARATION = "<?xml ";
117117

118118
public static Object convertValues(Type targetType, Object inputValue) {
119119
Type inputType = TypeChecker.getType(inputValue);
@@ -975,10 +975,10 @@ public static BDecimal stringToDecimal(String value) throws NumberFormatExceptio
975975

976976
public static BXml stringToXml(String value) throws BError {
977977
String xml = value.trim();
978-
if (!xml.startsWith(XML_START_ELEMENT)) {
979-
return XmlUtils.parse("<root>" + value + "</root>").children();
978+
if (xml.startsWith(XML_DECLARATION)) {
979+
return XmlUtils.parse(xml);
980980
}
981-
return XmlUtils.parse(xml);
981+
return XmlUtils.parse("<root>" + value + "</root>").children();
982982
}
983983

984984
public static RegExpValue stringToRegExp(String value) throws BError {

0 commit comments

Comments
 (0)