You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by ss ak <ss...@gmail.com> on 2009/07/28 20:37:43 UTC

xsd to XML

Hi,

I am new to this API...would like to create an XML from an XSD.
and using SCMPrint as an example...

1.This does not take an element  which is COMPLEX inside...only top element
can be complex....

But i have nested complex elements..any idea how to take care...

2. what parameters to i need to set to create a DOM Tree while parsing this
XSD...
here we are loading Grammar and traversing using namespaces....Is this the
way or can we use API in any means in creating an XML from XSD...

Please help needed and need of the work of my work....

Thanks,,,,,

parser->loadGrammar(xsdFile, Grammar::SchemaGrammarType, true);
XERCES_STD_QUALIFIER cout << "********** Printing out information from
Schema **********" << "\n\n";
bool updatedXSModel;
XSModel *xsModel = grammarPool->getXSModel(updatedXSModel);
if (xsModel)
{
StringList *namespaces = xsModel->getNamespaces();
for (unsigned i = 0; i < namespaces->size(); i++) {
XERCES_STD_QUALIFIER cout << "Processing Namespace: ";
const XMLCh *nameSpace = namespaces->elementAt(i);
if (nameSpace && *nameSpace)
XERCES_STD_QUALIFIER cout << StrX(nameSpace);
XERCES_STD_QUALIFIER cout <<
"\n============================================" << XERCES_STD_QUALIFIER
endl << XERCES_STD_QUALIFIER endl;
processElements(xsModel->getComponentsByNamespace(XSConstants::ELEMENT_DECLARATION,
nameSpace));
processTypeDefinitions(xsModel->getComponentsByNamespace(XSConstants::TYPE_DEFINITION,
nameSpace));
}
}
else
{
XERCES_STD_QUALIFIER cout << "No XSModel to print" << "\n\n";
}