All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.thymeleaf.templateparser.xmlsax.XmlNonValidatingSAXTemplateParser 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 XmlNonValidatingSAXTemplateParser extends AbstractNonValidatingSAXTemplateParser { // Even if we are using validating XML templates, fragments cannot be validated due to the lack of // context, so we simply add enough information for a non-validating parser to consider it alright // (a document root element declaration). private static final String FRAGMENT_WRAP_START = "\n"; private static final String FRAGMENT_WRAP_END = ""; public XmlNonValidatingSAXTemplateParser(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)document.getFirstChild()).getChildren(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy