< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/dom3/DOM3TreeWalker.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -366,12 +366,10 @@
* Optimized dispatch of characters.
*/
private final void dispatachChars(Node node)
throws org.xml.sax.SAXException {
if (fSerializer != null) {
- this.fSerializer.characters(node);
- } else {
String data = ((Text) node).getData();
this.fSerializer.characters(data.toCharArray(), 0, data.length());
}
}
@@ -1064,11 +1062,13 @@
// The filter should not apply in this case, since the
// EntityReference is not being expanded.
// should we pass entity reference nodes to the filter???
}
- if (fLexicalHandler != null) {
+ // if "entities" is true, or EntityReference node has no children,
+ // it will be serialized as the form "&entityName;" in the output.
+ if (fLexicalHandler != null && ((fFeatures & ENTITIES) != 0 || !node.hasChildNodes())) {
// startEntity outputs only Text but not Element, Attr, Comment
// and PI child nodes. It does so by setting the m_inEntityRef
// in ToStream and using this to decide if a node is to be
// serialized or not.
< prev index next >