From 0f7722cb0b88ab50b0e4ff22f492afae74c474b9 Mon Sep 17 00:00:00 2001 From: "peter.danner" Date: Wed, 2 May 2007 13:45:19 +0000 Subject: Added Map, that holds the NamespaceURIs of the grammarPool, to prevent multiple entries of one NamespaceURI git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@825 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../src/at/gv/egovernment/moa/util/DOMUtils.java | 41 +++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'common/src/at/gv/egovernment') diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java index fddf16944..95ee3aa4d 100644 --- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java +++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java @@ -94,9 +94,13 @@ public class DOMUtils { private static SymbolTable symbolTable = new SymbolTable(BIG_PRIME); /** Xerces schema grammar pool. */ private static XMLGrammarPool grammarPool = new XMLGrammarPoolImpl(); - + /** Map, that holds the NamespaceURIs of the grammarPool, to prevent multiple + * entries of one NamespaceURI */ + private static Set grammarNamespaces; + static { grammarPool.lockPool(); + grammarNamespaces = new HashSet(); } /** @@ -111,23 +115,28 @@ public class DOMUtils { throws IOException { XMLGrammarPreparser preparser; - // unlock the pool so that we can add another grammar - grammarPool.unlockPool(); - - // prepare the preparser - preparser = new XMLGrammarPreparser(symbolTable); - preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); - preparser.setProperty(GRAMMAR_POOL, grammarPool); - preparser.setFeature(NAMESPACES_FEATURE, true); - preparser.setFeature(VALIDATION_FEATURE, true); + if (!grammarNamespaces.contains(systemId)) { - // add the grammar to the pool - preparser.preparseGrammar( + grammarNamespaces.add(systemId); + + // unlock the pool so that we can add another grammar + grammarPool.unlockPool(); + + // prepare the preparser + preparser = new XMLGrammarPreparser(symbolTable); + preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); + preparser.setProperty(GRAMMAR_POOL, grammarPool); + preparser.setFeature(NAMESPACES_FEATURE, true); + preparser.setFeature(VALIDATION_FEATURE, true); + + // add the grammar to the pool + preparser.preparseGrammar( XMLGrammarDescription.XML_SCHEMA, - new XMLInputSource(null, systemId, null, inputStream, null)); - - // lock the pool again so that schemas are not added automatically - grammarPool.lockPool(); + new XMLInputSource(null, systemId, null, inputStream, null)); + + // lock the pool again so that schemas are not added automatically + grammarPool.lockPool(); + } } /** -- cgit v1.2.3