You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@locus.apache.org on 2000/04/06 21:23:58 UTC

cvs commit: xml-xerces/c/src/dom AttrNSImpl.cpp ElementNSImpl.cpp

lehors      00/04/06 12:23:58

  Modified:    c/src/dom AttrNSImpl.cpp ElementNSImpl.cpp
  Log:
  fixed setPrefix
  
  Revision  Changes    Path
  1.2       +23 -19    xml-xerces/c/src/dom/AttrNSImpl.cpp
  
  Index: AttrNSImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/AttrNSImpl.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttrNSImpl.cpp	2000/04/06 02:21:21	1.1
  +++ AttrNSImpl.cpp	2000/04/06 19:23:57	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: AttrNSImpl.cpp,v 1.1 2000/04/06 02:21:21 lehors Exp $
  + * $Id: AttrNSImpl.cpp,v 1.2 2000/04/06 19:23:57 lehors Exp $
    */
   
   #include "AttrNSImpl.hpp"
  @@ -101,8 +101,8 @@
               this->name.substringData(index+1, this->name.length()-index-1);
       }
   
  -    const DOMString& URI =
  -        xmlnsAlone ? xmlnsURI : mapPrefix(prefix, fNamespaceURI, DOM_Node::ATTRIBUTE_NODE);
  +    const DOMString& URI = xmlnsAlone ?
  +        xmlnsURI : mapPrefix(prefix, fNamespaceURI, DOM_Node::ATTRIBUTE_NODE);
       this -> namespaceURI = URI == null ? DOMString(null) : URI.clone();
   };  
   
  @@ -134,7 +134,7 @@
       return localName;
   }
   
  -void AttrNSImpl::setPrefix(const DOMString &fPrefix)
  +void AttrNSImpl::setPrefix(const DOMString &prefix)
   {
       DOMString xml = NodeImpl::getXmlString();
       DOMString xmlURI = NodeImpl::getXmlURIString();
  @@ -142,25 +142,29 @@
       DOMString xmlnsURI = NodeImpl::getXmlnsURIString();
   
       if (readOnly)
  -	throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
  +        throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
                                  null);
  -    if(fPrefix != null && !DocumentImpl::isXMLName(fPrefix))
  +    if (namespaceURI == null || localName.equals(xmlns))
  +        throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  +
  +    if (prefix != null && !DocumentImpl::isXMLName(prefix))
           throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
   
  -    if (fPrefix == null || fPrefix.length() == 0) {
  -	this -> prefix = null;
  -	name = localName;
  -	return;
  +    if (prefix == null || prefix.length() == 0) {
  +        this -> prefix = null;
  +        name = localName;
  +        return;
       }
   
  -    XMLCh *p = fPrefix.rawBuffer();
  -    for (int i = fPrefix.length(); --i >= 0;)
  -	if (*p++ == chColon)	//prefix is malformed
  -	    throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  -    if (fPrefix.equals(xml) && !namespaceURI.equals(xmlURI) ||
  -	fPrefix.equals(xmlns) && !namespaceURI.equals(xmlnsURI))
  -	throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  +    if (prefix.equals(xml) && !namespaceURI.equals(xmlURI) ||
  +        prefix.equals(xmlns) && !namespaceURI.equals(xmlnsURI))
  +        throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  +
  +    XMLCh *p = prefix.rawBuffer();
  +    for (int i = prefix.length(); --i >= 0;)
  +        if (*p++ == chColon)	//prefix is malformed
  +            throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
   
  -    name = this -> prefix = fPrefix;
  -    name = name + chColon + localName;    //nodeName is changed too
  +    this -> prefix = prefix;
  +    name = prefix + chColon + localName; //nodeName is changed too
   }
  
  
  
  1.2       +19 -17    xml-xerces/c/src/dom/ElementNSImpl.cpp
  
  Index: ElementNSImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/ElementNSImpl.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ElementNSImpl.cpp	2000/04/06 02:21:21	1.1
  +++ ElementNSImpl.cpp	2000/04/06 19:23:57	1.2
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: ElementNSImpl.cpp,v 1.1 2000/04/06 02:21:21 lehors Exp $
  + * $Id: ElementNSImpl.cpp,v 1.2 2000/04/06 19:23:57 lehors Exp $
    */
   
   #include "ElementNSImpl.hpp"
  @@ -128,7 +128,7 @@
       return localName;
   }
   
  -void ElementNSImpl::setPrefix(const DOMString &fPrefix)
  +void ElementNSImpl::setPrefix(const DOMString &prefix)
   {
       DOMString xml = NodeImpl::getXmlString();
       DOMString xmlURI = NodeImpl::getXmlURIString();
  @@ -136,26 +136,28 @@
       DOMString xmlnsURI = NodeImpl::getXmlnsURIString();
   
       if (readOnly)
  -	throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
  +        throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
                                  null);
  -    if(fPrefix != null && !DocumentImpl::isXMLName(fPrefix))
  +    if(prefix != null && !DocumentImpl::isXMLName(prefix))
           throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
  -    if (namespaceURI == null || localName == null)
  +
  +    if (namespaceURI == null)
   	throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
   
  -    if (fPrefix == null || fPrefix.length() == 0) {
  -	this -> prefix = null;
  -	name = localName;
  -	return;
  +    if (prefix == null || prefix.length() == 0) {
  +        this -> prefix = null;
  +        name = localName;
  +        return;
       }
   
  -    XMLCh *p = fPrefix.rawBuffer();
  -    for (int i = fPrefix.length(); --i >= 0;)
  -	if (*p++ == chColon)	//prefix is malformed
  -	    throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  -    if (fPrefix.equals(xml) && !namespaceURI.equals(xmlURI))
  -	throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  +    if (prefix.equals(xml) && !namespaceURI.equals(xmlURI))
  +        throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
  +
  +    XMLCh *p = prefix.rawBuffer();
  +    for (int i = prefix.length(); --i >= 0;)
  +        if (*p++ == chColon)	//prefix is malformed
  +            throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
   
  -    name = this -> prefix = fPrefix;
  -    name = name + chColon + localName;    //nodeName is changed too
  +    this -> prefix = prefix;
  +    name = prefix + chColon + localName; //nodeName is changed too
   }