Hello,

I have been looking through the xerces mail archives, and still cannot seem to get my code to work. My basic question is: if I am walking the DOM tree using xerces-c++, how can I get at the PSVI information from a DOMNode pointer (which I call curNode in the code samples below)? I found this code to work:

        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;

        if (!strcmp(S(typeName), "string"))  return DMT_STRING;
        if (!strcmp(S(typeName), "boolean")) return DMT_BOOL;
        if (!strcmp(S(typeName), "integer") ||
                !strcmp(S(typeName), "short") ||
                !strcmp(S(typeName), "long")) return DMT_INT;
        if (!strcmp(S(typeName), "double") ||
                !strcmp(S(typeName), "float")) return DMT_DOUBLE;

which is great, but it only handles finding the type of an element when the type is an attribute on that element. But I want to find out everything about an element, including when it is a complex type or a simple type with restrictions. For instance, if the schema says:

                                                        <xs:element name="Years">
                                                                <xs:simpleType>
                                                                        <xs:restriction base="xs:integer">
                                                                                <xs:minInclusive value="1900"/>
                                                                                <xs:maxInclusive value="3000"/>
                                                                        </xs:restriction>
                                                                </xs:simpleType>
                                                        </xs:element>

how can I find out the minInclusive and maxInclusive values straight from the DOMNode pointer to the "Years" element? I have tried code such as:

        PSVIElement *psviElem = (PSVIElement *) curNode;
        XSTypeDefinition *def = psviElem->getTypeDefinition();
        cout<<psviElem->getValidity()<<endl;
        enum XSTypeDefinition::TYPE_CATEGORY cat = def->getTypeCategory();
        cout<<cat<<endl;
        if (cat == XSTypeDefinition::COMPLEX_TYPE)
        {
                cout<<"yes"<<endl;
        }

but this code produces garbage in the cout's.

Can you help me?

Thanks much,

Jim

Reply via email to