Karl,

Have you gotten any answers on this? 

I have the same problem - my requirements are to be able to introspect (love 
that word choice, BTW) a collection of 30+ nested schemata and display them in 
a single tree, with a separate pane displaying the properties of the selected 
entity. 

BTW, can anyone point me to the documentation for the features and properties 
supported by XMLGrammarPreparser? Hoping there will be something there to help 
me out...

Right now we're stuck at 2.2.1, and I can't see any nested items. The good news 
is that I can move up to the latest available that will ship by 4Q 2003 for 
this feature.

Thanks,
Thomas Cox

> -----Original Message-----
> From: Karl Mueller [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 04, 2003 1:32 PM
> To: [EMAIL PROTECTED]
> Subject: Sample code to "introspect" schemas?
> 
> 
> Hi,
> 
> This has already been proffered but I just checked the 
> archives and they are not available.
> 
> Does anyone know where I can get some code sample to 
> "introspect" schemas? I need to introspect a schema in order 
> for me to  generate a correct XML document from it.
> 
> Briefly, I'm trying to introspect a schema (which is really 
> composed of a number of files (i.e., via includes)) and I'm 
> able to get the global elements, attributes etc. but I'm 
> unsure how go from there? That is how do I build the contents 
> of a complex type or element which itself might be composed 
> of child complex types etc? For example, I tried getting the 
> complex type content (i.e., method getEnclosingCTDefinition 
> ()) for the following element and it came back unexpectedly 
> (for me) as null:
> 
> <element name = "Customer">
>       <complexType>
>               <sequence>
>                       <element name = "FirstName" type = "string" />
>                       <element name = "MiddleInitial" type = 
> "string" />
>                       <element name = "LastName" type = "string" />
>               </sequence>
>       </complexType>
> </element>
> 
> 
> Here is a code snippet that gathers the schema grammar for me:
> 
>       XMLSchemaLoader xmlSchemaLoader = new XMLSchemaLoader();
>       xmlSchemaLoader.setErrorHandler (this);
> 
>       XMLInputSource xmlInputSource = new XMLInputSource 
> (null, schemaFile.
>         getName (), schemaFile.toURI ().getPath ());
> 
>       FileInputStream inputStream = null;
>       try
>       {
>               inputStream = new FileInputStream (schemaFile);
>       }
>       catch (Exception pException) { pException.printStackTrace (); }
> 
>       xmlInputSource.setByteStream (inputStream);
> 
>       XSGrammar schemaGrammar = null;
>       try
>       {
>               schemaGrammar = (XSGrammar) 
> xmlSchemaLoader.loadGrammar (
>                 xmlInputSource);
>               XSModel schemaModel = schemaGrammar.toXSModel();
> 
>               XSNamedMap elementComponents = 
> pSchemaModel.getComponents (
>                 XSConstants.ELEMENT_DECLARATION);
>               System.out.println ("Element components begin 
> (" + elementComponents.
>                 getLength () + ")");
> 
>               for (int i = 0; i < elementComponents.getLength (); i++)
>               {
>                       XSElementDeclaration elementDeclaration 
> = (XSElementDeclaration)
>                         elementComponents.item (i);
>                       System.out.println ("\tNamespace:Name: 
> " + elementDeclaration.
>                         getNamespace () + ":" + 
> elementDeclaration.getName ());
>                       System.out.println ("\tConstraint 
> value: \"" + elementDeclaration.
>                         getConstraintValue() + "\"");
> 
>                       System.out.println ("\tType def name: 
> \"" + elementDeclaration.
>                         getTypeDefinition().getName () + "\"");
> 
>                       if 
> (elementDeclaration.getEnclosingCTDefinition() != null)
>                       {
>                               System.out.println 
> ("\tEnclosing ct type def name: \"" +
>                                 
elementDeclaration.getEnclosingCTDefinition> ().getParticle ().
>                                 getName () + "\"");
>                       }
>                       else
>                       {
>                               System.out.println ("\tNo 
> complex type definition...");
>                       }
> 
>                       System.out.println ();
>               }
>               System.out.println ("Element components end...\n");
>       }
>       catch (Exception pException)
>       {
>               pException.printStackTrace ();
>       }
> 
> One final note: as I mentioned above my schema is really 
> composed of a number of files which are brought together by 
> "include" statements and I'm hoping that all I need to do is 
> point Xerces to my "lead" .xsd file and that all the included 
> files will automatically be brought in.
> 
> Thanks.
> 
> _____________________________________________
> Karl R. Mueller
> [EMAIL PROTECTED] _____________________________________________
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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

Reply via email to