tng         2003/01/31 11:40:19

  Modified:    c/src/xercesc/parsers AbstractDOMParser.cpp
  Log:
  Fix DOMTypeInfo on ns attributes.
  
  Revision  Changes    Path
  1.36      +71 -73    xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp
  
  Index: AbstractDOMParser.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/AbstractDOMParser.cpp,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- AbstractDOMParser.cpp     29 Jan 2003 22:37:06 -0000      1.35
  +++ AbstractDOMParser.cpp     31 Jan 2003 19:40:18 -0000      1.36
  @@ -769,6 +769,12 @@
       chLatin_x, chLatin_s, chLatin_i, chNull
       };
   
  +    //get the list for use in the loop
  +    XMLAttDefList* defAttrs = 0;
  +    if(elemDecl.hasAttDefs()) {
  +        defAttrs = &elemDecl.getAttDefList();
  +    }
  +
       if (fScanner -> getDoNamespaces()) {    //DOM Level 2, doNamespaces on
   
          XMLBufBid bbURI(&fBufMgr);
  @@ -791,12 +797,6 @@
           elem = createElementNSNode(namespaceURI, elemQName.getRawBuffer());
           elemImpl = (DOMElementImpl *) elem;
   
  -        //get the list for use in the loop
  -        XMLAttDefList* defAttrs = 0;
  -        if(elemDecl.hasAttDefs()) {
  -            defAttrs = &elemDecl.getAttDefList();
  -        }
  -
           for (unsigned int index = 0; index < attrCount; ++index) {
               const XMLAttr* oneAttrib = attrList.elementAt(index);
               unsigned int attrURIId = oneAttrib -> getURIId();
  @@ -831,12 +831,14 @@
               }
   
               attr->setSpecified(oneAttrib->getSpecified());
  -            if(defAttrs != 0) {
  -                XMLAttDef *attDef = defAttrs->findAttDef(attrURIId, 
oneAttrib->getQName());
  -                if(attDef != 0) {
  -                    attr->setTypeInfo(attDef->getDOMTypeInfoName(), 
attDef->getDOMTypeInfoUri());
  -                    attDef->reset();
  -                }
  +
  +            XMLAttDef *attDef = 0;
  +            if(defAttrs != 0)
  +                attDef = defAttrs->findAttDef(attrURIId, oneAttrib->getQName());
  +
  +            if(attDef != 0) {
  +                attr->setTypeInfo(attDef->getDOMTypeInfoName(), 
attDef->getDOMTypeInfoUri());
  +                attDef->reset();
               }
               else {
                   const XMLCh *name = oneAttrib->getName();
  @@ -882,13 +884,22 @@
                   fDocument->fNodeIDMap->add(attr);
                   attr->fNode.isIdAttr(true);
               }
  +
  +            XMLAttDef *attDef = 0;
  +            if(defAttrs != 0)
  +                attDef = defAttrs->findAttDef(oneAttrib -> getURIId(), 
oneAttrib->getQName());
  +
  +            if(attDef != 0) {
  +                attr->setTypeInfo(attDef->getDOMTypeInfoName(), 
attDef->getDOMTypeInfoUri());
  +                attDef->reset();
  +            }
  +
           }
       }
   
       // set up the default attributes
  -     if (elemDecl.hasAttDefs())
  +     if (defAttrs != 0)
        {               
  -        XMLAttDefList* defAttrs = &elemDecl.getAttDefList();
           XMLAttDef* attr = 0;
   
           DOMAttrImpl * insertAttr = 0;
  @@ -903,71 +914,58 @@
               {
   
                   if (fScanner->getDoNamespaces())
  -                    {
  -                        // DOM Level 2 wants all namespace declaration attributes
  -                        // to be bound to "http://www.w3.org/2000/xmlns/";
  -                        // So as long as the XML parser doesn't do it, it needs to
  -                        // done here.
  -                        const XMLCh* qualifiedName = attr->getFullName();
  -                        XMLBufBid bbPrefixQName(&fBufMgr);
  -                        XMLBuffer& prefixBuf = bbPrefixQName.getBuffer();
  -                        int colonPos = -1;
  -                        unsigned int uriId = fScanner->resolveQName(qualifiedName, 
prefixBuf, ElemStack::Mode_Attribute, colonPos);
  -
  -                        const XMLCh* namespaceURI = 0;
  -                        if (XMLString::equals(qualifiedName, XMLNS))    //for 
xmlns=...
  -                            uriId = fScanner->getXMLNSNamespaceId();
  -                        if (uriId != fScanner->getEmptyNamespaceId()) {  //TagName 
has a prefix
  -                            namespaceURI = fScanner->getURIText(uriId);
  -                        }
  -
  -                        insertAttr = (DOMAttrImpl *) fDocument->createAttributeNS(
  -                                                                                  
namespaceURI,     // NameSpaceURI
  -                                                                                  
qualifiedName);   // qualified name
  -
  -                        DOMAttr* remAttr = 
elemImpl->setDefaultAttributeNodeNS(insertAttr);
  -                        if (remAttr)
  -                            remAttr->release();
  -
  -                        if (attr->getValue() != 0)
  -                            {
  -                                insertAttr->setValue(attr->getValue());
  -                                insertAttr->setSpecified(false);
  -                            }
  +                {
  +                    // DOM Level 2 wants all namespace declaration attributes
  +                    // to be bound to "http://www.w3.org/2000/xmlns/";
  +                    // So as long as the XML parser doesn't do it, it needs to
  +                    // done here.
  +                    const XMLCh* qualifiedName = attr->getFullName();
  +                    XMLBufBid bbPrefixQName(&fBufMgr);
  +                    XMLBuffer& prefixBuf = bbPrefixQName.getBuffer();
  +                    int colonPos = -1;
  +                    unsigned int uriId = fScanner->resolveQName(qualifiedName, 
prefixBuf, ElemStack::Mode_Attribute, colonPos);
  +
  +                    const XMLCh* namespaceURI = 0;
  +                    if (XMLString::equals(qualifiedName, XMLNS))    //for xmlns=...
  +                        uriId = fScanner->getXMLNSNamespaceId();
  +                    if (uriId != fScanner->getEmptyNamespaceId()) {  //TagName has 
a prefix
  +                        namespaceURI = fScanner->getURIText(uriId);
  +                    }
  +
  +                    insertAttr = (DOMAttrImpl *) fDocument->createAttributeNS(
  +                                                                              
namespaceURI,     // NameSpaceURI
  +                                                                              
qualifiedName);   // qualified name
  +
  +                    DOMAttr* remAttr = 
elemImpl->setDefaultAttributeNodeNS(insertAttr);
  +                    if (remAttr)
  +                        remAttr->release();
   
  -                    }
  -                else
  +                    if (attr->getValue() != 0)
                       {
  -                        // Namespaces is turned off...
  -                        insertAttr = (DOMAttrImpl *) 
fDocument->createAttribute(attr->getFullName());
  -
  -                        DOMNode* remAttr = 
elemImpl->setDefaultAttributeNode(insertAttr);
  -                        if (remAttr)
  -                            remAttr->release();
  -
  -                        //need to do this before the get as otherwise we overwrite 
any value in the attr
  -                        if (attr->getValue() != 0)
  -                            {
  -                                insertAttr->setValue(attr->getValue());
  -                                insertAttr->setSpecified(false);
  -                            }
  -
  -                        if(insertAttr) {
  -                            insertAttr = (DOMAttrImpl 
*)(elemImpl->getAttributeNode(attr->getFullName()));
  -                            insertAttr->setTypeInfo(attr->getDOMTypeInfoName(), 
attr->getDOMTypeInfoUri());
  -                        }
  +                        insertAttr->setValue(attr->getValue());
  +                        insertAttr->setSpecified(false);
                       }
   
  -            }
  -            else {
  -                //we deal with the non namespace attrs down here as we are 
iterating over the XMLAttDefs anyway
  -                if(!fScanner->getDoNamespaces()) {
  -                    if(insertAttr == 0) {
  -                        insertAttr = (DOMAttrImpl 
*)(elemImpl->getAttributeNode(attr->getFullName()));
  +                }
  +                else
  +                {
  +                    // Namespaces is turned off...
  +                    insertAttr = (DOMAttrImpl *) 
fDocument->createAttribute(attr->getFullName());
  +
  +                    DOMNode* remAttr = 
elemImpl->setDefaultAttributeNode(insertAttr);
  +                    if (remAttr)
  +                        remAttr->release();
  +
  +                    //need to do this before the get as otherwise we overwrite any 
value in the attr
  +                    if (attr->getValue() != 0)
  +                    {
  +                        insertAttr->setValue(attr->getValue());
  +                        insertAttr->setSpecified(false);
                       }
  -                    if(insertAttr)
  -                        insertAttr->setTypeInfo(attr->getDOMTypeInfoName(), 
attr->getDOMTypeInfoUri());
                   }
  +
  +                insertAttr->setTypeInfo(attr->getDOMTypeInfoName(), 
attr->getDOMTypeInfoUri());
  +
               }
   
               insertAttr = 0;
  
  
  

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

Reply via email to