Fixed issue where empty narrative caused a StringIndexOutOfBoundsException

Fixed encoding issue on XmlParserTest so it'll run in windows
This commit is contained in:
b.debeaubien 2014-11-21 12:19:18 -05:00
parent 51f2ce1e37
commit 428af56c82
2 changed files with 9 additions and 7 deletions

View File

@ -71,15 +71,17 @@ public class XhtmlDt extends BasePrimitive<List<XMLEvent>> {
*/
@Override
public void setValueAsString(String theValue) throws DataFormatException {
String value = theValue.trim();
if (value.charAt(0) != '<') {
value = "<div>" + value + "</div>";
if (theValue == null || theValue.isEmpty()) {
super.setValueAsString(null);
} else {
String value = theValue.trim();
if (value.charAt(0) != '<') {
value = "<div>" + value + "</div>";
}
super.setValueAsString(value);
}
super.setValueAsString(value);
}
public boolean hasContent() {
return getValue() != null && getValue().size() > 0;
}

View File

@ -89,7 +89,7 @@ public class XmlParserTest {
@Test
public void testProfileWithBoundCode() throws IOException {
String content = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/DMIXAuditException.xml"));
String content = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/DMIXAuditException.xml"), "UTF-8");
ourCtx.newXmlParser().parseResource(Profile.class, content);
}