[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/kdom
From:       Rob Buis <rwlbuis () xs4all ! nl>
Date:       2004-04-10 14:07:00
Message-ID: 20040410140700.B21A294A1 () office ! kde ! org
[Download RAW message or body]

CVS commit by buis: 


Moved the prefix check to Helper, added the call from Element::setPrefix().


  M +2 -17     Attr.cc   1.44
  M +1 -4      Element.cc   1.53
  M +22 -0     Helper.h   1.16


--- kdenonbeta/kdom/Attr.cc  #1.43:1.44
@@ -222,20 +222,5 @@ void Attr::setPrefix(const DOMString &pr
                 throw new DOMException(NO_MODIFICATION_ALLOWED_ERR);
 
-        // INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal \
                character.
-        if(!Helper::ValidatePrefix(prefix))
-                throw new DOMException(INVALID_CHARACTER_ERR);
-
-        // NAMESPACE_ERR:
-        // - Raised if the specified prefix is malformed,
-        // - if the namespaceURI is null, or
-        // - if the qualifiedName is null and the namespaceURI is different from \
                null
-        // - if the specified prefix is "xml" and the namespaceURI is different
-        //   from "http://www.w3.org/XML/1998/namespace" [Namespaces].
-        // - if this node is an attribute and the qualifiedName of this node is \
                "xmlns"
-        DOMString qName = prefix + ":" + d->name;
-        if(!qName.isNull() && Helper::MalformedQualifiedName(qName) || \
                (namespaceURI().isNull()) ||
-           (qName.length() == 3 && prefix[0] == 'x' && prefix[1] == 'm' && prefix[2] \
                == 'l' &&
-           namespaceURI() != "http://www.w3.org/XML/1998/namespace") || prefix == \
                "xmlns")
-                throw new DOMException(NAMESPACE_ERR);
+        Helper::CheckPrefix(prefix, d->name, namespaceURI());
                 
         if(d)

--- kdenonbeta/kdom/Element.cc  #1.52:1.53
@@ -303,9 +303,6 @@ void Element::setPrefix(const DOMString 
                 throw new DOMException(NO_MODIFICATION_ALLOWED_ERR);
 
-        // INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal \
                character.
-        if(!Helper::ValidatePrefix(prefix))
-                throw new DOMException(INVALID_CHARACTER_ERR);
+        Helper::CheckPrefix(prefix, nodeName(), namespaceURI());
 
-        // TODO : NAMESPACE_ERR
         if(d)
                 d->prefix = prefix;

--- kdenonbeta/kdom/Helper.h  #1.15:1.16
@@ -88,4 +88,26 @@ namespace KDOM
                 }
 
+                static bool CheckPrefix(const DOMString &prefix, const DOMString \
&name, const DOMString &namespaceURI) +                {
+                        // INVALID_CHARACTER_ERR: Raised if the specified prefix \
contains an illegal character. +                        \
if(!Helper::ValidatePrefix(prefix)) +                                throw new \
DOMException(INVALID_CHARACTER_ERR); +
+                        // NAMESPACE_ERR:
+                        // - Raised if the specified prefix is malformed,
+                        // - if the namespaceURI is null, or
+                        // - if the qualifiedName is null and the namespaceURI is \
different from null +                        // - if the specified prefix is "xml" \
and the namespaceURI is different +                        //   from \
"http://www.w3.org/XML/1998/namespace" [Namespaces]. +                        // - if \
this node is an attribute and the qualifiedName of this node is "xmlns" +             \
DOMString qName = prefix + ":" + name; +                        if(!qName.isNull() && \
Helper::MalformedQualifiedName(qName) || (namespaceURI.isNull()) || +                 \
(qName.length() == 3 && prefix[0] == 'x' && prefix[1] == 'm' && prefix[2] == 'l' && + \
namespaceURI != "http://www.w3.org/XML/1998/namespace") || prefix == "xmlns") +       \
throw new DOMException(NAMESPACE_ERR); +
+                        return true;
+                }
+
                 static bool CheckQualifiedName(const DOMString &qualifiedName, const \
                DOMString &namespaceURI,
                                                                            int \
&colonPos, bool nameCanBeNull, bool nameCanBeEmpty)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic