private string targetNamespace ;
private XmlAttribute[] unhandledAttributes ;
private string version;
- private string language;
// other post schema compilation infoset
private Hashtable idCollection;
/// 3. id must be of type ID
/// 4. targetNamespace should be any uri
/// 5. version should be a normalizedString
- /// 6. xml:lang should be a language
/// </remarks>
public void Compile (ValidationEventHandler handler)
{
if (!XmlSchemaUtil.CheckNormalizedString(Version))
error(handler, Version + "is not a valid value for version attribute of schema");
- //6. xml:lang must be a language (removed)
-
// Compile the content of this schema
compilationItems = new XmlSchemaObjectCollection ();
- for (int i = 0; i < Items.Count; i++)
+ for (int i = 0; i < Items.Count; i++) {
+#if NET_2_0
+ Items [i].Parent = this;
+#endif
compilationItems.Add (Items [i]);
+ }
if (this == rootSchema)
handledUris = new Hashtable ();
// First, we run into inclusion schemas to collect
// compilation target items into compiledItems.
for (int i = 0; i < Includes.Count; i++) {
+#if NET_2_0
+ Includes [i].Parent = this;
+#endif
XmlSchemaExternal ext = Includes [i] as XmlSchemaExternal;
if (ext == null) {
error (handler, String.Format ("Object of Type {0} is not valid in Includes Property of XmlSchema", Includes [i].GetType().Name));
Uri baseUri = null;
if (this.SourceUri != null && this.SourceUri != String.Empty)
baseUri = new Uri (this.SourceUri);
- return resolver.ResolveUri (baseUri, relativeUri).ToString ();
+ Uri abs = resolver.ResolveUri (baseUri, relativeUri);
+ return abs != null ? abs.ToString () : String.Empty;
}
internal bool IsNamespaceAbsent (string ns)
case "version":
schema.version = reader.Value;
break;
- case "xml:lang":
- schema.language = reader.Value;
- break;
default:
if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
error(h, reader.Name + " attribute is not allowed in schema element",null);
XmlSerializerNamespaces nss = new XmlSerializerNamespaces ();
if (namespaceManager != null) {
- if (nss == null)
- nss = new XmlSerializerNamespaces ();
foreach (string name in namespaceManager) {
//xml and xmlns namespaces are added by default in namespaceManager.
//So we should ignore them
}
if (Namespaces != null && Namespaces.Count > 0) {
- nss.Add (String.Empty, XmlSchema.Namespace);
- foreach (XmlQualifiedName qn in Namespaces.ToArray ()) {
+ XmlQualifiedName [] qnames = Namespaces.ToArray ();
+ foreach (XmlQualifiedName qn in qnames)
nss.Add (qn.Name, qn.Namespace);
+ string p = String.Empty;
+ bool loop = true;
+ for (int idx = 1; loop; idx++) {
+ loop = false;
+ foreach (XmlQualifiedName qn in qnames)
+ if (qn.Name == p) {
+ p = "q" + idx;
+ loop = true;
+ break;
+ }
}
+ nss.Add (p, XmlSchema.Namespace);
}
if (nss.Count == 0) {
}
XmlSchemaSerializer xser = new XmlSchemaSerializer ();
- xser.Serialize (writer, this, nss);
+ XmlSerializerNamespaces backup = Namespaces;
+ try {
+ Namespaces = null;
+ xser.Serialize (writer, this, nss);
+ } finally {
+ Namespaces = backup;
+ }
writer.Flush();
}
#endregion