Finally I managed to make Xerces schema infrastructure to help me create a test 
schema object graph as shown by this testcase - test:


  | /**
  |     * Test Xerces ability to create XML schema
  |     * @throws Exception
  |     */
  |    public void testSchemaCreation() throws Exception
  |    {
  |       String typeNS = "http://org.jboss/types";;
  |       SchemaGrammar sg = new SchemaGrammar(typeNS, new XSDDescription(), 
new SymbolTable());
  |       XSComplexTypeDecl ct = new XSComplexTypeDecl();
  |       ct.setName("HelloObj");
  |       XSParticleDecl xsp = new XSParticleDecl();
  |       xsp.fType = XSParticleDecl.PARTICLE_ELEMENT;
  |       XSElementDecl xsel = new XSElementDecl();
  |       xsel.fName = "msg";
  |       xsp.fValue = xsel;
  | 
  |       ct.setValues("msg", typeNS, null, XSConstants.DERIVATION_NONE,
  |               XSConstants.DERIVATION_NONE, XSConstants.DERIVATION_NONE,
  |               XSConstants.DERIVATION_NONE, false, null, null, xsp, new 
XSObjectListImpl(null, 0));
  | 
  |       sg.addGlobalTypeDecl(ct);  //Always add global complex types to 
global types
  |       //sg.addComplexTypeDecl(ct, new SimpleLocator());  /**THIS DOES NOT 
WORK**/
  | 
  |       XSModel xsmodel = sg.toXSModel();
  |       assertNotNull("XSModel is null?", xsmodel);
  | 
  |       XSNamedMap xsnamedmap = 
xsmodel.getComponentsByNamespace(typedef,typeNS);
  |       assertNotNull("XSNamedMap is null?", xsnamedmap);
  |       assertEquals(1, xsnamedmap.getLength());
  |       assertEquals("HelloObj", xsnamedmap.item(0).getName());
  |    }
  | 
  | 

The test run is:

  | jboss-head/webservice/test] anil% ant 
-Dtest=org.jboss.test.ws.tools.xmlschema.XercesSchemaParserTestCase one-test
  | 
  | 
  | one-test:
  |     [junit] Running 
org.jboss.test.ws.tools.xmlschema.XercesSchemaParserTestCase
  |      [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 1.913 sec
  | 

Not a easy effort, but I hope it was worth it.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3874149#3874149

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3874149


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to