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
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2003-07-24 21:24:37 +0400
committerAtsushi Eno <atsushieno@gmail.com>2003-07-24 21:24:37 +0400
commit4f2417fbcf60f75850cfe4b6b171849d33df74ac (patch)
treefd048b0263fd7f2267db294c0b999a468bbcf498 /mcs/class/System.XML/System.Xml/DTDObjectModel.cs
parent23cc2051dc9e0e5ba3518c0b0221e11669a5c12a (diff)
2003-07-24 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* DTDObjectModel.cs : Added DTDEntityDeclarationCollection and DTDNotationDeclarationCollection and replaced Hashtables with them. Added NormalizedDefaultValue property for DTDAttributeDefinition. * DTDValidatingReader.cs : - It now reads attribute values into value collection. - Renamed consumedDefaultAttribute to consumedAttribute, and inContent to insideContent. - GetAttribute() should allow reader's other node state than element. - MoveToNextAttribute() should move when reader is placed other than the first attribute. - HandleError() now supports ValidationType.None (i.e. does nothing). - ValidateAttribute() now collects and resolves attribute value entity references. (On the other hand, it doesn't support EntityHandling.ExpandCharEntity.) - NodeType shouldn't return Attribute after ReadAttributeValue(). Now only Text is supported, but must also support EntityReference. - Add FilterNormalization() and partially support Normalization. svn path=/trunk/mcs/; revision=16615
Diffstat (limited to 'mcs/class/System.XML/System.Xml/DTDObjectModel.cs')
-rw-r--r--mcs/class/System.XML/System.Xml/DTDObjectModel.cs101
1 files changed, 94 insertions, 7 deletions
diff --git a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs
index ac643339cfe..58ba5b1bbc2 100644
--- a/mcs/class/System.XML/System.Xml/DTDObjectModel.cs
+++ b/mcs/class/System.XML/System.Xml/DTDObjectModel.cs
@@ -17,15 +17,17 @@ namespace Mono.Xml
{
public class DTDObjectModel
{
- internal DTDElementDeclarationCollection elementDecls;
- internal DTDAttListDeclarationCollection attListDecls;
- internal Hashtable EntityDecls = new Hashtable ();
- internal Hashtable NotationDecls = new Hashtable ();
+ DTDElementDeclarationCollection elementDecls;
+ DTDAttListDeclarationCollection attListDecls;
+ DTDEntityDeclarationCollection entityDecls;
+ DTDNotationDeclarationCollection notationDecls;
public DTDObjectModel ()
{
elementDecls = new DTDElementDeclarationCollection (this);
attListDecls = new DTDAttListDeclarationCollection (this);
+ entityDecls = new DTDEntityDeclarationCollection (this);
+ notationDecls = new DTDNotationDeclarationCollection (this);
factory = new DTDAutomataFactory (this);
}
@@ -61,6 +63,14 @@ namespace Mono.Xml
get { return attListDecls; }
}
+ public DTDEntityDeclarationCollection EntityDecls {
+ get { return entityDecls; }
+ }
+
+ public DTDNotationDeclarationCollection NotationDecls {
+ get { return notationDecls; }
+ }
+
DTDElementAutomata rootAutomata;
public DTDAutomata RootAutomata {
get {
@@ -151,9 +161,6 @@ namespace Mono.Xml
if (existing != null) {
// It should be valid and
// has effect of additive declaration.
-// throw new InvalidOperationException (String.Format (
-// "AttList declaration for {0} was already added.",
-// name));
foreach (DTDAttributeDefinition def in decl.Definitions)
if (decl.Get (def.Name) == null)
existing.Add (def);
@@ -172,6 +179,72 @@ namespace Mono.Xml
}
}
+ public class DTDEntityDeclarationCollection
+ {
+ Hashtable entityDecls = new Hashtable ();
+ DTDObjectModel root;
+
+ public DTDEntityDeclarationCollection (DTDObjectModel root)
+ {
+ this.root = root;
+ }
+
+ public DTDEntityDeclaration this [string name] {
+ get { return entityDecls [name] as DTDEntityDeclaration; }
+ }
+
+ public void Add (string name, DTDEntityDeclaration decl)
+ {
+ if (entityDecls [name] != null)
+ throw new InvalidOperationException (String.Format (
+ "Entity declaration for {0} was already added.",
+ name));
+ decl.SetRoot (root);
+ entityDecls.Add (name, decl);
+ }
+
+ public ICollection Keys {
+ get { return entityDecls.Keys; }
+ }
+
+ public ICollection Values {
+ get { return entityDecls.Values; }
+ }
+ }
+
+ public class DTDNotationDeclarationCollection
+ {
+ Hashtable notationDecls = new Hashtable ();
+ DTDObjectModel root;
+
+ public DTDNotationDeclarationCollection (DTDObjectModel root)
+ {
+ this.root = root;
+ }
+
+ public DTDNotationDeclaration this [string name] {
+ get { return notationDecls [name] as DTDNotationDeclaration; }
+ }
+
+ public void Add (string name, DTDNotationDeclaration decl)
+ {
+ if (notationDecls [name] != null)
+ throw new InvalidOperationException (String.Format (
+ "Notation declaration for {0} was already added.",
+ name));
+ decl.SetRoot (root);
+ notationDecls.Add (name, decl);
+ }
+
+ public ICollection Keys {
+ get { return notationDecls.Keys; }
+ }
+
+ public ICollection Values {
+ get { return notationDecls.Values; }
+ }
+ }
+
public class DTDContentModel
{
private DTDObjectModel root;
@@ -360,6 +433,7 @@ namespace Mono.Xml
public ArrayList EnumeratedNotations = new ArrayList();
public DTDAttributeOccurenceType OccurenceType = DTDAttributeOccurenceType.None;
private string resolvedDefaultValue;
+ private string resolvedNormalizedDefaultValue;
internal DTDAttributeDefinition () {}
@@ -371,6 +445,19 @@ namespace Mono.Xml
}
}
+ public string NormalizedDefaultValue {
+ get {
+ if (resolvedNormalizedDefaultValue == null) {
+ object o = (string) Datatype.ParseValue (ComputeDefaultValue (), null, null);
+ resolvedNormalizedDefaultValue =
+ (o is string []) ?
+ String.Join (" ", (string []) o) :
+ o.ToString ();
+ }
+ return resolvedNormalizedDefaultValue;
+ }
+ }
+
private string ComputeDefaultValue ()
{
if (UnresolvedDefaultValue == null)