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)
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