From ddb0f4439fbea483f57e270264a4e7eb52c766bc Mon Sep 17 00:00:00 2001
From: Khaled Noaman <knoaman@apache.org>
Date: Tue, 30 Jul 2002 13:26:56 +0000
Subject: [PATCH] Create default attributes with the namespace URI mapped to
 the attributes' prefixes.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174079 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/parsers/AbstractDOMParser.cpp | 38 +++--------------------
 1 file changed, 5 insertions(+), 33 deletions(-)

diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp
index edd68d9be..56443cfeb 100644
--- a/src/xercesc/parsers/AbstractDOMParser.cpp
+++ b/src/xercesc/parsers/AbstractDOMParser.cpp
@@ -724,42 +724,14 @@ void AbstractDOMParser::startElement(const  XMLElementDecl&         elemDecl
                         // So as long as the XML parser doesn't do it, it needs to
                         // done here.
                         const XMLCh* qualifiedName = attr->getFullName();
-                        int index = DOMDocumentImpl::indexofQualifiedName(qualifiedName);
-
+                        XMLBufBid bbPrefixQName(&fBufMgr);
                         XMLBufBid bbQName(&fBufMgr);
-                        XMLBuffer& buf = bbQName.getBuffer();
-                        static const XMLCh XMLNS[] = {
-                            chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chNull};
-
-                        if (index > 0) {
-                            // there is prefix
-                            // map to XML URI for all cases except when prefix == "xmlns"
-                            XMLCh* prefix;
-                            XMLCh temp[1000];
-
-                            if (index > 999)
-                                prefix = new XMLCh[index+1];
-                            else
-                                prefix = temp;
-
-                            XMLString::subString(prefix ,qualifiedName, 0, index);
-
-                            if (!XMLString::compareString(prefix,XMLNS))
-                                buf.append(XMLUni::fgXMLNSURIName);
-                            else
-                                buf.append(XMLUni::fgXMLURIName);
-
-                            if (index > 999)
-                                delete prefix;
-                        }
-                        else {
-                            //   No prefix
-                            if (!XMLString::compareString(qualifiedName,XMLNS))
-                                buf.append(XMLUni::fgXMLNSURIName);
-                        }
+                        XMLBuffer& prefixBuf = bbPrefixQName.getBuffer();
+                        XMLBuffer& nameBuf = bbQName.getBuffer();
+                        unsigned int uriId = fScanner->resolveQName(qualifiedName, nameBuf, prefixBuf, ElemStack::Mode_Attribute);
 
                         insertAttr = (DOMAttrImpl *) fDocument->createAttributeNS(
-                           buf.getRawBuffer(),     // NameSpaceURI
+                           fScanner->getURIText(uriId),     // NameSpaceURI
                            qualifiedName);   // qualified name
 
                         DOMNode* remAttr = elemImpl->setDefaultAttributeNodeNS(insertAttr);
-- 
GitLab