diff --git a/src/xercesc/dom/impl/DOMElementImpl.cpp b/src/xercesc/dom/impl/DOMElementImpl.cpp index b4f95a63c347238c8f4d51f0f831ddce48d6be19..f976d561b2e4e99c32486138f2473b35f76a4551 100644 --- a/src/xercesc/dom/impl/DOMElementImpl.cpp +++ b/src/xercesc/dom/impl/DOMElementImpl.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -168,16 +168,11 @@ short DOMElementImpl::getNodeType() const { const XMLCh * DOMElementImpl::getAttribute(const XMLCh *nam) const { - static const XMLCh emptyString[] = {0}; - DOMNode * attr=0; + DOMNode * attr = fAttributes->getNamedItem(nam); + if (attr) + return attr->getNodeValue(); - attr=fAttributes->getNamedItem(nam); - - const XMLCh *retString = emptyString; - if (attr != 0) - retString = attr->getNodeValue(); - - return retString; + return XMLUni::fgZeroLenString; }; diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.cpp b/src/xercesc/dom/impl/DOMImplementationImpl.cpp index 6ddf42a1a00818fd58f982f67e2fca8db4b74235..aa766ba444339e8520baf86f8cfc283bf1805e94 100644 --- a/src/xercesc/dom/impl/DOMImplementationImpl.cpp +++ b/src/xercesc/dom/impl/DOMImplementationImpl.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,9 +84,6 @@ XERCES_CPP_NAMESPACE_BEGIN // (Static constructors can not be safely used because // of order of initialization dependencies.) // ------------------------------------------------------------ -static const XMLCh gXML[] = // Points to "XML" - {chLatin_X, chLatin_M, chLatin_L, chNull}; - static const XMLCh g1_0[] = // Points to "1.0" {chDigit_1, chPeriod, chDigit_0, chNull}; static const XMLCh g2_0[] = // Points to "2.0" @@ -99,7 +96,7 @@ static const XMLCh gTrav[] = // Points to "Traversal" static const XMLCh gCore[] = // Points to "Core" {chLatin_C, chLatin_o, chLatin_r, chLatin_e, chNull}; static const XMLCh gRange[] = // Points to "Range" - {chLatin_R, chLatin_a, chLatin_n, chLatin_g, chLatin_e, 0}; + {chLatin_R, chLatin_a, chLatin_n, chLatin_g, chLatin_e, chNull}; static const XMLCh gLS[] = // Points to "LS" {chLatin_L, chLatin_S, chNull}; @@ -212,7 +209,7 @@ bool DOMImplementationImpl::hasFeature(const XMLCh * feature, const XMLCh * bool version3_0 = XMLString::equals(version, g3_0); // Currently, we support only XML Level 1 version 1.0 - if (XMLString::compareIString(feature, gXML) == 0 + if (XMLString::compareIString(feature, XMLUni::fgXMLString) == 0 && (anyVersion || version1_0 || version2_0)) return true; diff --git a/src/xercesc/dom/impl/DOMNodeImpl.cpp b/src/xercesc/dom/impl/DOMNodeImpl.cpp index f86dcba4f6a2b104cbcfd904217adae553af7efd..67cf07fae00f913d72398037f92bf168ff0baabe 100644 --- a/src/xercesc/dom/impl/DOMNodeImpl.cpp +++ b/src/xercesc/dom/impl/DOMNodeImpl.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -365,27 +365,10 @@ bool DOMNodeImpl::hasAttributes() const { -static const XMLCh s_xml[] = {chLatin_x, chLatin_m, chLatin_l, chNull}; -static const XMLCh s_xmlURI[] = // "http://www.w3.org/XML/1998/namespace" - { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, - chLatin_o, chLatin_r, chLatin_g, chForwardSlash, chLatin_X, chLatin_M, chLatin_L, chForwardSlash, - chDigit_1, chDigit_9, chDigit_9, chDigit_8, chForwardSlash, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, chLatin_a, chLatin_c, chLatin_e, - chNull}; -static const XMLCh s_xmlns[] = {chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chNull}; -static const XMLCh s_xmlnsURI[] = // "http://www.w3.org/2000/xmlns/" - { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, - chLatin_o, chLatin_r, chLatin_g, chForwardSlash, - chDigit_2, chDigit_0, chDigit_0, chDigit_0, chForwardSlash, - chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chForwardSlash, chNull}; - - -const XMLCh *DOMNodeImpl::getXmlString() {return s_xml;}; -const XMLCh *DOMNodeImpl::getXmlURIString() {return s_xmlURI;}; -const XMLCh *DOMNodeImpl::getXmlnsString() {return s_xmlns;}; -const XMLCh *DOMNodeImpl::getXmlnsURIString() {return s_xmlnsURI;}; +const XMLCh *DOMNodeImpl::getXmlString() {return XMLUni::fgXMLString;}; +const XMLCh *DOMNodeImpl::getXmlURIString() {return XMLUni::fgXMLURIName;}; +const XMLCh *DOMNodeImpl::getXmlnsString() {return XMLUni::fgXMLNSString;}; +const XMLCh *DOMNodeImpl::getXmlnsURIString() {return XMLUni::fgXMLNSURIName;}; //Return a URI mapped from the given prefix and namespaceURI as below // prefix namespaceURI output @@ -399,34 +382,16 @@ const XMLCh *DOMNodeImpl::getXmlnsURIString() {return s_xmlnsURI;}; const XMLCh* DOMNodeImpl::mapPrefix(const XMLCh *prefix, const XMLCh *namespaceURI, short nType) { - - static const XMLCh s_xml[] = {chLatin_x, chLatin_m, chLatin_l, chNull}; - static const XMLCh s_xmlURI[] = // "http://www.w3.org/XML/1998/namespace" - { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, - chLatin_o, chLatin_r, chLatin_g, chForwardSlash, chLatin_X, chLatin_M, chLatin_L, chForwardSlash, - chDigit_1, chDigit_9, chDigit_9, chDigit_8, chForwardSlash, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, chLatin_a, chLatin_c, chLatin_e, - chNull}; - static const XMLCh s_xmlns[] = {chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chNull}; - static const XMLCh s_xmlnsURI[] = // "http://www.w3.org/2000/xmlns/" - { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, - chLatin_o, chLatin_r, chLatin_g, chForwardSlash, - chDigit_2, chDigit_0, chDigit_0, chDigit_0, chForwardSlash, - chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chForwardSlash, chNull}; - - if (prefix == 0) return namespaceURI; - if (XMLString::equals(prefix, s_xml)) { - if (XMLString::equals(namespaceURI, s_xmlURI)) - return s_xmlURI; + if (XMLString::equals(prefix, XMLUni::fgXMLString)) { + if (XMLString::equals(namespaceURI, XMLUni::fgXMLURIName)) + return XMLUni::fgXMLURIName; throw DOMException(DOMException::NAMESPACE_ERR, 0); - } else if (nType == DOMNode::ATTRIBUTE_NODE && XMLString::equals(prefix, s_xmlns)) { - if (XMLString::equals(namespaceURI, s_xmlnsURI)) - return s_xmlnsURI; + } else if (nType == DOMNode::ATTRIBUTE_NODE && XMLString::equals(prefix, XMLUni::fgXMLNSString)) { + if (XMLString::equals(namespaceURI, XMLUni::fgXMLNSURIName)) + return XMLUni::fgXMLNSURIName; throw DOMException(DOMException::NAMESPACE_ERR, 0); } else if (namespaceURI == 0 || *namespaceURI == 0) { throw DOMException(DOMException::NAMESPACE_ERR, 0); @@ -594,10 +559,10 @@ const XMLCh* DOMNodeImpl::lookupNamespacePrefix(const XMLCh* const namespaceURI, ns = attr->getNamespaceURI(); - if (ns != 0 && XMLString::equals(ns, s_xmlnsURI)) { + if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) { // DOM Level 2 nodes - if ((useDefault && XMLString::equals(attr->getNodeName(), s_xmlns)) || - (attrPrefix != 0 && XMLString::equals(attrPrefix, s_xmlns)) && + if ((useDefault && XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) || + (attrPrefix != 0 && XMLString::equals(attrPrefix, XMLUni::fgXMLNSString)) && XMLString::equals(value, namespaceURI)) { const XMLCh* localname= attr->getLocalName(); const XMLCh* foundNamespace = el->lookupNamespaceURI(localname); @@ -644,14 +609,14 @@ const XMLCh* DOMNodeImpl::lookupNamespaceURI(const XMLCh* specifiedPrefix) const const XMLCh *value = attr->getNodeValue(); ns = attr->getNamespaceURI(); - if (ns != 0 && XMLString::equals(ns, s_xmlnsURI)) { + if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) { // at this point we are dealing with DOM Level 2 nodes only if (specifiedPrefix == 0 && - XMLString::equals(attr->getNodeName(), s_xmlns)) { + XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) { // default namespace return value; } else if (attrPrefix != 0 && - XMLString::equals(attrPrefix, s_xmlns) && + XMLString::equals(attrPrefix, XMLUni::fgXMLNSString) && XMLString::equals(attr->getLocalName(), specifiedPrefix)) { // non default namespace return value; @@ -1083,7 +1048,7 @@ bool DOMNodeImpl::isDefaultNamespace(const XMLCh* namespaceURI) const{ if (thisNode->hasAttributes()) { DOMElement *elem = (DOMElement *)thisNode; - DOMNode *attr = elem->getAttributeNodeNS(s_xmlnsURI, s_xmlns); + DOMNode *attr = elem->getAttributeNodeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString); if (attr != 0) { const XMLCh *value = attr->getNodeValue(); return XMLString::equals(namespaceURI, value); diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp index ffef991b5ee3afe3f5f977996f74a1a57695ddc1..b55d808fe1ac37a165d252ca4e56d47c3b5a9cca 100644 --- a/src/xercesc/dom/impl/DOMWriterImpl.cpp +++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.49 2004/01/13 20:47:42 knoaman + * Remove unnecessary local static data + * * Revision 1.48 2004/01/13 16:34:20 cargilld * Misc memory management changes. * @@ -441,20 +444,6 @@ static const XMLByte BOM_utf16le[] = {(XMLByte)0xFF, (XMLByte)0xFE, (XMLByte) 0 static const XMLByte BOM_ucs4be[] = {(XMLByte)0x00, (XMLByte)0x00, (XMLByte)0xFE, (XMLByte)0xFF, (XMLByte) 0}; static const XMLByte BOM_ucs4le[] = {(XMLByte)0xFF, (XMLByte)0xFE, (XMLByte)0x00, (XMLByte)0x00, (XMLByte) 0}; -static const XMLCh s_xmlnsURI[] = // "http://www.w3.org/2000/xmlns/" - { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, - chLatin_o, chLatin_r, chLatin_g, chForwardSlash, - chDigit_2, chDigit_0, chDigit_0, chDigit_0, chForwardSlash, - chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chForwardSlash, chNull}; -static const XMLCh s_xmlns[] = {chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chNull}; -static const XMLCh s_xmlURI[] = // "http://www.w3.org/XML/1998/namespace" - { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, chDigit_3, chPeriod, - chLatin_o, chLatin_r, chLatin_g, chForwardSlash, chLatin_X, chLatin_M, chLatin_L, chForwardSlash, - chDigit_1, chDigit_9, chDigit_9, chDigit_8, chForwardSlash, - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, chLatin_a, chLatin_c, chLatin_e, - chNull}; // // Notification of the error though error handler @@ -1016,7 +1005,7 @@ void DOMWriterImpl::processNode(const DOMNode* const nodeToWrite, int level) { namespaceMap->put((void*)prefix,(XMLCh*)nodeToWrite->getNamespaceURI()); *fFormatter << XMLFormatter::NoEscapes - << chSpace << s_xmlns; + << chSpace << XMLUni::fgXMLNSString; if(!XMLString::equals(prefix,XMLUni::fgZeroLenString)) *fFormatter << chColon << prefix; *fFormatter << chEqual << chDoubleQuote @@ -1064,16 +1053,16 @@ void DOMWriterImpl::processNode(const DOMNode* const nodeToWrite, int level) const XMLCh* ns = attribute->getNamespaceURI(); if (ns != 0 ) { - if(XMLString::equals(ns, s_xmlnsURI)) + if(XMLString::equals(ns, XMLUni::fgXMLNSURIName)) { const XMLCh* nsPrefix = attribute->getLocalName(); - if(XMLString::equals(attribute->getNodeName(),s_xmlns)) + if(XMLString::equals(attribute->getNodeName(),XMLUni::fgXMLNSString)) nsPrefix = XMLUni::fgZeroLenString; if(namespaceMap->containsKey((void*)nsPrefix)) continue; namespaceMap->put((void*)attribute->getLocalName(),(XMLCh*)attribute->getNodeValue()); } - else if(!XMLString::equals(ns, s_xmlURI)) + else if(!XMLString::equals(ns, XMLUni::fgXMLURIName)) { // check if the namespace for the current node is already defined const XMLCh* prefix = attribute->getPrefix(); @@ -1094,7 +1083,7 @@ void DOMWriterImpl::processNode(const DOMNode* const nodeToWrite, int level) { namespaceMap->put((void*)prefix,(XMLCh*)attribute->getNamespaceURI()); *fFormatter << XMLFormatter::NoEscapes - << chSpace << s_xmlns << chColon << prefix + << chSpace << XMLUni::fgXMLNSString << chColon << prefix << chEqual << chDoubleQuote << XMLFormatter::AttrEscapes << attribute->getNamespaceURI() diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp index 135a3afcb10cf1684c0f98eb4b194328d649b2ed..a049aa9fb97d4077cd2cb3986aa9a68f011b5448 100644 --- a/src/xercesc/parsers/AbstractDOMParser.cpp +++ b/src/xercesc/parsers/AbstractDOMParser.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002,2003 The Apache Software Foundation. All rights + * Copyright (c) 2002,2004 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -827,9 +827,6 @@ void AbstractDOMParser::startElement(const XMLElementDecl& elemDecl { DOMElement *elem; DOMElementImpl *elemImpl; - static const XMLCh XMLNS[] = { - chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chNull - }; static const XMLCh XSI[] = { chLatin_x, chLatin_s, chLatin_i, chNull @@ -873,7 +870,7 @@ void AbstractDOMParser::startElement(const XMLElementDecl& elemDecl unsigned int attrURIId = oneAttrib -> getURIId(); namespaceURI = 0; bool foundXMLNS = false; - if (XMLString::equals(oneAttrib -> getName(), XMLNS)) { //for xmlns=... + if (XMLString::equals(oneAttrib -> getName(), XMLUni::fgXMLNSString)) { //for xmlns=... attrURIId = fScanner->getXMLNSNamespaceId(); foundXMLNS = true; } @@ -967,7 +964,7 @@ void AbstractDOMParser::startElement(const XMLElementDecl& elemDecl unsigned int uriId = fScanner->resolveQName(qualifiedName, prefixBuf, ElemStack::Mode_Attribute, colonPos); const XMLCh* namespaceURI = 0; - if (XMLString::equals(qualifiedName, XMLNS)) //for xmlns=... + if (XMLString::equals(qualifiedName, XMLUni::fgXMLNSString)) //for xmlns=... uriId = fScanner->getXMLNSNamespaceId(); if (uriId != fScanner->getEmptyNamespaceId()) { //TagName has a prefix namespaceURI = fScanner->getURIText(uriId);