Java Code Examples for org.hl7.fhir.utilities.xhtml.XhtmlNode#setValueAsString()

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#setValueAsString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XhtmlNodeTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * See https://github.com/jamesagnew/hapi-fhir/issues/1658
 */
@Test
public void testLangAttributePreserved() {
  XhtmlNode dt = new XhtmlNode();
  dt.setValueAsString("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>");
  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>", dt.getValueAsString());
  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
}
 
Example 2
Source File: XhtmlNodeTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseRsquo() {
  XhtmlNode dt = new XhtmlNode();
  dt.setValueAsString("It&rsquo;s January again");
  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">It’s January again</div>", dt.getValueAsString());
  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">It’s January again</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
}
 
Example 3
Source File: XhtmlNodeTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessingInstructionNotPreserved() {
  XhtmlNode dt = new XhtmlNode();
  dt.setValueAsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>");
  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", dt.getValueAsString());
  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
}
 
Example 4
Source File: XhtmlNodeTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseXhtmlQualified() {

  XhtmlNode node = new XhtmlNode();
  node.setValueAsString("<xhtml:div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">" +
    "<xhtml:img src=\"http://pbs.twimg.com/profile_images/544507893991485440/r_vo3uj2_bigger.png\" alt=\"Twitter Avatar\"/>" +
    "@fhirabend" +
    "</xhtml:div>");

  String output = node.getValueAsString();
  ourLog.info(output);

  Assertions.assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\"><img src=\"http://pbs.twimg.com/profile_images/544507893991485440/r_vo3uj2_bigger.png\" alt=\"Twitter Avatar\"/>@fhirabend</div>", output);
}
 
Example 5
Source File: XhtmlNodeTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializable() throws IOException {
  XhtmlNode node = new XhtmlNode();
  node.setValueAsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><div xmlns=\"http://www.w3.org/1999/xhtml\">Test</div>");

  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  ObjectOutputStream oout = new ObjectOutputStream(bout);
  oout.writeObject(node);
}