Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorJason Diamond <injektilo@mono-cvs.ximian.com>2002-03-07 06:06:52 +0300
committerJason Diamond <injektilo@mono-cvs.ximian.com>2002-03-07 06:06:52 +0300
commitc3b0039b20118c6fa088df8cc3a09ff35b43e8fc (patch)
treea8fe312e38e117a5674e398e73c5f711f90a589a /mcs
parent1b38dd7d9d06988f2b9e40d87027de490bcf9fa1 (diff)
Removed redundant code.
svn path=/trunk/mcs/; revision=2956
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.XML/Mono.System.XML.csproj15
-rw-r--r--mcs/class/System.XML/System.Xml/ChangeLog7
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlException.cs4
-rw-r--r--mcs/class/System.XML/System.Xml/XmlInputSource.cs619
-rwxr-xr-xmcs/class/System.XML/System.Xml/XmlNames_1_0.cs547
-rw-r--r--mcs/class/System.XML/System.Xml/XmlParser.cs516
6 files changed, 7 insertions, 1701 deletions
diff --git a/mcs/class/System.XML/Mono.System.XML.csproj b/mcs/class/System.XML/Mono.System.XML.csproj
index 0f6d167cbad..1101bbaee55 100644
--- a/mcs/class/System.XML/Mono.System.XML.csproj
+++ b/mcs/class/System.XML/Mono.System.XML.csproj
@@ -221,11 +221,6 @@
BuildAction = "Compile"
/>
<File
- RelPath = "System.Xml\XmlInputSource.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
RelPath = "System.Xml\XmlLinkedNode.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -236,11 +231,6 @@
BuildAction = "Compile"
/>
<File
- RelPath = "System.Xml\XmlNames_1_0.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
RelPath = "System.Xml\XmlNamespaceManager.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -286,11 +276,6 @@
BuildAction = "Compile"
/>
<File
- RelPath = "System.Xml\XmlParser.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
- <File
RelPath = "System.Xml\XmlParserContext.cs"
SubType = "Code"
BuildAction = "Compile"
diff --git a/mcs/class/System.XML/System.Xml/ChangeLog b/mcs/class/System.XML/System.Xml/ChangeLog
index d1a7df66a7c..038ccc6a7ed 100644
--- a/mcs/class/System.XML/System.Xml/ChangeLog
+++ b/mcs/class/System.XML/System.Xml/ChangeLog
@@ -1,3 +1,10 @@
+2002-03-06 Jason Diamond <jason@injektilo.org>
+
+ * XmlInputSource.cs, XmlNames_1_0.cs, XmlParse.cs: Removed files.
+ We already have a parser in XmlTextReader.
+
+ * XmlException.cs: Removed constructor accepting XmlInputSource.
+
2002-03-06 Kral Ferch <kral_ferch@hotmail.com>
* XmlNode.cs: Rewrote this class from scratch with
diff --git a/mcs/class/System.XML/System.Xml/XmlException.cs b/mcs/class/System.XML/System.Xml/XmlException.cs
index 8ba13667010..b70da48ecfb 100755
--- a/mcs/class/System.XML/System.Xml/XmlException.cs
+++ b/mcs/class/System.XML/System.Xml/XmlException.cs
@@ -44,10 +44,6 @@ namespace System.Xml
this.linePosition = linePosition;
}
- internal XmlException (string message, XmlInputSource inputSrc)
- {
- }
-
#endregion
#region Properties
diff --git a/mcs/class/System.XML/System.Xml/XmlInputSource.cs b/mcs/class/System.XML/System.Xml/XmlInputSource.cs
deleted file mode 100644
index 8505ecc3c2b..00000000000
--- a/mcs/class/System.XML/System.Xml/XmlInputSource.cs
+++ /dev/null
@@ -1,619 +0,0 @@
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
-//
-// System.Xml.XmlInputSource.cs
-// port of Open Xml TXmlInputSource class
-//
-// Author:
-// Daniel Weber (daniel-weber@austin.rr.com
-//
-// (C) 2001 Daniel Weber
-//
-//
-
-using System;
-using System.IO;
-
-namespace System.Xml
-{
- internal class XmlInputSource
- {
- private DomEncodingType Fencoding;
-
- private string FpublicID;
- private string FsystemID;
- public string FrootName;
-
- private Stream FStream;
-
- private bool FLastCharWasCR;
-
- // locator
- int FColumnNumber;
- int FStartColumnNumber;
- int FStartLineNumber;
- bool FLastWCharWasLF;
- int FLineNumber;
- bool FPieceEndSet;
-
- // Buffer storage for UTF-8 surrogates
- // see http://www.ietf.org/rfc/rfc2279.txt for a complete description of UTF-8 encoding
- private int FLastUcs4;
-
-
- //FLocator: TdomStandardLocator;
-
- // public properties
- //===========================================================================
- public DomEncodingType encoding
- {
- get
- {
- return Fencoding;
- }
- }
-
- //property locator: TdomStandardLocator read FLocator;
- public string publicId
- {
- get
- {
- return FpublicID;
- }
- }
-
- public string rootName
- {
- get
- {
- return FrootName;
- }
- }
-
- public Stream stream
- {
- get
- {
- return FStream;
- }
- }
-
- public string streamAsWideString
- {
- get
- {
- return string.Empty;
- //wideString read getStreamAsWideString;
- }
- }
-
- public string systemId
- {
- get
- {
- return FsystemID;
- }
- }
-
- public int columnNumber
- {
- get { return FColumnNumber; }
- }
-
- public int lineNumber
- {
- get { return FLineNumber; }
- }
-
- public int startColumnNumber
- {
- get { return FStartColumnNumber; }
- }
-
- public int startLineNumber
- {
- get { return FStartLineNumber; }
- }
-
- // private methods
- //===========================================================================
- /// <summary>
- /// Analyze the first bytes of an XML document to try and determine encoding
- /// </summary>
- /// <returns>Determined encoding type, defaults to UTF-8</returns>
- private void setEncodingType()
- {
- try
- {
- byte[] buf = new byte[4];
-
- FStream.Seek(0, SeekOrigin.Begin);
- FStream.Read(buf, 0, 4);
-
- // UTF-16 code streams should begin with 0xfeff for big-endian systems
- // or 0xfffe for little endian systems.
- // check that first....
- if ( (buf[0] == 0xfe) & (buf[1] == 0xff) )
- Fencoding = DomEncodingType.etUTF16BE;
- else if ( (buf[0] == 0xff) & (buf[1] == 0xfe) )
- Fencoding = DomEncodingType.etUTF16LE;
- else
- {
- // assume utf-8, look for encoding in <?xml version="1.0" encoding="ISO-8859-6"> tag, eg
- Fencoding = DomEncodingType.etUTF8;
-
- // Check if the stream begins with <?[X|x][M|m][L|l]
- if ( (buf[0] == 0x3c) & (buf[1] == 0x3f) & // "<?"
- ((buf[2] == 0x78) | (buf[2] ==0x58) ) & // "x" or "X"
- ( (buf[2] == 0x6d) | (buf[3] ==0x4d) ) & // "m" or "M"
- ( (buf[2] == 0x6c) | (buf[2] ==0x4c) ) ) // "l" or "L"
- {
-
- string tag = "";
- while (FStream.Position != FStream.Length)
- {
- char c = getNextChar();
- tag += c;
-
- if (c == '>')
- break;
- }
-
- // start from the location of "encoding", and scan for quotes
- string encodeString = readEncodingAttrFromTag(tag);
- encodeString = encodeString.ToUpper();
-
- if ( (encodeString.IndexOf("ISO-8859-1") != -1) |
- (encodeString.IndexOf("LATIN-1") != -1) )
- Fencoding = DomEncodingType.etLatin1;
- else if ( (encodeString.IndexOf("ISO-8859-2") != -1) |
- (encodeString.IndexOf("LATIN-2") != -1) )
- Fencoding = DomEncodingType.etLatin2;
- else if ( (encodeString.IndexOf("ISO-8859-3") != -1) |
- (encodeString.IndexOf("LATIN-3") != -1) )
- Fencoding = DomEncodingType.etLatin3;
- else if ( (encodeString.IndexOf("ISO-8859-4") != -1) |
- (encodeString.IndexOf("LATIN-4") != -1) )
- Fencoding = DomEncodingType.etLatin4;
- else if ( (encodeString.IndexOf("ISO-8859-5") != -1) |
- (encodeString.IndexOf("CYRILLIC") != -1) )
- Fencoding = DomEncodingType.etCyrillic;
- else if ( (encodeString.IndexOf("ISO-8859-6") != -1) |
- (encodeString.IndexOf("ARABIC") != -1) )
- Fencoding = DomEncodingType.etArabic;
- else if ( (encodeString.IndexOf("ISO-8859-7") != -1) |
- (encodeString.IndexOf("GREEK") != -1) )
- Fencoding = DomEncodingType.etGreek;
- else if ( (encodeString.IndexOf("ISO-8859-8") != -1) |
- (encodeString.IndexOf("HEBREW") != -1) )
- Fencoding = DomEncodingType.etHebrew;
- else if ( (encodeString.IndexOf("ISO-8859-9") != -1) |
- (encodeString.IndexOf("LATIN-5") != -1) )
- Fencoding = DomEncodingType.etLatin5;
- else if ( (encodeString.IndexOf("ISO-8859-10") != -1) |
- (encodeString.IndexOf("LATIN-6") != -1) )
- Fencoding = DomEncodingType.etLatin6;
- else if ( (encodeString.IndexOf("ISO-8859-13") != -1) |
- (encodeString.IndexOf("LATIN-7") != -1) )
- Fencoding = DomEncodingType.etLatin7;
- else if ( (encodeString.IndexOf("ISO-8859-14") != -1) |
- (encodeString.IndexOf("LATIN-8") != -1) )
- Fencoding = DomEncodingType.etLatin8;
- else if ( (encodeString.IndexOf("ISO-8859-15") != -1) |
- (encodeString.IndexOf("LATIN-9") != -1) )
- Fencoding = DomEncodingType.etLatin9;
- else if (encodeString.IndexOf("KOI8-R") != -1)
- Fencoding = DomEncodingType.etKOI8R;
- else if (encodeString.IndexOf("CP10000_MACROMAN") != -1)
- Fencoding = DomEncodingType.etcp10000_MacRoman;
- else if ( (encodeString.IndexOf("Windows-1250") != -1) |
- (encodeString.IndexOf("CP1250") != -1) )
- Fencoding = DomEncodingType.etcp1250;
- else if ( (encodeString.IndexOf("Windows-1251") != -1) |
- (encodeString.IndexOf("CP1251") != -1) )
- Fencoding = DomEncodingType.etcp1251;
- else if ( (encodeString.IndexOf("Windows-1252") != -1) |
- (encodeString.IndexOf("CP1252") != -1) )
- Fencoding = DomEncodingType.etcp1252;
- }
- }
-
- }
- catch
- {
- Fencoding = DomEncodingType.etUTF8;
- }
-
- FStream.Seek(0, SeekOrigin.Begin);
- }
-
- /// <summary>
- /// Helper function to try and find the encoding attribute value in
- /// declaration tag. Does not do well-formedness checks.
- /// </summary>
- /// <param name="tag">string to scan</param>
- /// <exception cref="InvalidOperationException">If bad encoding char found, mis-matched quotes, or no equals sign.</exception>
- /// <returns>encoding, or string.Empty if it is not found.</returns>
- private string readEncodingAttrFromTag( string tag )
- {
- int encodeIndex = tag.IndexOf("encoding");
- if ( encodeIndex == -1)
- return string.Empty;
- else
- {
- int curIndex = encodeIndex + "encoding".Length;
- bool firstQuoteFound = false;
- bool equalsFound = false;
- char quoteChar = (char) 0xffff; // c# insists on initialization...
- string encoding = "";
-
- while ( curIndex != tag.Length )
- {
- char c = tag[curIndex];
- curIndex++;
-
- if ( c == '=')
- {
- equalsFound = true;
- continue;
- }
-
- if ( (c== '\"') | (c=='\'') )
- {
- if ( !firstQuoteFound & !equalsFound)
- throw new InvalidOperationException("No equals sign found in encoding attribute");
- else if ( firstQuoteFound )
- {
- if (c == quoteChar)
- return encoding;
- else
- throw new InvalidOperationException("non-matching quotes in attribute value");
- }
- else
- {
- firstQuoteFound = true;
- quoteChar = c;
- continue;
- }
- }
- else if (firstQuoteFound)
- {
- if ( ( c >= 'a') & ( c <= 'z')) encoding += c;
- else if ( ( c >= 'A') & ( c <= 'Z')) encoding += c;
- else if ( ( c >= '0') & ( c <= '9')) encoding += c;
- else if ( c == '_' ) encoding += c;
- else if ( c == '-') encoding += c;
- else if (c == '.') encoding += c;
- else
- throw new InvalidOperationException("invalid character in encoding attribute");
- }
- }
- return string.Empty;
- }
- }
-
- private void evaluate(char c)
- {
- if (FLastWCharWasLF)
- {
- FLineNumber++;
- FLastWCharWasLF = false;
- FColumnNumber = 1;
- }
- else
- FColumnNumber++;
-
- if (c == (char) 10 )
- FLastWCharWasLF = true;
-
- if (FPieceEndSet)
- pieceStart();
- }
-
- public void pieceEnd()
- {
- FPieceEndSet = true;
- }
-
- public void pieceStart()
- {
- FStartColumnNumber = FColumnNumber;
- FStartLineNumber = FLineNumber;
- FPieceEndSet = false;
- }
-
- /// <summary>
- /// Return true if input stream is at EOF.
- /// </summary>
- /// <returns></returns>
- public bool atEOF()
- {
- return (FStream.Length == FStream.Position);
- }
-
- /// <summary>
- /// Sets the internal root name by analyzing the tags at the beginning of the stream.
- /// root name is:
- /// - the element tag of the first element found
- /// - the root name listed in a !DOCTYPE tag
- /// - empty if a parse error occurs, or no applicable tags are found.
- /// Does not do well-formedness checks - skips comments and proc. instructions
- /// </summary>
- private void getRootName()
- {
- reset();
- FrootName = string.Empty;
-
- while ( ! atEOF() )
- {
- string tag = "<";
- char c = getNextChar();
-
- // skip whitespace to first tag
- while ( !atEOF() && (XmlNames_1_0.IsXmlWhiteSpace( c )) )
- c = getNextChar();
- if ( (c != '<') | atEOF() ) break;
-
- while ( !atEOF() & ( c != '>' ) )
- {
- c = getNextChar();
- tag += c;
- }
- if ( atEOF() ) break;
-
- // Only allow 1) comments, 2) processing instructions before <!DOCTYPE ...>
- if ( tag.StartsWith("<?") ) // Processing instruction
- continue;
- else if ( tag.StartsWith("<--") ) // comment
- continue;
- else if ( tag.StartsWith("<!DOCTYPE") ) // what we're looking for...
- {
- setRootName( tag );
- break;
- }
- // no DOCTYPE tag? Use the first element tag as the root
- else if ( tag.StartsWith( "<" ) )
- setRootName( tag );
- // we hit a non-comment, processing instruction or declaration, we ain't gonna get it
- else
- {
- FrootName = string.Empty;
- break;
- }
- }
- }
-
- private void setRootName( string doctypeTag )
- {
- int start = doctypeTag.IndexOf("<DOCTYPE");
- if ( start == -1 )
- start = 1; // set from element
- else
- start += "<DOCTYPE".Length;
- while ( ( start != doctypeTag.Length ) & XmlNames_1_0.IsXmlWhiteSpace( doctypeTag[start] ) )
- start++;
-
- string tmp = string.Empty;
-
- while ( ( start != doctypeTag.Length ) &&
- !XmlNames_1_0.IsXmlWhiteSpace(doctypeTag[start]) &&
- (doctypeTag[start] != '>') &&
- (doctypeTag[start] != '[') &&
- (doctypeTag[start] != '/') )
- tmp += doctypeTag[start];
-
- if (XmlNames_1_0.isXmlName(tmp) ) FrootName = tmp;
- }
-
- /// <summary>
- /// Read in the next character (either UTF-8 or UTF-16) and convert by charset
- /// Normalize CR/LF pairs to single CR.
- /// </summary>
- /// <returns></returns>
- public char getNextChar()
- {
- byte[] buf = new byte[2];
- char retval = (char) 0xffff;
- int bCount;
-
- switch(Fencoding)
- {
- case DomEncodingType.etLatin1:
- bCount = stream.Read(buf,0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_1ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin2:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_2ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin3:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_3ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin4:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_4ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etCyrillic:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_5ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etArabic:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_6ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etGreek:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_7ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etHebrew:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_8ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin5:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_9ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin6:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_10ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin7:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_13ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin8:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_14ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etLatin9:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.Iso8859_15ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etKOI8R:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.KOI8_RToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etcp10000_MacRoman:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.cp10000_MacRomanToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etcp1250:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.cp1250ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etcp1251:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.cp1251ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etcp1252:
- bCount = stream.Read(buf, 0, 1);
- if (bCount == 1)
- retval = XmlUtil.cp1252ToUTF16Char(buf[0]);
- break;
- case DomEncodingType.etUTF8:
- if ( FLastUcs4 >= 0x10000)
- {
- // Output low surrogate
- retval = XmlUtil.Utf16LowSurrogate(FLastUcs4);
- FLastUcs4 = 0;
- }
- else
- {
- FLastUcs4 = XmlUtil.ReadUTF8Char( stream );
- if ( FLastUcs4 >= 0x10000)
- retval = XmlUtil.Utf16HighSurrogate(FLastUcs4);
- else
- retval = (char) FLastUcs4;
- }
- break;
- case DomEncodingType.etUTF16BE:
- bCount = stream.Read(buf, 0, 2);
- if (bCount == 2)
- retval = System.Convert.ToChar( (buf[0] << 16) + buf[1] );
- break;
- case DomEncodingType.etUTF16LE:
- bCount = stream.Read(buf, 0, 2);
- if (bCount == 2)
- retval = System.Convert.ToChar( (buf[1] << 16) + buf[0] );
- break;
- }
-
- // normalize CRLF or a single CR to LF:
- if ( (retval == 0x000D) & FLastCharWasCR) // 0x000d = CR
- {
- FLastCharWasCR = false;
- return getNextChar();
- }
- else if ( retval == 0x000A) // 0x000a = LF
- {
- FLastCharWasCR = true;
- return (char) 0x000D;
- }
- else
- FLastCharWasCR = false;
-
- evaluate(retval);
- return retval;
- }
-
- /// <summary>
- /// Reset the Input to the origin and clear internal variables.
- /// </summary>
- public void reset()
- {
- FLastUcs4 = 0;
- FLastCharWasCR = false;
-
- switch(Fencoding)
- {
- // skip the leading 0xfeff/oxfffe on UTF-16 streams
- case DomEncodingType.etUTF16BE:
- FStream.Seek(2, SeekOrigin.Begin);
- break;
- case DomEncodingType.etUTF16LE:
- FStream.Seek(2, SeekOrigin.Begin);
- break;
- default:
- FStream.Seek(0, SeekOrigin.Begin);
- break;
- }
-
- FColumnNumber = 0;
- FLineNumber = 0;
- FStartColumnNumber = 0;
- FStartLineNumber = 0;
- FLastWCharWasLF = true;
- pieceEnd();
- }
-
-/*
- * private
-
-
- protected
- function getStreamAsWideString: wideString; virtual;
- procedure skipTextDecl(const locator: TdomStandardLocator); virtual;
- public
- constructor create(const stream: TStream;
- const publicId,
- systemId: wideString); virtual;
- destructor destroy; override;
-
-
-*/
- // Constructor
- //===========================================================================
- XmlInputSource(Stream inputStream, string publicID, string systemID)
- {
- if (inputStream == null)
- throw new NullReferenceException("Null stream passed to XmlInputSource constructor");
-
- FStream = inputStream;
- FLastUcs4 = 0;
- FLastCharWasCR = false;
- FpublicID = publicID;
- FsystemID = systemID;
- setEncodingType();
- //FLocator:= TdomStandardLocator.create(self);
- getRootName();
- }
- }
-
-}
diff --git a/mcs/class/System.XML/System.Xml/XmlNames_1_0.cs b/mcs/class/System.XML/System.Xml/XmlNames_1_0.cs
deleted file mode 100755
index 54bd6116e0c..00000000000
--- a/mcs/class/System.XML/System.Xml/XmlNames_1_0.cs
+++ /dev/null
@@ -1,547 +0,0 @@
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
-//
-// internal System.Xml.XmlNames
-//
-// Author:
-// Daniel Weber (daniel-weber@austin.rr.com)
-// Code ported from Open XML 2.3.17
-//
-// (C) 2001 Daniel Weber
-//
-
-using System;
-
-namespace System.Xml
-{
- /// <summary>
- /// Helper class to determine validity of Xml Names
- /// </summary>
- internal class XmlNames_1_0
- {
- // Private data members
-
- // public properties
-
- // public methods
-
- // Static methods
- /// <summary>
- /// Return true if char is a valid Xml character
- /// </summary>
- /// <param name="S">unicode character to check</param>
- /// <returns>true if valid XML character, false otherwise.</returns>
- public static bool IsXmlChar(char S)
- {
- // TODO - verify XmlNames.IsXmlChar(char) ranges correct
- if (S == 0x0009) return true;
- if (S == 0x000A) return true;
- if (S == 0x000D) return true;
- if (S == 0x0020) return true;
- if ( (S >= 0xE000) & (S <= 0xFFFD) ) return true;
- if ( (S >= 0xD800) & (S <=0xDBFF) ) return true;
- if ( (S >= 0xDC00) & (S <= 0xDFFF) ) return true;
- return false;
- }
-
- /// <summary>
- /// Returns true if char is a valid Xml whitespace character.
- /// S is in unicode.
- /// </summary>
- /// <param name="S"></param>
- /// <returns></returns>
- public static bool IsXmlWhiteSpace( char S)
- {
- // TODO - validate XmlNames.IsXmlWhiteSpace
- if (S == 0x0009) return true;
- if (S == 0x000A) return true;
- if (S == 0x000D) return true;
- if (S == 0x0020) return true;
- return false;
- }
-
- /// <summary>
- /// Return true if character is a valid Xml base character
- /// </summary>
- /// <param name="S">unicode character to check.</param>
- /// <returns></returns>
- public static bool IsXmlBaseChar(char S)
- {
- long c = System.Convert.ToInt64(S);
- c = c >> 16;
-
- // Taken directly from Appendix B of the XML 1.0 spec
- // Do a switch on the high byte to minimize if's on each character.
- switch (c)
- {
- case 0:
- if ( (S >= 0x0041) & (S <= 0x005a) ) return true;
- if ( (S >= 0x0061) & (S <= 0x007a) ) return true;
- if ( (S >= 0x00c0) & (S <= 0x00d6) ) return true;
- if ( (S >= 0x00d8) & (S <= 0x00f6) ) return true;
- if ( (S >= 0x00f8) & (S <= 0x00ff) ) return true;
- break;
- case 1:
- if ( (S >= 0x0100) & (S <= 0x0131) ) return true;
- if ( (S >= 0x0134) & (S <= 0x013E) ) return true;
-
- if ( (S >= 0x0141) & (S <= 0x0148) ) return true;
- if ( (S >= 0x014a) & (S <= 0x017e) ) return true;
- if ( (S >= 0x0180) & (S <= 0x01c3) ) return true;
-
- if ( (S >= 0x01cd) & (S <= 0x01f0) ) return true;
- if ( (S >= 0x01f4) & (S <= 0x01f5) ) return true;
- if (S >= 0x01fa) return true;
- break;
- case 2:
- if ( (S >= 0x01fa) & (S <= 0x0217) ) return true;
- if ( (S >= 0x0250) & (S <= 0x02a8) ) return true;
- if ( (S >= 0x02bb) & (S <= 0x02c1) ) return true;
- break;
- case 3:
- if ( S == 0x0386) return true;
- if ( (S >= 0x0388) & (S <= 0x038a) ) return true;
- if ( S == 0x038c) return true;
- if ( (S >= 0x038e) & (S <= 0x03a1) ) return true;
- if ( (S >= 0x03a3) & (S <= 0x03ce) ) return true;
- if ( (S >= 0x03D0) & (S <= 0x03D6) ) return true;
-
- if ( S == 0x03DA) return true;
- if ( S == 0x03DC) return true;
- if ( S == 0x03DE) return true;
- if ( S == 0x03E0) return true;
- if ( (S >= 0x03E2) & (S <= 0x03F3) ) return true;
- break;
- case 4:
- if ( (S >= 0x0401) & (S <= 0x040C) ) return true;
- if ( (S >= 0x040E) & (S <= 0x044F) ) return true;
-
- if ( (S >= 0x0451) & (S <= 0x045C) ) return true;
- if ( (S >= 0x045E) & (S <= 0x0481) ) return true;
- if ( (S >= 0x0490) & (S <= 0x04C4) ) return true;
- if ( (S >= 0x04C7) & (S <= 0x04C8) ) return true;
- if ( (S >= 0x04CB) & (S <= 0x04CC) ) return true;
-
- if ( (S >= 0x04D0) & (S <= 0x04EB) ) return true;
- if ( (S >= 0x04EE) & (S <= 0x04F5) ) return true;
- if ( (S >= 0x04F8) & (S <= 0x04F9) ) return true;
- break;
- case 5:
- if ( (S >= 0x0531) & (S <= 0x0556) ) return true;
- if ( S == 0x0559) return true;
-
- if ( (S >= 0x0561) & (S <= 0x0586) ) return true;
- if ( (S >= 0x05D0) & (S <= 0x05EA) ) return true;
- if ( (S >= 0x05F0) & (S <= 0x05F2) ) return true;
- break;
- case 6:
- if ( (S >= 0x0621) & (S <= 0x063A) ) return true;
- if ( (S >= 0x0641) & (S <= 0x064A) ) return true;
- if ( (S >= 0x0671) & (S <= 0x06B7) ) return true;
- if ( (S >= 0x06BA) & (S <= 0x06BE) ) return true;
- if ( (S >= 0x06C0) & (S <= 0x06CE) ) return true;
- if ( (S >= 0x06D0) & (S <= 0x06D3) ) return true;
- if ( S == 0x06D5) return true;
- if ( (S >= 0x06E5) & (S <= 0x06E6) ) return true;
- break;
- case 9:
- if ( (S >= 0x0905) & (S <= 0x0939) ) return true;
- if ( S == 0x093D) return true;
- if ( (S >= 0x0958) & (S <= 0x0961) ) return true;
- if ( (S >= 0x0985) & (S <= 0x098C) ) return true;
- if ( (S >= 0x098F) & (S <= 0x0990) ) return true;
- if ( (S >= 0x0993) & (S <= 0x09A8) ) return true;
- if ( (S >= 0x09AA) & (S <= 0x09B0) ) return true;
- if ( S == 0x09B2) return true;
- if ( (S >= 0x09B6) & (S <= 0x09B9) ) return true;
- if ( (S >= 0x09DC) & (S <= 0x09DD) ) return true;
- if ( (S >= 0x09DF) & (S <= 0x09E1) ) return true;
- if ( (S >= 0x09F0) & (S <= 0x09F1) ) return true;
- break;
- case 10: // 0x0Ann
- if ( (S >= 0x0A05) & (S <= 0x0A0A) ) return true;
- if ( (S >= 0x0A0F) & (S <= 0x0A10) ) return true;
- if ( (S >= 0x0A13) & (S <= 0x0A28) ) return true;
- if ( (S >= 0x0A2A) & (S <= 0x0A30) ) return true;
- if ( (S >= 0x0A32) & (S <= 0x0A33) ) return true;
- if ( (S >= 0x0A35) & (S <= 0x0A36) ) return true;
- if ( (S >= 0x0A38) & (S <= 0x0A39) ) return true;
- if ( (S >= 0x0A59) & (S <= 0x0A5C) ) return true;
- if ( S == 0x0A5E) return true;
- if ( (S >= 0x0A72) & (S <= 0x0A74) ) return true;
- if ( (S >= 0x0A85) & (S <= 0x0A8B) ) return true;
- if ( S == 0x0A8D) return true;
- if ( (S >= 0x0A8F) & (S <= 0x0A91) ) return true;
- if ( (S >= 0x0A93) & (S <= 0x0AA8) ) return true;
- if ( (S >= 0x0AAA) & (S <= 0x0AB0) ) return true;
- if ( (S >= 0x0AB2) & (S <= 0x0AB3) ) return true;
- if ( (S >= 0x0AB5) & (S <= 0x0AB9) ) return true;
- if ( S == 0x0ABD) return true;
- if ( S == 0x0AE0) return true;
- break;
- case 11: // 0x0Bnn
- if ( (S >= 0x0B05) & (S <= 0x0B0C) ) return true;
- if ( (S >= 0x0B0F) & (S <= 0x0B10) ) return true;
- if ( (S >= 0x0B13) & (S <= 0x0B28) ) return true;
- if ( (S >= 0x0B2A) & (S <= 0x0B30) ) return true;
- if ( (S >= 0x0B32) & (S <= 0x0B33) ) return true;
- if ( (S >= 0x0B36) & (S <= 0x0B39) ) return true;
- if ( S == 0x0B3D) return true;
- if ( (S >= 0x0B5C) & (S <= 0x0B5D) ) return true;
- if ( (S >= 0x0B5F) & (S <= 0x0B61) ) return true;
- if ( (S >= 0x0B85) & (S <= 0x0B8A) ) return true;
- if ( (S >= 0x0B8E) & (S <= 0x0B90) ) return true;
- if ( (S >= 0x0B92) & (S <= 0x0B95) ) return true;
- if ( (S >= 0x0B99) & (S <= 0x0B9A) ) return true;
- if ( S == 0x0B9C) return true;
- if ( (S >= 0x0B9E) & (S <= 0x0B9F) ) return true;
- if ( (S >= 0x0BA3) & (S <= 0x0BA4) ) return true;
- if ( (S >= 0x0BA8) & (S <= 0x0BAA) ) return true;
- if ( (S >= 0x0BAE) & (S <= 0x0BB5) ) return true;
- if ( (S >= 0x0BB7) & (S <= 0x0BB9) ) return true;
- break;
- case 12: // 0x0Cnn
- if ( (S >= 0x0C05) & (S <= 0x0C0C) ) return true;
- if ( (S >= 0x0C0E) & (S <= 0x0C10) ) return true;
- if ( (S >= 0x0C12) & (S <= 0x0C28) ) return true;
- if ( (S >= 0x0C2A) & (S <= 0x0C33) ) return true;
- if ( (S >= 0x0C35) & (S <= 0x0C39) ) return true;
- if ( (S >= 0x0C60) & (S <= 0x0C61) ) return true;
- if ( (S >= 0x0C85) & (S <= 0x0C8C) ) return true;
- if ( (S >= 0x0C8E) & (S <= 0x0C90) ) return true;
- if ( (S >= 0x0C92) & (S <= 0x0CA8) ) return true;
- if ( (S >= 0x0CAA) & (S <= 0x0CB3) ) return true;
- if ( (S >= 0x0CB5) & (S <= 0x0CB9) ) return true;
- if ( S == 0x0CDE) return true;
- if ( (S >= 0x0CE0) & (S <= 0x0CE1) ) return true;
- break;
- case 13: // 0x0Dnn
- if ( (S >= 0x0D05) & (S <= 0x0D0C) ) return true;
- if ( (S >= 0x0D0E) & (S <= 0x0D10) ) return true;
- if ( (S >= 0x0D12) & (S <= 0x0D28) ) return true;
- if ( (S >= 0x0D2A) & (S <= 0x0D39) ) return true;
- if ( (S >= 0x0D60) & (S <= 0x0D61) ) return true;
- break;
- case 14: // 0x0Enn
- if ( (S >= 0x0E01) & (S <= 0x0E2E) ) return true;
- if ( S == 0x0E30) return true;
- if ( (S >= 0x0E32) & (S <= 0x0E33) ) return true;
- if ( (S >= 0x0E40) & (S <= 0x0E45) ) return true;
- if ( (S >= 0x0E81) & (S <= 0x0E82) ) return true;
- if ( S == 0x0E84) return true;
- if ( (S >= 0x0E87) & (S <= 0x0E88) ) return true;
- if ( S == 0x0E8A) return true;
- if ( S == 0x0E8D) return true;
- if ( (S >= 0x0E94) & (S <= 0x0E97) ) return true;
- if ( (S >= 0x0E99) & (S <= 0x0E9F) ) return true;
- if ( (S >= 0x0EA1) & (S <= 0x0EA3) ) return true;
- if ( S == 0x0EA5) return true;
- if ( S == 0x0EA7) return true;
- if ( (S >= 0x0EAA) & (S <= 0x0EAB) ) return true;
- if ( (S >= 0x0EAD) & (S <= 0x0EAE) ) return true;
- if ( S == 0x0EB0) return true;
- if ( (S >= 0x0EB2) & (S <= 0x0EB3) ) return true;
- if ( S == 0x0EBD) return true;
- if ( (S >= 0x0EC0) & (S <= 0x0EC4) ) return true;
- break;
- case 0x0F:
- if ( (S >= 0x0F40) & (S <= 0x0F47) ) return true;
- if ( (S >= 0x0F49) & (S <= 0x0F69) ) return true;
- break;
- case 0x10:
- if ( (S >= 0x10A0) & (S <= 0x10C5) ) return true;
- if ( (S >= 0x10D0) & (S <= 0x10F6) ) return true;
- break;
- case 0x11:
- if ( S == 0x1100) return true;
- if ( (S >= 0x1102) & (S <= 0x1103) ) return true;
- if ( (S >= 0x1105) & (S <= 0x1107) ) return true;
- if ( S == 0x1109) return true;
- if ( (S >= 0x110B) & (S <= 0x110C) ) return true;
- if ( (S >= 0x110E) & (S <= 0x1112) ) return true;
- if ( S == 0x113C) return true;
- if ( S == 0x113E) return true;
- if ( S == 0x1140) return true;
- if ( S == 0x114C) return true;
- if ( S == 0x114E) return true;
- if ( S == 0x1150) return true;
- if ( (S >= 0x1154) & (S <= 0x1155) ) return true;
- if ( S == 0x1159) return true;
- if ( (S >= 0x115F) & (S <= 0x1161) ) return true;
- if ( S == 0x1163) return true;
- if ( S == 0x1165) return true;
- if ( S == 0x1167) return true;
- if ( S == 0x1169) return true;
- if ( (S >= 0x116D) & (S <= 0x116E) ) return true;
- if ( (S >= 0x1172) & (S <= 0x1173) ) return true;
- if ( S == 0x1175) return true;
- if ( S == 0x119E) return true;
- if ( S == 0x11A8) return true;
- if ( S == 0x11AB) return true;
- if ( (S >= 0x11AE) & (S <= 0x11AF) ) return true;
- if ( (S >= 0x11B7) & (S <= 0x11B8) ) return true;
- if ( S == 0x11BA) return true;
- if ( (S >= 0x11BC) & (S <= 0x11C2) ) return true;
- if ( S == 0x11EB) return true;
- if ( S == 0x11F0) return true;
- if ( S == 0x11F9) return true;
- break;
- case 0x1E:
- if ( (S >= 0x1E00) & (S <= 0x1E9B) ) return true;
- if ( (S >= 0x1EA0) & (S <= 0x1EF9) ) return true;
- break;
- case 0x1F:
- if ( (S >= 0x1F00) & (S <= 0x1F15) ) return true;
- if ( (S >= 0x1F18) & (S <= 0x1F1D) ) return true;
- if ( (S >= 0x1F20) & (S <= 0x1F45) ) return true;
- if ( (S >= 0x1F48) & (S <= 0x1F4D) ) return true;
- if ( (S >= 0x1F50) & (S <= 0x1F57) ) return true;
- if ( S == 0x1F59) return true;
- if ( S == 0x1F5B) return true;
- if ( S == 0x1F5D) return true;
- if ( (S >= 0x1F5F) & (S <= 0x1F7D) ) return true;
- if ( (S >= 0x1F80) & (S <= 0x1FB4) ) return true;
- if ( (S >= 0x1FB6) & (S <= 0x1FBC) ) return true;
- if ( S == 0x1FBE) return true;
- if ( (S >= 0x1FC2) & (S <= 0x1FC4) ) return true;
- if ( (S >= 0x1FC6) & (S <= 0x1FCC) ) return true;
- if ( (S >= 0x1FD0) & (S <= 0x1FD3) ) return true;
- if ( (S >= 0x1FD6) & (S <= 0x1FDB) ) return true;
- if ( (S >= 0x1FE0) & (S <= 0x1FEC) ) return true;
- if ( (S >= 0x1FF2) & (S <= 0x1FF4) ) return true;
- if ( (S >= 0x1FF6) & (S <= 0x1FFC) ) return true;
- break;
- case 33: // 0x21nn
- if ( S == 0x2126) return true;
- if ( (S >= 0x212A) & (S <= 0x212B) ) return true;
- if ( S == 0x212E) return true;
- if ( (S >= 0x2180) & (S <= 0x2182) ) return true;
- break;
- case 48: // 0x30nn
- if ( (S >= 0x3041) & (S <= 0x3094) ) return true;
- if ( (S >= 0x30A1) & (S <= 0x30FA) ) return true;
- break;
- case 49: // 0x31nn
- if ( (S >= 0x3105) & (S <= 0x312C) ) return true;
- break;
- default:
- if ( (S >= 0xAC00) & (S <= 0xd7a3) ) return true;
- break;
- }
-
- return false;
- }
-
- /// <summary>
- /// Return true if S is a valid Xml Ideographic
- /// </summary>
- /// <param name="S">unicode character to check.</param>
- /// <returns></returns>
- public static bool IsXmlIdeographic( char S )
- {
- if ( (S >= 0x4E00) & (S <= 0x9FA5) ) return true;
- if ( S == 0x3007) return true;
- if ( (S >= 0x3021) & (S <= 0x3029) ) return true;
- return false;
-
- }
-
- /// <summary>
- /// Return true if S is a valid Xml combining character.
- /// </summary>
- /// <param name="S">Unicode character to check</param>
- /// <returns></returns>
- public static bool IsXmlCombiningChar( char S )
- {
- if ( (S >= 0x0300) & (S <= 0x0345) ) return true;
- if ( (S >= 0x0360) & (S <= 0x0361) ) return true;
- if ( (S >= 0x0483) & (S <= 0x0486) ) return true;
- if ( (S >= 0x0591) & (S <= 0x05A1) ) return true;
- if ( (S >= 0x05A3) & (S <= 0x05B9) ) return true;
- if ( (S >= 0x05BB) & (S <= 0x05BD) ) return true;
- if ( S == 0x05BF) return true;
- if ( (S >= 0x05C1) & (S <= 0x05C2) ) return true;
- if ( S == 0x05C4) return true;
- if ( (S >= 0x064B) & (S <= 0x0652) ) return true;
- if ( S == 0x0670) return true;
- if ( (S >= 0x06D6) & (S <= 0x06DC) ) return true;
- if ( (S >= 0x06DD) & (S <= 0x06DF) ) return true;
- if ( (S >= 0x06E0) & (S <= 0x06E4) ) return true;
- if ( (S >= 0x06E7) & (S <= 0x06E8) ) return true;
- if ( (S >= 0x06EA) & (S <= 0x06ED) ) return true;
- if ( (S >= 0x0901) & (S <= 0x0903) ) return true;
- if ( S == 0x093C) return true;
- if ( (S >= 0x093E) & (S <= 0x094C) ) return true;
- if ( S == 0x094D) return true;
- if ( (S >= 0x0951) & (S <= 0x0954) ) return true;
- if ( (S >= 0x0962) & (S <= 0x0963) ) return true;
- if ( (S >= 0x0981) & (S <= 0x0983) ) return true;
- if ( S == 0x09BC) return true;
- if ( S == 0x09BE) return true;
- if ( S == 0x09BF) return true;
- if ( (S >= 0x09C0) & (S <= 0x09C4) ) return true;
- if ( (S >= 0x09C7) & (S <= 0x09C8) ) return true;
- if ( (S >= 0x09CB) & (S <= 0x09CD) ) return true;
- if ( S == 0x09D7) return true;
- if ( (S >= 0x09E2) & (S <= 0x09E3) ) return true;
- if ( S == 0x0A02) return true;
- if ( S == 0x0A3C) return true;
- if ( S == 0x0A3E) return true;
- if ( S == 0x0A3F) return true;
- if ( (S >= 0x0A40) & (S <= 0x0A42) ) return true;
- if ( (S >= 0x0A47) & (S <= 0x0A48) ) return true;
- if ( (S >= 0x0A4B) & (S <= 0x0A4D) ) return true;
- if ( (S >= 0x0A70) & (S <= 0x0A71) ) return true;
- if ( (S >= 0x0A81) & (S <= 0x0A83) ) return true;
- if ( S == 0x0ABC) return true;
- if ( (S >= 0x0ABE) & (S <= 0x0AC5) ) return true;
- if ( (S >= 0x0AC7) & (S <= 0x0AC9) ) return true;
- if ( (S >= 0x0ACB) & (S <= 0x0ACD) ) return true;
- if ( (S >= 0x0B01) & (S <= 0x0B03) ) return true;
- if ( S == 0x0B3C) return true;
- if ( (S >= 0x0B3E) & (S <= 0x0B43) ) return true;
- if ( (S >= 0x0B47) & (S <= 0x0B48) ) return true;
- if ( (S >= 0x0B4B) & (S <= 0x0B4D) ) return true;
- if ( (S >= 0x0B56) & (S <= 0x0B57) ) return true;
- if ( (S >= 0x0B82) & (S <= 0x0B83) ) return true;
- if ( (S >= 0x0BBE) & (S <= 0x0BC2) ) return true;
- if ( (S >= 0x0BC6) & (S <= 0x0BC8) ) return true;
- if ( (S >= 0x0BCA) & (S <= 0x0BCD) ) return true;
- if ( S == 0x0BD7) return true;
- if ( (S >= 0x0C01) & (S <= 0x0C03) ) return true;
- if ( (S >= 0x0C3E) & (S <= 0x0C44) ) return true;
- if ( (S >= 0x0C46) & (S <= 0x0C48) ) return true;
- if ( (S >= 0x0C4A) & (S <= 0x0C4D) ) return true;
- if ( (S >= 0x0C55) & (S <= 0x0C56) ) return true;
- if ( (S >= 0x0C82) & (S <= 0x0C83) ) return true;
- if ( (S >= 0x0CBE) & (S <= 0x0CC4) ) return true;
- if ( (S >= 0x0CC6) & (S <= 0x0CC8) ) return true;
- if ( (S >= 0x0CCA) & (S <= 0x0CCD) ) return true;
- if ( (S >= 0x0CD5) & (S <= 0x0CD6) ) return true;
- if ( (S >= 0x0D02) & (S <= 0x0D03) ) return true;
- if ( (S >= 0x0D3E) & (S <= 0x0D43) ) return true;
- if ( (S >= 0x0D46) & (S <= 0x0D48) ) return true;
- if ( (S >= 0x0D4A) & (S <= 0x0D4D) ) return true;
- if ( S == 0x0D57) return true;
- if ( S == 0x0E31) return true;
- if ( (S >= 0x0E34) & (S <= 0x0E3A) ) return true;
- if ( (S >= 0x0E47) & (S <= 0x0E4E) ) return true;
- if ( S == 0x0EB1) return true;
- if ( (S >= 0x0EB4) & (S <= 0x0EB9) ) return true;
- if ( (S >= 0x0EBB) & (S <= 0x0EBC) ) return true;
- if ( (S >= 0x0EC8) & (S <= 0x0ECD) ) return true;
- if ( (S >= 0x0F18) & (S <= 0x0F19) ) return true;
- if ( S == 0x0F35) return true;
- if ( S == 0x0F37) return true;
- if ( S == 0x0F39) return true;
- if ( S == 0x0F3E) return true;
- if ( S == 0x0F3F) return true;
- if ( (S >= 0x0F71) & (S <= 0x0F84) ) return true;
- if ( (S >= 0x0F86) & (S <= 0x0F8B) ) return true;
- if ( (S >= 0x0F90) & (S <= 0x0F95) ) return true;
- if ( S == 0x0F97) return true;
- if ( (S >= 0x0F99) & (S <= 0x0FAD) ) return true;
- if ( (S >= 0x0FB1) & (S <= 0x0FB7) ) return true;
- if ( S == 0x0FB9) return true;
- if ( (S >= 0x20D0) & (S <= 0x20DC) ) return true;
- if ( S == 0x20E1) return true;
- if ( (S >= 0x302A) & (S <= 0x302F) ) return true;
- if ( S == 0x3099) return true;
- if ( S == 0x309A) return true;
-
- return false;
- }
-
- /// <summary>
- /// Return true if S is a valid Xml digit.
- /// </summary>
- /// <param name="S">Unicode character to check.</param>
- /// <returns>true if S is a valid unicode digit.</returns>
- public static bool IsXmlDigit( char S )
- {
- // TODO - validiate IsXmlDigit
- if ( (S >= 0x0030) & (S <= 0x0039) ) return true;
- if ( (S >= 0x0660) & (S <= 0x0669) ) return true;
- if ( (S >= 0x06F0) & (S <= 0x06F9) ) return true;
- if ( (S >= 0x0966) & (S <= 0x096F) ) return true;
- if ( (S >= 0x09E6) & (S <= 0x09EF) ) return true;
- if ( (S >= 0x0A66) & (S <= 0x0A6F) ) return true;
- if ( (S >= 0x0AE6) & (S <= 0x0AEF) ) return true;
- if ( (S >= 0x0B66) & (S <= 0x0B6F) ) return true;
- if ( (S >= 0x0BE7) & (S <= 0x0BEF) ) return true;
- if ( (S >= 0x0C66) & (S <= 0x0C6F) ) return true;
- if ( (S >= 0x0CE6) & (S <= 0x0CEF) ) return true;
- if ( (S >= 0x0D66) & (S <= 0x0D6F) ) return true;
- if ( (S >= 0x0E50) & (S <= 0x0E59) ) return true;
- if ( (S >= 0x0ED0) & (S <= 0x0ED9) ) return true;
- if ( (S >= 0x0F20) & (S <= 0x0F29) ) return true;
-
- return false;
- }
-
- /// <summary>
- /// Return true if S is a valid Xml Extender.
- /// </summary>
- /// <param name="S">unicode character to check.</param>
- /// <returns>true if S is a valid Xml Extender.</returns>
- public static bool IsXmlExtender ( char S )
- {
- if ( S == 0x00B7) return true;
- if ( S == 0x02D0) return true;
- if ( S == 0x02D1) return true;
- if ( S == 0x0387) return true;
- if ( S == 0x0640) return true;
- if ( S == 0x0E46) return true;
- if ( S == 0x0EC6) return true;
- if ( S == 0x3005) return true;
- if ( (S >= 0x3031) & ( S <= 0x3035) ) return true;
- if ( (S >= 0x309D) & ( S <= 0x309E) ) return true;
- if ( (S >= 0x30FC) & ( S <= 0x30FE) ) return true;
-
- return false;
- }
-
- public static bool IsXmlLetter(char S)
- {
- return IsXmlIdeographic(S) | IsXmlBaseChar(S);
- }
-
- /// <summary>
- /// Return true if S is a valid Xml name char.
- /// </summary>
- /// <param name="S">Unicode character to check</param>
- /// <returns>true if S is valid in an xml name.</returns>
- public static bool IsXmlNameChar ( char S )
- {
- if ( IsXmlLetter(S) | IsXmlDigit(S) | IsXmlCombiningChar(S) | IsXmlExtender(S) )
- return true;
- if ( (S == '.') | (S == '-') | (S == '_') | (S == ':') )
- return true;
- return false;
- }
-
- /// <summary>
- /// Return true if the passed string is a valid Xml 1.0 name
- /// </summary>
- /// <param name="s">String to check for validity</param>
- /// <returns>true if string is valid Xml name</returns>
- public static bool isXmlName( string s )
- {
- if ( s.Length == 0 ) return false;
-
- if ( !IsXmlLetter(s[0]) | (s[0] != '_') | (s[0] != ':') )
- return false;
-
- for (int i = 1; i < s.Length; i++)
- {
- if (! IsXmlNameChar( s[i] ) )
- return false;
- }
-
- return true;
- }
-
-
- // Constructors
-
- }
-}
diff --git a/mcs/class/System.XML/System.Xml/XmlParser.cs b/mcs/class/System.XML/System.Xml/XmlParser.cs
deleted file mode 100644
index 8c02b02f1a1..00000000000
--- a/mcs/class/System.XML/System.Xml/XmlParser.cs
+++ /dev/null
@@ -1,516 +0,0 @@
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
-//
-// internal System.Xml.XmlParser
-//
-// Author:
-// Daniel Weber (daniel-weber@austin.rr.com)
-//
-// (C) 2001 Daniel Weber
-//
-
-using System;
-using System.Collections;
-
-namespace System.Xml
-{
- internal class XmlParser
- {
- // Private data members
- XmlDocument Fdoc;
- XmlInputSource Fsrc;
-
- // Elements push themselves on on start, pop on complete
- Stack RefNodes;
-
- // private classes
- private enum DomPieceType
- {
- xmlProcessingInstruction,
- xmlXmlDeclaration,
- xmlTextDeclaration,
- xmlComment,xmlCDATA,
- xmlPCDATA,
- xmlDoctype,
- xmlStartTag,
- xmlEndTag,
- xmlEmptyElementTag,
- xmlCharRef,
- xmlEntityRef,
- xmlParameterEntityRef,
- xmlEntityDecl,
- xmlElementDecl,
- xmlAttributeDecl,
- xmlNotationDecl,
- xmlCondSection,
- xmlUnknown,
-
- }
-
- // constants
- private const char CR = (char) 0x0D;
- private const char LF = (char) 0x0A;
- private const char QM = '?';
- private const char AMP = '&';
- private const char GTCODE = '<';
- private const char LTCODE = '>';
- private const char SINGLEQUOTE = (char) 0x39; // '
- private const char DOUBLEQUOTE = (char) 0x34; // "
- private const char NUMBERSIGN = (char) 0x35; // #
- private const char SLASH = (char) 0x47; // /
- private const string PISTART = "<?";
- private const string PIEND = "?>";
- private const string XMLDECLSTART = "<?xml";
- private const string COMMENTSTART = "<!--";
- private const string CDATASTART = "<![CDATA[";
- private const string DOCTYPESTART = "<!DOCTYPE";
-
- // private properties
- private XmlNode refNode
- {
- get
- {
- Object e = RefNodes.Peek();
- if ( e == null )
- return null;
- else
- return e as XmlNode;
- }
- }
-
- // public properties
-
- // public methods
- public bool parse()
- {
- bool retval = true;
- XmlException parseError = null;
- bool singleQuoteOpen = false;
- bool doubleQuoteOpen = false;
- bool bracketOpen = false;
- string content = "";
- DomPieceType pieceType = DomPieceType.xmlUnknown;
- string subEndMarker = "";
- string subStartMarker = "";
-
- try
- {
- while ( !Fsrc.atEOF() )
- {
- if ( parseError != null) break;
-
- char c = Fsrc.getNextChar();
-
- if ( !XmlNames_1_0.IsXmlChar(c) )
- {
- content += c;
- throw new XmlException("'Invalid character error.'", Fsrc);
- }
-
- switch (pieceType)
- {
- case DomPieceType.xmlUnknown:
- if ( c == GTCODE)
- pieceType = DomPieceType.xmlStartTag;
- else if ( c == AMP)
- pieceType = DomPieceType.xmlEntityRef;
- else
- pieceType = DomPieceType.xmlPCDATA;
- content += c;
- Fsrc.pieceStart();
- break;
-
- case DomPieceType.xmlPCDATA:
- if ( c == GTCODE )
- {
- parseError = writePCDATA(content);
- content = "";
- pieceType = DomPieceType.xmlStartTag;
- Fsrc.pieceStart();
- }
- else if ( c == AMP)
- {
- parseError = writePCDATA(content);
- content = "";
- pieceType = DomPieceType.xmlEntityRef;
- Fsrc.pieceStart();
- }
- content += c;
- break;
-
- case DomPieceType.xmlEntityRef:
- content += c;
- if ( c == ';' )
- {
- if ( content[2] == NUMBERSIGN )
- parseError = writeCharRef(content);
- else
- parseError = writeEntityRef(content);
- content = "";
- pieceType = DomPieceType.xmlUnknown;
- }
- break;
-
- case DomPieceType.xmlStartTag:
- content += c;
- switch( content.Length)
- {
- case 2:
- if (content.StartsWith(PISTART))
- pieceType = DomPieceType.xmlProcessingInstruction;
- break;
- case 4:
- if (content.StartsWith(COMMENTSTART))
- pieceType = DomPieceType.xmlComment;
- break;
- case 9:
- if (content.StartsWith(CDATASTART))
- pieceType = DomPieceType.xmlCDATA;
- else if (content.StartsWith(DOCTYPESTART))
- {
- pieceType = DomPieceType.xmlDoctype;
- subEndMarker = "";
- subStartMarker = "";
- bracketOpen = false;
- }
- break;
- }
-
- // Count quotation marks:
- if ((c == SINGLEQUOTE) && (! doubleQuoteOpen))
- singleQuoteOpen = ! singleQuoteOpen;
- else if ((c == DOUBLEQUOTE) && (! singleQuoteOpen))
- doubleQuoteOpen = ! doubleQuoteOpen;
- else if (c == LTCODE)
- {
- if ((! doubleQuoteOpen) && (! singleQuoteOpen))
- {
- if (content[2] == SLASH)
- {
- int l = content.Length;
- int offset = 3;
- // eliminate white-space after tag name:
- while ((l-offset > 0) && XmlNames_1_0.IsXmlWhiteSpace(content[l-offset+2]))
- offset++;
- parseError = writeEndElement(content.Substring(3, l-offset));
- }
- else
- {
- if (content[content.Length-1] == SLASH)
- parseError = writeEmptyElement(content.Substring(2, content.Length-3));
- else
- parseError = writeStartElement(content.Substring(2, content.Length-2));
- }
- content = "";
- pieceType = DomPieceType.xmlUnknown;
- }
- }
- break;
-
- //<?PINAME ?>
- case DomPieceType.xmlProcessingInstruction:
- content += c;
- if ( c == LTCODE )
- if (content[content.Length-1] == QM)
- {
- if ( (content.Length > 5) &&
- (XmlNames_1_0.IsXmlWhiteSpace(content[6])) &&
- (content.StartsWith(XMLDECLSTART)) )
- parseError = writeXmlDeclaration(content.Substring(3, content.Length-4));
- else
- parseError = writeProcessingInstruction(content.Substring(3, content.Length-4));
- content = "";
- pieceType = DomPieceType.xmlUnknown;
- }
- break;
-
-
- case DomPieceType.xmlComment:
- content += c;
- if (c == LTCODE)
- if ( (content.EndsWith("-->") ) && (content.Length > 6) )
- {
- parseError = writeComment(content.Substring(5, content.Length-7));
- content = "";
- pieceType = DomPieceType.xmlUnknown;
- }
- break;
-
- case DomPieceType.xmlCDATA:
- content += c;
- if (c == LTCODE )
- {
- if (content[content.Length-1] == ']' )
- if (content[content.Length-2] == ']')
- {
- parseError = writeCDATA(content.Substring(10, content.Length-12));
- content = "";
- pieceType = DomPieceType.xmlUnknown;
- }
- }
- break;
-
- case DomPieceType.xmlDoctype:
- content += c;
- if (subEndMarker == "")
- {
- if ( (c == SINGLEQUOTE) && (! doubleQuoteOpen))
- {
- singleQuoteOpen = !singleQuoteOpen;
- }
- else if ( (c == DOUBLEQUOTE) && (! singleQuoteOpen))
- {
- doubleQuoteOpen = ! doubleQuoteOpen;
- }
-
- if (bracketOpen)
- {
- if (! (singleQuoteOpen | doubleQuoteOpen) )
- {
- if (c == GTCODE)
- {
- subStartMarker = "<";
- }
- else if ( (c == '!') && (subStartMarker == "<"))
- {
- subStartMarker = "<";
- }
- else if ( (c == QM) && (subStartMarker == "<") )
- {
- subStartMarker = "";
- subEndMarker = PIEND;
- }
- else if ((c == '-') && (subStartMarker == "<!"))
- {
- subStartMarker = "<!-";
- }
- else if ((c == '-') && (subStartMarker == "<!-"))
- {
- subStartMarker = "";
- subEndMarker = "-->";
- }
- else if (subStartMarker != "")
- {
- subStartMarker = "";
- }
-
- if ((c == ']') && (! singleQuoteOpen) && (! doubleQuoteOpen))
- bracketOpen = false;
- }
- }
- else // if BracketOpened ...
- {
- if ((c == '[') && (! singleQuoteOpen) && (! doubleQuoteOpen))
- bracketOpen = true;
- }
- } //if BracketOpened ... else ...
- else // if (SubEndMarker = '') ...
- {
- if (content.EndsWith(subEndMarker))
- subEndMarker = "";
- } //if (SubEndMarker = '') ... else ...
-
- if ((! doubleQuoteOpen) && (! singleQuoteOpen) && (! bracketOpen) &&
- (subEndMarker == "") && (c == '>'))
- {
- parseError = writeDoctype(content);
- content = "";
- pieceType = DomPieceType.xmlUnknown;
- }
- break;
-
- } // switch
- } // while more characters
-
- if (parseError == null)
- if (content.Length > 0)
- parseError = writePCDATA(content);
- } // try
- catch
- {
- // we need to raise the exception again, converted to an XmlException
- /*
- except
- on EConvertError do raise EParserInvalidCharacter_Err.create('Invalid character error.');
- on EReadError do raise EParserInvalidCharacter_Err.create('Invalid character error.');
- end; {try ...}
- except
- on E: EParserInvalidCharacter_Err do
- parserError:= parserErrorFactory(sender,inputSource.Locator,
- EParserInvalidCharacter_Err.create('Invalid character error.'),
- '');
-
- */
- }
-
- if (parseError != null)
- {
- // Deal with the error, somehow
- retval = false;
- }
- return retval;
- }
-
-
- // private methods
- private XmlException writePCDATA(string content)
- {
- return null;
- }
-
- private XmlException writeEntityRef(string content)
- {
- string entityName = content.Substring(2, content.Length - 2);
- return null;
- }
-
- private XmlException writeCharRef( string content)
- {
- return null;
- }
-
- private XmlException writeEndElement( string content)
- {
- return null;
- }
-
- private XmlException writeEmptyElement( string content)
- {
- return null;
- }
-
- private XmlException writeStartElement( string content)
- {
- return null;
- }
-
- private XmlException writeComment( string content)
- {
-/*
- procedure TdomStandardIntSubsetBuilder.comment(const sender: TdomCustomParser;
- const locator: TdomStandardLocator;
- const data: wideString);
-var
- newComment: TdomCMComment;
-begin
- if not assigned(FRefNode) then exit;
- try
- newComment:= FRefNode.OwnerCMObject.CreateCMComment(data);
- try
- FRefNode.appendChild(newComment);
- except
- if assigned(newComment.ParentNode)
- then newComment.ParentNode.RemoveChild(newComment);
- FRefNode.OwnerCMObject.FreeAllCMNodes(TdomCMNode(newComment));
- raise;
- end; {try ...}
- except
- raise EParserInvalidCharacter_Err.create('Invalid character error.');
- end; {try ...}
-end;
-
-function TXmlDocBuilder.comment(const sender: TXmlCustomProcessorAgent;
- const locator: TdomStandardLocator;
- data: wideString): TXmlParserError;
-var
- newComment: TdomComment;
-begin
- if assigned(FOnComment) then FOnComment(sender,locator,data);
- result:= nil;
- if assigned(FRefNode) then begin
- try
- newComment:= FRefNode.OwnerDocument.CreateComment(data);
- try
- FRefNode.appendChild(newComment);
- except
- if assigned(newComment.ParentNode)
- then newComment.ParentNode.RemoveChild(newComment);
- FRefNode.OwnerDocument.FreeAllNodes(TdomNode(newComment));
- raise;
- end; {try ...}
- except
- result:= parserErrorFactory(sender,locator,
- EParserInvalidComment_Err.create('Invalid comment error.'),
- data);
- end; {try ...}
- end; {if assigned(FRefNode) ...}
-
- if not assigned(result)
- then if assigned(nextHandler)
- then result:= nextHandler.comment(sender,locator,data);
-end;
-
-
-function TXmlWFTestContentHandler.comment(const sender: TXmlCustomProcessorAgent;
- const locator: TdomStandardLocator;
- data: wideString): TXmlParserError;
-var
- dataLength: integer;
-begin
- if assigned(FOnComment) then FOnComment(sender,locator,data);
- if not FIsActive
- then raise EParserException.Create('TXmlWFTestContentHandler not active.');
- result:= nil;
- FXMLDeclarationAllowed:= false;
-
- if pos('--',data) > 0
- then result:= parserErrorFactory(sender,locator,
- EParserInvalidComment_Err.create('Invalid comment error.'),
- '--');
- dataLength:= length(data);
- if dataLength > 0
- then if WideChar(data[dataLength]) = '-'
- then if not assigned(result)
- then result:= parserErrorFactory(sender,locator,
- EParserInvalidComment_Err.create('Invalid comment error.'),
- '-');
- if not IsXmlChars(data)
- then if not assigned(result)
- then result:= parserErrorFactory(sender,locator,
- EParserInvalidCharacter_Err.create('Invalid character error.'),
- data);
-
- if not assigned(result)
- then if assigned(nextHandler)
- then result:= nextHandler.comment(sender,locator,data);
-end;
-
-
-*/
- return null;
- }
-
-
- private XmlException writeXmlDeclaration ( string content)
- {
- return null;
- }
-
- private XmlException writeProcessingInstruction( string content)
- {
- return null;
- }
-
- private XmlException writeCDATA( string content)
- {
- return null;
- }
-
- private XmlException writeDoctype( string content)
- {
- return null;
- }
-
- private void mainLoop()
- {
- }
-
- // Constructors
- public XmlParser ( XmlInputSource src, XmlDocument doc )
- {
- Fsrc = src;
- Fdoc = doc;
- RefNodes = new Stack();
- }
-
- }
-}