//
using System;
using System.Collections;
+#if NET_2_0
+using System.Collections.Generic;
+#endif
using System.Collections.Specialized;
using System.IO;
using System.Text;
}
}
- IDictionary IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
+#if NET_2_0
+ IDictionary<string, string>
+#else
+ IDictionary
+#endif
+ IXmlNamespaceResolver.GetNamespacesInScope (XmlNamespaceScope scope)
{
IXmlNamespaceResolver resolver = reader as IXmlNamespaceResolver;
if (resolver == null)
}
string IXmlNamespaceResolver.LookupPrefix (string ns)
- {
- return ((IXmlNamespaceResolver) this).LookupPrefix (ns, false);
- }
-
- string IXmlNamespaceResolver.LookupPrefix (string ns, bool atomizedNames)
{
IXmlNamespaceResolver resolver = reader as IXmlNamespaceResolver;
if (resolver == null)
throw new NotSupportedException ("The input XmlReader does not implement IXmlNamespaceResolver and thus this validating reader cannot execute namespace prefix lookup.");
- return resolver.LookupPrefix (ns, atomizedNames);
+ return resolver.LookupPrefix (ns);
}
// It is used only for independent XmlReader use, not for XmlValidatingReader.
#if NET_2_0
+ [Obsolete]
public override object ReadTypedValue ()
#else
public object ReadTypedValue ()
return o;
}
- private object ReadTypedValueCore ()
- {
- XsDatatype dt = SchemaType as XsDatatype;
- SimpleType st = SchemaType as SimpleType;
- if (st != null)
- dt = st.Datatype;
- if (dt == null)
- return null;
-
- switch (NodeType) {
- case XmlNodeType.Element:
- if (IsEmptyElement)
- return null;
-
- storedCharacters.Length = 0;
- bool loop = true;
- do {
- Read ();
- switch (NodeType) {
- case XmlNodeType.SignificantWhitespace:
- case XmlNodeType.Text:
- case XmlNodeType.CDATA:
- storedCharacters.Append (Value);
- break;
- case XmlNodeType.Comment:
- break;
- default:
- loop = false;
- break;
- }
- } while (loop && !EOF && ReadState == ReadState.Interactive);
- return dt.ParseValue (storedCharacters.ToString (), NameTable, ParserContext.NamespaceManager);
- case XmlNodeType.Attribute:
- return dt.ParseValue (Value, NameTable, ParserContext.NamespaceManager);
- }
- return null;
- }
-
// Public Overriden Properties
public override int AttributeCount {
get { return GetAttribute (localName, ns); }
}
- int IXmlLineInfo.LineNumber {
+ public int LineNumber {
get { return readerLineInfo != null ? readerLineInfo.LineNumber : 0; }
}
- int IXmlLineInfo.LinePosition {
+ public int LinePosition {
get { return readerLineInfo != null ? readerLineInfo.LinePosition : 0; }
}
case ContentProc.Lax:
break;
default:
- // FIXME: why is it not invalid if xsi:type exists?
if (xsiTypeName == null &&
(schemas.Contains (reader.NamespaceURI) ||
!schemas.MissedSubComponents (reader.NamespaceURI)))
- HandleError ("Element declaration for " + reader.LocalName + " is missing.");
+ HandleError ("Element declaration for " + new QName (reader.LocalName, reader.NamespaceURI) + " is missing.");
break;
}
}
XsdKeyTable seq = (XsdKeyTable) keyTables [i];
if (seq.SelectorMatches (this.elementQNameStack, reader.Depth) != null) {
// creates and registers new entry.
- XsdKeyEntry entry = new XsdKeyEntry (seq, reader.Depth, reader as IXmlLineInfo);
+ XsdKeyEntry entry = new XsdKeyEntry (seq, reader.Depth, readerLineInfo);
seq.Entries.Add (entry);
}
}
private void ProcessKeyEntry (XsdKeyEntry entry)
{
bool isNil = XsiNilDepth == Depth;
- entry.ProcessMatch (false, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, this as IXmlLineInfo, Depth, null, null, null, isNil, CurrentKeyFieldConsumers);
+ entry.ProcessMatch (false, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, readerLineInfo, Depth, null, null, null, isNil, CurrentKeyFieldConsumers);
if (MoveToFirstAttribute ()) {
try {
do {
case XmlSchema.InstanceNamespace:
continue;
}
- entry.ProcessMatch (true, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, this as IXmlLineInfo, Depth, LocalName, NamespaceURI, Value, false, CurrentKeyFieldConsumers);
+ entry.ProcessMatch (true, elementQNameStack, this, NameTable, BaseURI, SchemaType, ParserContext.NamespaceManager, readerLineInfo, Depth, LocalName, NamespaceURI, Value, false, CurrentKeyFieldConsumers);
} while (MoveToNextAttribute ());
} finally {
MoveToElement ();
if (identity == null)
identity = value;
- if (!field.SetIdentityField (identity, reader.Depth == xsiNilDepth, dt as XsdAnySimpleType, this.Depth, (IXmlLineInfo) this))
+ if (!field.SetIdentityField (identity, reader.Depth == xsiNilDepth, dt as XsdAnySimpleType, this.Depth, readerLineInfo))
HandleError ("Two or more identical key value was found: '" + value + "' .");
this.currentKeyFieldConsumers.RemoveAt (0);
}
return -1;
}
- bool IXmlLineInfo.HasLineInfo ()
+ public bool HasLineInfo ()
{
return readerLineInfo != null && readerLineInfo.HasLineInfo ();
}
return reader.LookupNamespace (prefix);
}
- string IXmlNamespaceResolver.LookupNamespace (string prefix, bool atomizedNames)
- {
- IXmlNamespaceResolver res = reader as IXmlNamespaceResolver;
- if (res != null)
- return res.LookupNamespace (prefix, atomizedNames);
- else
- return reader.LookupNamespace (prefix);
- }
-
public override void MoveToAttribute (int i)
{
switch (reader.NodeType) {
private XmlSchema ReadExternalSchema (string uri)
{
Uri absUri = resolver.ResolveUri ((BaseURI != "" ? new Uri (BaseURI) : null), uri);
+ string absUriString = absUri != null ? absUri.ToString () : String.Empty;
XmlTextReader xtr = null;
try {
- xtr = new XmlTextReader (absUri.ToString (),
+ xtr = new XmlTextReader (absUriString,
(Stream) resolver.GetEntity (
absUri, null, typeof (Stream)),
NameTable);
schemaLocation = XsDatatype.FromName ("token", XmlSchema.Namespace).Normalize (schemaLocation);
tmp = schemaLocation.Split (XmlChar.WhitespaceChars);
} catch (Exception ex) {
- HandleError ("Invalid schemaLocation attribute format.", ex, true);
+ if (schemas.Count == 0)
+ HandleError ("Invalid schemaLocation attribute format.", ex, true);
tmp = new string [0];
}
if (tmp.Length % 2 != 0)
- HandleError ("Invalid schemaLocation attribute format.");
+ if (schemas.Count == 0)
+ HandleError ("Invalid schemaLocation attribute format.");
for (int i = 0; i < tmp.Length; i += 2) {
try {
schema = ReadExternalSchema (tmp [i + 1]);
} catch (Exception) { // FIXME: (wishlist) It is bad manner ;-(
- HandleError ("Could not resolve schema location URI: " + tmp [i + 1], null, true);
+ if (!schemas.Contains (tmp [i]))
+ HandleError (String.Format ("Could not resolve schema location URI: {0}",
+ i + 1 < tmp.Length ? tmp [i + 1] : String.Empty), null, true);
continue;
}
if (schema.TargetNamespace == null)
try {
schema = ReadExternalSchema (noNsSchemaLocation);
} catch (Exception) { // FIXME: (wishlist) It is bad manner ;-(
- HandleError ("Could not resolve schema location URI: " + noNsSchemaLocation, null, true);
+ if (schemas.Count != 0)
+ HandleError ("Could not resolve schema location URI: " + noNsSchemaLocation, null, true);
}
if (schema != null && schema.TargetNamespace != null)
HandleError ("Specified schema has different target namespace.");
}
}
+#if NET_2_0
+ public XmlSchemaType ActualSchemaType {
+ get {
+ object at = ActualType;
+ if (at == null)
+ return null;
+ XmlSchemaType st = at as XmlSchemaType;
+ if (st == null)
+ st = XmlSchemaType.GetBuiltInSimpleType (
+ ((XmlSchemaDatatype) at).TypeCode);
+ return st;
+ }
+ }
+#endif
+
public bool IsInvalid {
get { return State == XsdValidationState.Invalid; }
}