org.thymeleaf.templateparser.xmlsax.XhtmlAndHtml5NonValidatingSAXTemplateParser Maven / Gradle / Ivy
package org.thymeleaf.templateparser.xmlsax;
import java.util.List;
import org.thymeleaf.dom.Document;
import org.thymeleaf.dom.NestableNode;
import org.thymeleaf.dom.Node;
/**
*
* Parses XML documents, using a standard SAX parser.
*
*
*
* This implementation populates tree nodes with detailed location
* information (document name and line number).
*
*
* @since 2.0.0
*
* @author Guven Demir
* @author Daniel Fernández
*
*/
public final class XhtmlAndHtml5NonValidatingSAXTemplateParser extends AbstractNonValidatingSAXTemplateParser {
// This fragment start is valid for both HTML5 and non-validating XHTML (being a fragment and non-validating,
// there is no need to add DTDs).
private static final String FRAGMENT_WRAP_START = "\n";
private static final String FRAGMENT_WRAP_END = "";
public XhtmlAndHtml5NonValidatingSAXTemplateParser(final int poolSize) {
super(poolSize);
}
@Override
protected final String wrapFragment(final String fragment) {
return FRAGMENT_WRAP_START + fragment + FRAGMENT_WRAP_END;
}
@Override
protected final List unwrapFragment(final Document document) {
return ((NestableNode)((NestableNode)((NestableNode)document.getFirstChild()).getFirstChild()).getFirstChild()).getChildren();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy