Don't preserve XML instruction declarations inside JSON narrative blocks
This commit is contained in:
parent
d3cf93cf04
commit
746e249346
|
@ -397,6 +397,10 @@ public class XhtmlNode implements IBaseXhtml {
|
||||||
XhtmlDocument fragment = new XhtmlParser().parse(val, "div");
|
XhtmlDocument fragment = new XhtmlParser().parse(val, "div");
|
||||||
this.attributes = fragment.getAttributes();
|
this.attributes = fragment.getAttributes();
|
||||||
this.childNodes = fragment.getChildNodes();
|
this.childNodes = fragment.getChildNodes();
|
||||||
|
// Strip the <? .. ?> declaration if one was present
|
||||||
|
if (childNodes.size() > 0 && childNodes.get(0) != null && childNodes.get(0).getNodeType() == NodeType.Instruction) {
|
||||||
|
childNodes.remove(0);
|
||||||
|
}
|
||||||
this.content = fragment.getContent();
|
this.content = fragment.getContent();
|
||||||
this.name = fragment.getName();
|
this.name = fragment.getName();
|
||||||
this.nodeType= fragment.getNodeType();
|
this.nodeType= fragment.getNodeType();
|
||||||
|
|
|
@ -46,5 +46,14 @@ public class XhtmlNodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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>");
|
||||||
|
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", dt.getValueAsString());
|
||||||
|
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">help i'm a bug</div>", new XhtmlNode().setValue(dt.getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue