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