|
25 | 25 | import org.apache.logging.log4j.LogManager;
|
26 | 26 | import org.apache.logging.log4j.Logger;
|
27 | 27 |
|
| 28 | +import org.exist.util.XMLReaderPool; |
28 | 29 | import org.exist.util.io.FastByteArrayOutputStream;
|
29 | 30 | import org.w3c.dom.Element;
|
30 | 31 | import org.w3c.dom.Node;
|
|
60 | 61 | import java.sql.Statement;
|
61 | 62 | import java.sql.Timestamp;
|
62 | 63 | import java.sql.Types;
|
63 |
| -import javax.xml.parsers.SAXParser; |
64 |
| -import javax.xml.parsers.SAXParserFactory; |
65 | 64 | import org.exist.dom.memtree.AppendingSAXAdapter;
|
66 | 65 | import org.exist.dom.memtree.ReferenceNode;
|
67 | 66 | import org.exist.dom.memtree.SAXAdapter;
|
@@ -263,17 +262,21 @@ public ExecuteFunction( XQueryContext context, FunctionSignature signature )
|
263 | 262 | // Add a null indicator attribute if the value was SQL Null
|
264 | 263 | builder.addAttribute( new QName( "null", SQLModule.NAMESPACE_URI, SQLModule.PREFIX ), "true" );
|
265 | 264 | } else {
|
266 |
| - |
267 |
| - SAXParserFactory factory = SAXParserFactory.newInstance(); |
268 |
| - factory.setNamespaceAware(true); |
269 | 265 | InputSource src = new InputSource(sqlXml.getCharacterStream());
|
270 |
| - SAXParser parser = factory.newSAXParser(); |
271 |
| - XMLReader xr = parser.getXMLReader(); |
272 |
| - |
273 |
| - SAXAdapter adapter = new AppendingSAXAdapter(builder); |
274 |
| - xr.setContentHandler(adapter); |
275 |
| - xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter); |
276 |
| - xr.parse(src); |
| 266 | + final XMLReaderPool parserPool = context.getBroker().getBrokerPool().getParserPool(); |
| 267 | + XMLReader reader = null; |
| 268 | + try { |
| 269 | + reader = parserPool.borrowXMLReader(); |
| 270 | + |
| 271 | + SAXAdapter adapter = new AppendingSAXAdapter(builder); |
| 272 | + reader.setContentHandler(adapter); |
| 273 | + reader.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter); |
| 274 | + reader.parse(src); |
| 275 | + } finally { |
| 276 | + if (reader != null) { |
| 277 | + parserPool.returnXMLReader(reader); |
| 278 | + } |
| 279 | + } |
277 | 280 | }
|
278 | 281 | } catch(Exception e) {
|
279 | 282 | throw new XPathException("Could not parse column of type SQLXML: " + e.getMessage(), e);
|
|
0 commit comments