X4O: Removed iterator for tree walker and bettered tag folding code
This commit is contained in:
parent
045f6d07f6
commit
9638d876b5
6 changed files with 27 additions and 16 deletions
|
|
@ -43,7 +43,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
*/
|
||||
public class SAX3WriterEnum<TAG extends Enum<?>, TAG_WRITER extends ContentWriter> implements SAX3WriterEnumHammer<TAG>, Closeable {
|
||||
|
||||
private final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||
static private final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
|
||||
private final TAG_WRITER contentWriter;
|
||||
private final String tagNamespaceUri;
|
||||
private final String tagNamespacePrefix;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import org.xml.sax.helpers.AttributesImpl;
|
|||
*/
|
||||
public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag, SAX3WriterXml> {
|
||||
|
||||
static public final List<String> HTML_VOID_TAGS = Collections.unmodifiableList(Tag.valuesVoidElement());
|
||||
static private final List<String> HTML_VOID_TAGS = Collections.unmodifiableList(Tag.valuesVoidElementAsString());
|
||||
|
||||
public SAX3WriterHtml(Writer out, String encoding) {
|
||||
super(new SAX3WriterXml(out, encoding), "", SAX3XMLConstants.NULL_NS_URI);
|
||||
|
|
@ -397,8 +397,12 @@ public class SAX3WriterHtml extends SAX3WriterEnum<SAX3WriterHtml.Tag, SAX3Write
|
|||
return voidElement;
|
||||
}
|
||||
|
||||
static public List<String> valuesVoidElement() {
|
||||
return Arrays.stream(values()).filter(v -> v.voidElement()).map(v -> v.name()).toList();
|
||||
static public List<Tag> valuesVoidElement() {
|
||||
return Arrays.stream(values()).filter(v -> v.voidElement()).toList();
|
||||
}
|
||||
|
||||
static public List<String> valuesVoidElementAsString() {
|
||||
return valuesVoidElement().stream().map(v -> v.name()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -477,11 +477,11 @@ public class AbstractContentWriterHandler implements ContentHandler, Closeable {
|
|||
}
|
||||
|
||||
private boolean allowEndElementFolding(String tag) {
|
||||
if (getPropertyConfig().getProperty(OUTPUT_FOLD_EMPTY_TAGS) == null) {
|
||||
return true;
|
||||
}
|
||||
if (foldEmptyTags == null) {
|
||||
foldEmptyTags = new HashSet<>();
|
||||
if (getPropertyConfig().getProperty(OUTPUT_FOLD_EMPTY_TAGS) != null) {
|
||||
foldEmptyTags.addAll(getPropertyConfig().getPropertyList(OUTPUT_FOLD_EMPTY_TAGS));
|
||||
}
|
||||
foldEmptyTags = new HashSet<>(getPropertyConfig().getPropertyList(OUTPUT_FOLD_EMPTY_TAGS));
|
||||
}
|
||||
if (foldEmptyTags.isEmpty()) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue