[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlTextWriter.cs,1.8,1.9
From: |
Gopal.V <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlTextWriter.cs,1.8,1.9 XmlWriter.cs,1.3,1.4 |
Date: |
Tue, 31 Dec 2002 06:13:08 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System.Xml
In directory subversions:/tmp/cvs-serv12558/System.Xml
Modified Files:
XmlTextWriter.cs XmlWriter.cs
Log Message:
Patch #923 for Xml
Index: XmlTextWriter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlTextWriter.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** XmlTextWriter.cs 13 Dec 2002 03:45:07 -0000 1.8
--- XmlTextWriter.cs 31 Dec 2002 11:13:05 -0000 1.9
***************
*** 777,784 ****
}
! // Write a processing instruction.
public override void WriteProcessingInstruction(String name, String
text)
! {
! // TODO
}
--- 777,807 ----
}
! // Write a processing instruction. <?name text?>
public override void WriteProcessingInstruction(String name, String
text)
! {
!
! if((writeState == System.Xml.WriteState.Start)
|| (name == null))
! {
! throw new ArgumentException
! (S._("Xml_ArgumentException"),
"name");
!
! }
! if(writeState == System.Xml.WriteState.Closed)
! {
!
! throw new InvalidOperationException
! (S._("Xml_InvalidOperation"));
! }
!
! Sync(WriteStateFlag.PrologFlag);
!
! if (text != null)
! {
! writer.WriteLine("<?{0} {1}?>",name,
text);
! }
! else
! {
! writer.WriteLine("<?{0}?>",name);
! }
}
***************
*** 786,790 ****
public override void WriteQualifiedName(String localName, String ns)
{
! // TODO
}
--- 809,914 ----
public override void WriteQualifiedName(String localName, String ns)
{
! if ((localName == null) || (localName ==
String.Empty))
! {
! throw new ArgumentException
! (S._("Xml_ArgumentException"),
"localName");
! }
!
! if ((Namespaces == false) && (ns != null)
! && (ns != String.Empty))
! {
! throw new ArgumentException
! (S._("Xml_ArgumentException"),
"ns");
! }
!
! if(!XmlReader.IsName(localName))
! {
! throw new XmlException
! (S._("Xml_XmlException"));
! }
!
!
! if (writeState == System.Xml.WriteState.Closed)
! {
! throw new InvalidOperationException
! (S._("Xml_InvalidOperation"));
! }
!
! if (writeState == System.Xml.WriteState.Closed)
! {
! throw new
InvalidOperationException
!
(S._("Xml_InvalidOperation"));
! break;
! }
!
! if ((writeState ==
System.Xml.WriteState.Element) || (writeState ==
System.Xml.WriteState.Attribute))
! {
!
! if ((ns == null) && (writeState
== System.Xml.WriteState.Element))
! {
! throw new
ArgumentException
!
(S._("Xml_ArgumentException"), "ns");
! }
!
! if (Namespaces == false)
! {
! if ((ns == null) &&
(writeState == System.Xml.WriteState.Attribute))
! {
!
writer.Write(localName);
! }
! }
! else if (Namespaces == true)
! {
!
! try
! {
! Uri uri = new
System.Uri(ns);
! String prefix =
LookupPrefix(ns);
!
!
if((Object)prefix == null && prefix == String.Empty)
! {
! throw
new ArgumentException
!
(S._("Xml_PrefixNotFound"), "ns");
! }
! else
! {
!
! if
(writeState == System.Xml.WriteState.Attribute)
! {
!
if (prefix != scope.prefix)
!
{
!
writer.Write("{0}:{1}", prefix, localName);
!
}
!
else
!
{
!
writer.Write("{0}", localName);
!
}
! }
! else if
(writeState == System.Xml.WriteState.Element)
! {
!
if((Object)ns == null && ns == String.Empty)
!
{
!
throw new ArgumentException
!
(S._("Xml_NamespaceValueNull"));
!
}
!
else if (prefix != scope.prefix)
!
{
!
writer.Write("{0}:{1}", prefix, localName);
!
}
!
else if (prefix == scope.prefix)
!
{
!
writer.Write("{0}", localName);
!
}
! }
! }
! }
! catch
(UriFormatException e)
! {
! throw new
ArgumentException
!
(S._("Xml_InvalidUriFormat"), "ns");
! }
! }
!
! }
}
***************
*** 917,920 ****
--- 1041,1170 ----
}
+ // this is sorta a non-spec hack to get namespaces declared from within
attributes
+ // to be added to the namespaceManager
+ internal override void WriteStartAttribute(String prefix, String
localName,
+
String ns , String value, bool flagNS)
+ {
+ // heres the hack
+ if((Object)value != null && value !=
String.Empty && flagNS == true)
+ {
+ // add the namespace and prefix
to namespaceManager
+
namespaceManager.AddNamespace(localName, value);
+ }
+
+ // Validate the parameters.
+ if(!namespaces && (prefix != null || ns !=
null))
+ {
+ throw new ArgumentException
+
(S._("Xml_NamespacesNotSupported"));
+ }
+
+ // Check the state and output delimiters.
+ if(writeState ==
System.Xml.WriteState.Attribute)
+ {
+ writer.Write(quoteChar);
+ writer.Write(' ');
+ }
+ else if(writeState ==
System.Xml.WriteState.Element)
+ {
+ writer.Write(' ');
+ }
+ else if(writeState ==
System.Xml.WriteState.Closed)
+ {
+ throw new InvalidOperationException
+ (S._("Xml_InvalidWriteState"));
+ }
+
+ // Output the name of the attribute, with
appropriate prefixes.
+ if(((Object)prefix) != null && prefix !=
String.Empty &&
+ ((Object)ns) != null && ns != String.Empty)
+ {
+ // We need to associate a prefix with a
namespace.
+ String currMapping = LookupPrefix(ns);
+ if(currMapping == prefix)
+ {
+ // The prefix is already mapped
to this URI.
+ if(prefix != scope.prefix)
+ {
+ writer.Write(prefix);
+ writer.Write(':');
+ }
+ }
+ else
+ {
+ // Create a new pseudo-prefix
for the URI.
+ prefix = GetPseudoPrefix(ns);
+ writer.Write("xmlns:");
+ writer.Write(prefix);
+ writer.Write('=');
+ writer.Write(quoteChar);
+ WriteQuotedString(ns);
+ writer.Write(quoteChar);
+ writer.Write(' ');
+ writer.Write(prefix);
+ writer.Write(':');
+ }
+ }
+ else if(((Object)prefix) != null && prefix !=
String.Empty)
+ {
+ // We were only given a prefix, so
output it directly.
+ if(prefix != scope.prefix)
+ {
+ writer.Write(prefix);
+ writer.Write(':');
+ }
+ }
+ else if(((Object)ns) != null && ns !=
String.Empty)
+ {
+ // We were only given a namespace, so
find the prefix.
+ prefix = LookupPrefix(ns);
+ if(((Object)prefix) == null ||
prefix.Length == 0)
+ {
+ // Create a new pseudo-prefix
for the URI.
+ prefix = GetPseudoPrefix(ns);
+ writer.Write("xmlns:");
+ writer.Write(prefix);
+ writer.Write('=');
+ writer.Write(quoteChar);
+ WriteQuotedString(ns);
+ writer.Write(quoteChar);
+ writer.Write(' ');
+ writer.Write(prefix);
+ writer.Write(':');
+ }
+ }
+ writer.Write(localName);
+
+ // Output the start of the attribute value.
+ writer.Write('=');
+ writer.Write(quoteChar);
+
+ // We are now in the attribute state.
+ writeState = System.Xml.WriteState.Attribute;
+
+ // Recognise special attributes.
+ if(prefix == "xml")
+ {
+ if(localName == "lang")
+ {
+ special = Special.Lang;
+ }
+ else if(localName == "space")
+ {
+ special = Special.Space;
+ }
+ else
+ {
+ special = Special.None;
+ }
+ }
+ else
+ {
+ special = Special.None;
+ }
+
+ }
+
+
// Write the start of an XML document.
public override void WriteStartDocument(bool standalone)
Index: XmlWriter.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlWriter.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** XmlWriter.cs 27 Jul 2002 00:28:56 -0000 1.3
--- XmlWriter.cs 31 Dec 2002 11:13:05 -0000 1.4
***************
*** 70,74 ****
throw new
ArgumentNullException("localName");
}
! WriteStartAttribute(prefix, localName, ns);
WriteString(value);
WriteEndAttribute();
--- 70,91 ----
throw new
ArgumentNullException("localName");
}
! if((Object)value != null && value !=
String.Empty)
! {
! bool flagNS = true;
! try {
! Uri uri = new Uri(value);
! }
! catch (UriFormatException e)
! {
! flagNS = false;
! }
!
! WriteStartAttribute(prefix, localName,
ns, value, flagNS);
! }
! else
! {
! WriteStartAttribute(prefix, localName,
ns);
! }
!
WriteString(value);
WriteEndAttribute();
***************
*** 349,352 ****
--- 366,372 ----
}
+ // the hack for namespaces
+ internal abstract void WriteStartAttribute(String prefix, String
localName, String ns, String value, bool flagNS);
+
// Write the start of an XML document.
public abstract void WriteStartDocument(bool standalone);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlTextWriter.cs,1.8,1.9 XmlWriter.cs,1.3,1.4,
Gopal.V <address@hidden> <=