MCPcopy Create free account
hub / github.com/apache/freemarker / parse

Method parse

src/main/java/freemarker/ext/dom/NodeModel.java:168–186  ·  view source on GitHub ↗

Create a NodeModel from a SAX input source. Adjacent text nodes will be merged (and CDATA sections are considered as text nodes). @param removeComments whether to remove all comment nodes (recursively) from the tree before processing @param removePIs whether to remove all processing instruction node

(InputSource is, boolean removeComments, boolean removePIs)

Source from the content-addressed store, hash-verified

166 * (recursively from the tree before processing
167 */
168 static public NodeModel parse(InputSource is, boolean removeComments, boolean removePIs)
169 throws SAXException, IOException, ParserConfigurationException
170 {
171 DocumentBuilder builder = getDocumentBuilderFactory().newDocumentBuilder();
172 if (errorHandler != null) builder.setErrorHandler(errorHandler);
173 Document doc = builder.parse(is);
174 if (removeComments && removePIs) {
175 simplify(doc);
176 } else {
177 if (removeComments) {
178 removeComments(doc);
179 }
180 if (removePIs) {
181 removePIs(doc);
182 }
183 mergeAdjacentText(doc);
184 }
185 return wrap(doc);
186 }
187
188 /**
189 * Create a NodeModel from an XML input source. By default,

Callers 9

setUpMethod · 0.95
transformMethod · 0.95
readConfigMethod · 0.45
testDateToUTCStringMethod · 0.45
testLocalTimeMethod · 0.45
testAccuracyMethod · 0.45
getDocumentMethod · 0.45
processMethod · 0.45
parseXmlMethod · 0.45

Calls 7

simplifyMethod · 0.95
removeCommentsMethod · 0.95
removePIsMethod · 0.95
mergeAdjacentTextMethod · 0.95
wrapMethod · 0.95
setErrorHandlerMethod · 0.80

Tested by 5

setUpMethod · 0.76
readConfigMethod · 0.36
testDateToUTCStringMethod · 0.36
testLocalTimeMethod · 0.36
testAccuracyMethod · 0.36