Alberto,

I used the code you just gave to me. I'm trying to get a pointer to a QName
object, but it seems that that object is invalid.
I get the pointer to QName, but then no matter which method of QName I call
I get an exception (Access in invalid memory). 

XMLAttDefList& attrIter=pComplexType->getAttDefList();
for(unsigned int i=0;i<attrIter.getAttDefCount();i++)
{
    XMLAttDef& attr=attrIter.getAttDef(i);
    XMLAttDef::DefAttTypes ty = attr.getDefaultType();
    if(ty == XMLAttDef::Prohibited)
            continue;
    SchemaAttDef* pAttr=(SchemaAttDef*)&attr;
    QName* qname = pAttr->getAttName();
    unsigned int uriid = qname->getURI(); --> I always get an exception here
        // qname object is invalid
}

I noticed that you get the ComplexTypeInfo by reference and not a pointer 

--> ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement(); <--

(how do you do that?... I mean what is "complexTypeEnum?"...)

In contrast, I get a pointer to the ComplexTypeInfo object like the way
you indicated in one of your posts:

// xmlnode is a DOMNode*...
DOMPSVITypeInfo* psviType =
(DOMPSVITypeInfo*)xmlnode->getInterface(XMLUni::fgXercescInterfacePSVITypeIn
fo);
    if (!psviType)
        return false;
    const XMLCh* typeName =
psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Name);
    if (!typeName)
        return false;
    const XMLCh* typeURI =
psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Namespace)
;

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

    Grammar* pGrammar=FDOMParser->getGrammar(typeURI);
    if(!pGrammar && pGrammar->getGrammarType()!=Grammar::SchemaGrammarType)
        return false;

    SchemaGrammar* pSchema=(SchemaGrammar*)pGrammar;
    if(typeType!=XSTypeDefinition::COMPLEX_TYPE)
        return true;

    XMLBuffer typeKey(1023);
    typeKey.set(typeURI);
    typeKey.append(chComma);
    typeKey.append(typeName);
    RefHashTableOf<ComplexTypeInfo>* pSchemaTypes =
pSchema->getComplexTypeRegistry();
    ComplexTypeInfo* pComplexType =
pSchemaTypes->get(typeKey.getRawBuffer());


Thanks again, you help is being priceless!

Nicolas


-----Original Message-----
From: Alberto Massari [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 02, 2006 12:00 PM
To: Nicolas Tsokas
Cc: [email protected]
Subject: RE: Attribute namespace info through PSVI. Please help...!

At 11:45 AM 3/2/2006 +0200, Nicolas Tsokas wrote:
>Hi Alberto,
>
>Method getAttName() is not implemented in base class XMLAttDef. It's only
>implemented in class SchemaAttDef.

You're right, I read my code too quickly.... This is what I do:

ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement();
if(curTypeInfo.hasAttDefs())
{
   XMLAttDefList& attrIter=curTypeInfo.getAttDefList();
   for(unsigned int i=0;i<attrIter.getAttDefCount();i++)
   {
     XMLAttDef& attr=attrIter.getAttDef(i);
     XMLAttDef::DefAttTypes ty = attr.getDefaultType();
     if(ty == XMLAttDef::Prohibited)
       continue;
     SchemaAttDef* pAttr=(SchemaAttDef*)&attr;
     if(pAttr->getAttName()->getURI()==qname.getURI())
       szName=pAttr->getFullName();
     else
       szName=getFullName(pAttr->getAttName());
   }
}

and this code has never failed.
If this doesn't help you, can you send the entire testcase you are 
using (C++ files and schema)?

Thanks,
Alberto


>Is there any way of extracting namespace/prefix information from XMLAttDef?
>
>Many thanks for replying to me...
>
>Nicolas
>
>
>-----Original Message-----
>From: Alberto Massari [mailto:[EMAIL PROTECTED]
>Sent: Thursday, March 02, 2006 11:08 AM
>To: [email protected]
>Subject: RE: Attribute namespace info through PSVI. Please help...!
>
>Hi Nicolas,
>
>At 02:50 PM 3/1/2006 +0200, Nicolas Tsokas wrote:
> >Hi Alberto...
> >
> >Thanks indeed for your answer...
> >
> >Yes, I've tried getAttName()... And it always gives me a pointer to
> >an invalid QName object. I mean qname->getPrefix(),
qname->getLocalPart(),
> >etc. they all cause an exception...
>
>That's strange, as I have used it successfully.
>
>
> >Here's my code: (the previous part of the code is the one you posted
> >on xerces-c mail archives on 02 Feb 2005)...
> >
> >ComplexTypeInfo* pComplexType =
pSchemaTypes->get(typeKey.getRawBuffer());
> >if (!pComplexType->hasAttDefs())
> >         return;
> >
> >SchemaAttDefList& attDefList =
> >         (SchemaAttDefList&)pComplexType->getAttDefList();
> >unsigned int attCount = attDefList.getAttDefCount();
> >for (unsigned int i=0; i<attCount; i++)
> >{
> >         SchemaAttDef& attDef = (SchemaAttDef&)attDefList.getAttDef(i);
> >         attributes->add(attDef.getFullName());
> >         const QName* qnm = attDef.getAttName();
> >         const XMLCh* aaa = qnm->getPrefix();
> >}
>
>Just to double check; can you remove the casts and work directly off
>the virtual table (this is the code I have been using in my app)? Like
this:
>
>XMLAttDefList& attDefList = pComplexType->getAttDefList();
>unsigned int attCount = attDefList.getAttDefCount();
>for (unsigned int i=0; i<attCount; i++)
>{
>          XMLAttDef& attDef = attDefList.getAttDef(i);
>          attributes->add(attDef.getFullName());
>          const QName* qnm = attDef.getAttName();
>          const XMLCh* aaa = qnm->getPrefix();
>}
>
>Hope this helps,
>Alberto
>
> >Thanks again Alberto... I really appreciate your help.
> >
> >Nicolas
> >
> >
> >
> >
> >-----Original Message-----
> >From: Alberto Massari [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, March 01, 2006 2:32 PM
> >To: [email protected]
> >Subject: Re: Attribute namespace info through PSVI. Please help...!
> >
> >Hi Nicolas,
> >
> >At 02:00 PM 3/1/2006 +0200, Nicolas Tsokas wrote:
> > >Hi everyone,
> > >
> > >I'm trying to obtain info about an element using
> > >PSVI (trying to resolve allowed children and attributes
> > >for that specific element).
> > >
> > >I obtain a pointer to the corresponding
> > >ComplexTypeInfo object which describes the element. Then I
> > >get the names and namespaces of the allowed
> > >children for that element by using ComplextTypeInfo's
> > >elementAt(index) method and by obtaining
> > >pointers to SchemaElementDecl objects.
> > >
> > >I have a problem with the attributes, though:
> > >I get the list of attributes through
> > >getAttDefList() method of the ComplexTypeInfo object.
> > >Then I obtain a SchemaAttDef for each attribute.
> > >SchemaAttDef gives the attribute's name
> > >through its method getFullName(), but I cannot
> > >figure out any way of finding their namespaces
> > >(or namespace prefixes). Am I missing something?...
> >
> >Have you tried with SchemaAttDef::getAttName()?
> >The QName* it returns should give you prefix, local name and namespace
URI.
> >
> >Alberto
> >
> > >
> > >Can anybody please help me?
> > >
> > >Thank you so much in advance.
> > >
> > >Nicolas
> >
> >
> >---------------------------------------------------------------------
> >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]
>
>
>---------------------------------------------------------------------
>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