소스 검색

2003-01-13 Ville Palo <[email protected]>

	* XmlDocument.cs: Added CheckName () method to check names validity.

svn path=/trunk/mcs/; revision=10480
Ville Palo 23 년 전
부모
커밋
4fe82568f8
2개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 0
      mcs/class/System.XML/System.Xml/ChangeLog
  2. 10 2
      mcs/class/System.XML/System.Xml/XmlDocument.cs

+ 4 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,7 @@
+2003-01-13  Ville Palo <[email protected]>
+
+	* XmlDocument.cs: Added CheckName () method to check names validity.
+	
 2003-01-11  Gonzalo Paniagua Javier <[email protected]>
 
 	* XmlTextReader.cs:

+ 10 - 2
mcs/class/System.XML/System.Xml/XmlDocument.cs

@@ -273,7 +273,7 @@ namespace System.Xml
 			string localName;
 
 			ParseName (qualifiedName, out prefix, out localName);
-
+			
 			return CreateElement (prefix, localName, namespaceURI);
 		}
 
@@ -284,7 +284,7 @@ namespace System.Xml
 		{
 			if ((localName == null) || (localName == String.Empty))
 				throw new ArgumentException ("The local name for elements or attributes cannot be null or an empty string.");
-
+			CheckName (localName);
 			return new XmlElement (prefix != null ? prefix : String.Empty, localName, namespaceURI != null ? namespaceURI : String.Empty, this);
 		}
 
@@ -651,6 +651,14 @@ namespace System.Xml
 			}
 		}
 
+		// Checks that Element's name is valid
+		private void CheckName (String name)
+		{
+			// TODO: others validations?
+			if (name.IndexOf (" ") >= 0)
+				throw new XmlException ("The ' ' characted cannot be included in a name");
+		}
+
 		// Reads XmlReader and creates Attribute Node.
 		private XmlAttribute ReadAttributeNode(XmlReader reader)
 		{