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)
| 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, |