I parse an XML File using a DOMBuilderImpl and use a XML
Schema to validate it.
Then i would like to get, for any given DOMNode, the
information of the corresponding type.

For now i've tried something like that :

const XMLCh *typeName;

DOMPSVITypeInfo *typeInfo = (DOMPSVITypeInfo*)
domNode->getInterface(XMLUni::fgXercescInterfacePSVITypeInfo);
if (typeInfo)
{
        typeName =
typeInfo->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Name);
        if (typeName)
        {
                const XMLCh *typeURI =
typeInfo->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Namespace);

                XSTypeDefinition::TYPE_CATEGORY typeType =
(XSTypeDefinition::TYPE_CATEGORY)typeInfo->getNumericProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Type);

                Grammar* pGrammar = parser->getGrammar(typeURI);
                if(pGrammar &&
pGrammar->getGrammarType()==Grammar::SchemaGrammarType)
                {
                        SchemaGrammar* pSchemaGrammar = 
(SchemaGrammar*)pGrammar;
                        if(typeType==XSTypeDefinition::COMPLEX_TYPE)
                        {
                                XMLBuffer typeKey(1023);
                                typeKey.set(typeURI);
                                typeKey.append(chComma);
                                typeKey.append(typeName);
                                ComplexTypeInfo* pComplexType =
pSchemaGrammar->getComplexTypeRegistry()->get(typeKey.getRawBuffer());
                                cout << "type : " <<
XMLString::transcode(pComplexType->getTypeName()) << endl;
                        }
                        else
                        {
                                DatatypeValidator* pSimpleType =
pSchemaGrammar->getDatatypeRegistry()->getDatatypeValidator(typeName);
                                if(pSimpleType)
                                {
                                        switch( pSimpleType->getType() )
                                        {
                                        case DatatypeValidator::String:         
cout << "string";
     break;
                                        case DatatypeValidator::AnyURI:         
cout << "AnyURI";
     break;
                                        [snip]
                                        }
                                        cout << endl;
                                }
                        }
                }
        }
}

so it gives me the names of the types but i don't know how to
get more info (like the values of an enumeration), i've looked
at the SCMPrint example but i can't find a way to get from
what i have to a XSTypeDefinition.
Any help is welcome :)

By the way, as a minor problem, i have the same problem as
stated there with my code :
http://www.mail-archive.com/[email protected]/msg14794.html
The DatatypeValidator is null on anonymous simple types, and i
don't know why either.

Regards,
Adrien de Sentenac

Accédez au courrier électronique de La Poste : www.laposte.net ; 
3615 LAPOSTENET (0,34€/mn) ; tél : 08 92 68 13 50 (0,34€/mn)



Reply via email to