Hi Jim,

At 14.53 01/02/2005 -0800, brutocao wrote:
Alberto,

Thanks, that was very helpful. I cut and pasted in the SEnumVal code and I am now traversing the schema info. Now I want to only consider my node of interest, which you have let me know is found with getGrammar(uri).

curNode is the pointer to the DOMNode of interest. In trying to find the namespace URI for this node, I tried this and it failed:

SchemaGrammar *gram = (SchemaGrammar *) parser->
getGrammar(((PSVIElement *) curNode)->getElementDeclaration()->getNamespace());


What would be the correct syntax?

As a suggestion for the future, every time you need to write a cast on an object, there is something wrong....you cannot take a DOMNode and treat it as it were a PSVIElement; at best, you will get unexpected results, but most likely your application will crash.


Let's start from the code you originally posted:

        const XMLCh *typeName;
        DOMPSVITypeInfo *psviType;

        psviType = (DOMPSVITypeInfo*)
                curNode->getInterface(XMLUni::fgXercescInterfacePSVITypeInfo);
        if (!psviType) return DMT_NONE;

typeName = psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Name);
if (!typeName) return DMT_NONE;


Now let's get the URI for the type:

const XMLCh *typeURI=psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Namespace);

Then ask for which type (simple vs complex) we have to search:

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

Finally, ask the parser for the type definition:

Grammar* pGrammar=parser.getGrammar(typeURI);
if(pGrammar && pGrammar->getGrammarType()==Grammar::SchemaGrammarType)
{
SchemaGrammar* pSchema=(SchemaGrammar*)pGrammar;
if(typeType==XSTypeDefinition::COMPLEX_TYPE)
{
XMLBuffer typeKey(1023);
typeKey.set(typeURI);
typeKey.append(chComma);
typeKey.append(typeName);
ComplexTypeInfo* pComplexType=pSchema->getComplexTypeRegistry()->get(typeKey.getRawBuffer());
}
else
{
DatatypeValidator* pSimpleType=pSchema->getDatatypeRegistry()->getDatatypeValidator(typeName);
}
}



Alberto



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



Reply via email to