Hi,

In the course of working on XQilla, I've been getting an IllegalArgumentException when I'm using the XMLGrammarPool with Xerces-C 2.8. Boris brought this to my attention, and it's slightly odd since it only seems to occur with attribute groups in schemas. I've attached sample code, XML and XSD that will reproduce the problem.

I realise I'm probably doing things that most people won't ever need to do with Xerces-C. Never-the-less is what I'm trying to do valid, and if so is the IllegalArgumentException a bug in Xerces-C?

John

--
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:            http://oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net
#include <iostream>

#include <xercesc/dom/DOM.hpp>
#include <xercesc/parsers/DOMBuilderImpl.hpp>
#include <xercesc/internal/XMLGrammarPoolImpl.hpp>
#include <xercesc/framework/XMLGrammarDescription.hpp>

XERCES_CPP_NAMESPACE_USE;
using namespace std;

int main(int argc, char *argv[])
{
  XMLPlatformUtils::Initialize();

  XMLGrammarPoolImpl *grpool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
    
  DOMBuilderImpl *xmlParser = new DOMBuilderImpl(0, XMLPlatformUtils::fgMemoryManager, grpool);
  xmlParser->setFeature(XMLUni::fgDOMNamespaces, true);
  xmlParser->setFeature(XMLUni::fgXercesSchema, true);
  xmlParser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);

  xmlParser->parseURI("test.xml");

  // we copy this gramamr and reset the parser one in the process.
  XMLGrammarPoolImpl *newgrpool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);

  RefHashTableOfEnumerator<Grammar> enumerator = grpool->getGrammarEnumerator();

  while(enumerator.hasMoreElements()) {
    Grammar &g = enumerator.nextElement();
    newgrpool->cacheGrammar(grpool->orphanGrammar(g.getGrammarDescription()->getGrammarKey()));
  }

  newgrpool->getXSModel();

  XMLPlatformUtils::Terminate();

  return 0;
}
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="test test.xsd"/>
<schema xmlns="http://www.w3.org/2001/XMLSchema";>
  <attributeGroup name="foo"/>
</schema>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to