Well,

I've been digging around a lot to understand what Xerces does and does
not allow and there seems to be some problem with Xerces here. If I
follow your tip and use the ContentSpecNode I end up in a dead end. I
can get the ContentSpec, but it doesn't do me much good, all that it
seems to allow is retrieving a "formatted content model", sometimes:

ContentSpecNode* pSpecNode = element.getContentSpec();
if ( pSpecNode )
{
        XMLElementDecl* pElemDecl = pSpecNode->getElementDecl();
        if ( pElemDecl )
        {
                XMLCh const* szModel =
pElemDecl->getFormattedContentModel();
        }
} 

Alternatively I can get the content model another way by doing this:    

XMLContentModel* pModel = element.getContentModel();

Where the 'element' came from SchemaGrammar::getElemEnumerator().

But casting pModel to something like SimpleContentModel doesn't help
because the class ContentLeafNameTypeVector isn't exported from Xerces
so it generates a link error (even though XMLContentModel let's you
access it with an API):

void XsdGraph::GetContentVector(SimpleContentModel* pModel)
{
ContentLeafNameTypeVector* pVector =
pModel->getContentLeafNameTypeVector();
        
if ( pVector )
{
        for ( unsigned int i = 0; i < pVector->getLeafCount(); i++ )
        {
        wcout <<
                L"Name: " << pVector->getLeafNameAt(i)->getLocalPart()
<<
                L" Type: " << pVector->getLeafTypeAt(i) << endl;
        }
}
}

So you have apparently two designs here: one internal to the library and
one for clients of the library, or so it seems.

Anyways, I'm back at my original question:  what's the way to get the
list of parent/child relationships in a schema (elements and their
sub-elements, types and their sub-types) in order to build something
like a dependency graph from the schema elements?

Yours,

Elisha Berns

> -----Original Message-----
> From: Gareth Reakes [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 18, 2005 6:51 AM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: Advanced novice question about PSVI
> 
> Hey,
> 
> >
> > There is a general mapping between schema types and application
classes.
> > Think of it as a way to save an application as a graph provided you
know
> > what the node definitions are ahead of time.
> >
> 
> Good, that will help a lot.
> 
> 
> >
> > Well I see this in the PSVI classes and I have started development
on
> > it, but here is really where my questions are:  How do you get all
the
> > sub elements of complexContent or other composite types?
> 
> Take a look at the Grammar class. This will lead you on to things like
> SchemaElementDecl which has getContentSpec. That method will give you
a
> content model.
> 
> 
> Regards,
> 
> Gareth
> 
> --
> Gareth Reakes, Managing Director      Parthenon Computing
> +44-1865-811184                  http://www.parthcomp.com
> 
> ---------------------------------------------------------------------
> 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