diff options
Diffstat (limited to 'mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/DTMXPathDocumentWriter.cs')
-rw-r--r-- | mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/DTMXPathDocumentWriter.cs | 450 |
1 files changed, 225 insertions, 225 deletions
diff --git a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/DTMXPathDocumentWriter.cs b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/DTMXPathDocumentWriter.cs index 0dd7c7849ad..75f291803bd 100644 --- a/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/DTMXPathDocumentWriter.cs +++ b/mcs/class/Mono.Xml.Ext/Mono.Xml.XPath/DTMXPathDocumentWriter.cs @@ -176,8 +176,8 @@ namespace Mono.Xml.XPath if (!nodes [nodeIndex].IsEmptyElement) parentForFirstChild = nodeIndex; -
- state = WriteState.Content;
+ + state = WriteState.Content; writerDepth++; } @@ -304,40 +304,40 @@ namespace Mono.Xml.XPath } return null; } -
- public override void WriteCData (string data)
- {
- AddTextNode (data);
- }
-
- private void AddTextNode (string data)
- {
- switch (state) {
- case WriteState.Element:
- CloseStartElement ();
- break;
- case WriteState.Content:
- break;
- default:
- throw new InvalidOperationException ("Invalid document state for CDATA section: " + state);
- }
-
- // When text after text, just add the value, and return.
- if (nodes [nodeIndex].Depth == writerDepth) {
- switch (nodes [nodeIndex].NodeType) {
- case XPathNodeType.Text:
- case XPathNodeType.SignificantWhitespace:
- nodes [nodeIndex].Value += data;
- if (IsWhitespace (data))
- nodes [nodeIndex].NodeType = XPathNodeType.SignificantWhitespace;
- else
- nodes [nodeIndex].NodeType = XPathNodeType.Text;
- return;
- }
- }
-
- int parent = GetParentIndex ();
- UpdateTreeForAddition ();
+ + public override void WriteCData (string data) + { + AddTextNode (data); + } + + private void AddTextNode (string data) + { + switch (state) { + case WriteState.Element: + CloseStartElement (); + break; + case WriteState.Content: + break; + default: + throw new InvalidOperationException ("Invalid document state for CDATA section: " + state); + } + + // When text after text, just add the value, and return. + if (nodes [nodeIndex].Depth == writerDepth) { + switch (nodes [nodeIndex].NodeType) { + case XPathNodeType.Text: + case XPathNodeType.SignificantWhitespace: + nodes [nodeIndex].Value += data; + if (IsWhitespace (data)) + nodes [nodeIndex].NodeType = XPathNodeType.SignificantWhitespace; + else + nodes [nodeIndex].NodeType = XPathNodeType.Text; + return; + } + } + + int parent = GetParentIndex (); + UpdateTreeForAddition (); AddNode (parent, 0, // attribute @@ -354,29 +354,29 @@ namespace Mono.Xml.XPath 0, // nsIndex 0, // line info 0); - }
-
- private void CheckTopLevelNode ()
- {
- switch (state) {
- case WriteState.Element:
- CloseStartElement ();
- break;
- case WriteState.Content:
- case WriteState.Prolog:
- case WriteState.Start:
- break;
- default:
- throw new InvalidOperationException ("Invalid document state for CDATA section: " + state);
- }
- }
-
- public override void WriteComment (string data)
- {
- CheckTopLevelNode ();
-
- int parent = GetParentIndex ();
- UpdateTreeForAddition ();
+ } + + private void CheckTopLevelNode () + { + switch (state) { + case WriteState.Element: + CloseStartElement (); + break; + case WriteState.Content: + case WriteState.Prolog: + case WriteState.Start: + break; + default: + throw new InvalidOperationException ("Invalid document state for CDATA section: " + state); + } + } + + public override void WriteComment (string data) + { + CheckTopLevelNode (); + + int parent = GetParentIndex (); + UpdateTreeForAddition (); AddNode (parent, 0, // attribute @@ -393,14 +393,14 @@ namespace Mono.Xml.XPath 0, // nsIndex 0, // line info 0); - }
-
- public override void WriteProcessingInstruction (string name, string data)
- {
- CheckTopLevelNode ();
-
- int parent = GetParentIndex ();
- UpdateTreeForAddition ();
+ } + + public override void WriteProcessingInstruction (string name, string data) + { + CheckTopLevelNode (); + + int parent = GetParentIndex (); + UpdateTreeForAddition (); AddNode (parent, 0, // attribute @@ -417,14 +417,14 @@ namespace Mono.Xml.XPath 0, // nsIndex 0, // line info 0); - }
-
- public override void WriteWhitespace (string data)
- {
- CheckTopLevelNode ();
-
- int parent = GetParentIndex ();
- UpdateTreeForAddition ();
+ } + + public override void WriteWhitespace (string data) + { + CheckTopLevelNode (); + + int parent = GetParentIndex (); + UpdateTreeForAddition (); AddNode (parent, 0, // attribute @@ -441,43 +441,43 @@ namespace Mono.Xml.XPath 0, // nsIndex 0, // line info 0); - }
-
- public override void WriteStartDocument ()
- {
- // do nothing
- }
-
- public override void WriteStartDocument (bool standalone)
- {
- // do nothing
- }
-
- public override void WriteEndDocument ()
- {
- // do nothing
- }
-
- public override void WriteStartElement (string prefix, string localName, string ns)
- {
- switch (state) {
- case WriteState.Element:
- CloseStartElement ();
- break;
- case WriteState.Start:
- case WriteState.Prolog:
- case WriteState.Content:
- break;
- default:
- throw new InvalidOperationException ("Invalid document state for writing element: " + state);
- }
-
- int parent = GetParentIndex ();
- UpdateTreeForAddition ();
+ } + + public override void WriteStartDocument () + { + // do nothing + } + + public override void WriteStartDocument (bool standalone) + { + // do nothing + } + + public override void WriteEndDocument () + { + // do nothing + } + + public override void WriteStartElement (string prefix, string localName, string ns) + { + switch (state) { + case WriteState.Element: + CloseStartElement (); + break; + case WriteState.Start: + case WriteState.Prolog: + case WriteState.Content: + break; + default: + throw new InvalidOperationException ("Invalid document state for writing element: " + state); + } + + int parent = GetParentIndex (); + UpdateTreeForAddition (); WriteStartElement (parent, prevSibling, prefix, localName, ns); state = WriteState.Element; - }
+ } private void WriteStartElement (int parent, int previousSibling, string prefix, string localName, string ns) { @@ -511,49 +511,49 @@ namespace Mono.Xml.XPath lastNsInScope = namespaces [lastNsInScope].NextNamespace; } } -
- public override void WriteEndElement ()
- {
- WriteEndElement (false);
- }
-
- public override void WriteFullEndElement ()
- {
- WriteEndElement (true);
- }
-
- private void WriteEndElement (bool full)
- {
- switch (state) {
- case WriteState.Element:
- CloseStartElement ();
- break;
- case WriteState.Content:
- break;
- default:
- throw new InvalidOperationException ("Invalid state for writing EndElement: " + state);
- }
- parentForFirstChild = -1;
- if (nodes [nodeIndex].NodeType == XPathNodeType.Element) {
- if (!full)
- nodes [nodeIndex].IsEmptyElement = true;
- }
-
- writerDepth--;
- }
-
- public override void WriteStartAttribute (string prefix, string localName, string ns)
- {
- if (state != WriteState.Element)
- throw new InvalidOperationException ("Invalid document state for attribute: " + state);
-
- state = WriteState.Attribute;
+ + public override void WriteEndElement () + { + WriteEndElement (false); + } + + public override void WriteFullEndElement () + { + WriteEndElement (true); + } + + private void WriteEndElement (bool full) + { + switch (state) { + case WriteState.Element: + CloseStartElement (); + break; + case WriteState.Content: + break; + default: + throw new InvalidOperationException ("Invalid state for writing EndElement: " + state); + } + parentForFirstChild = -1; + if (nodes [nodeIndex].NodeType == XPathNodeType.Element) { + if (!full) + nodes [nodeIndex].IsEmptyElement = true; + } + + writerDepth--; + } + + public override void WriteStartAttribute (string prefix, string localName, string ns) + { + if (state != WriteState.Element) + throw new InvalidOperationException ("Invalid document state for attribute: " + state); + + state = WriteState.Attribute; if (ns == XmlNamespaces.XMLNS) ProcessNamespace ((prefix == null || prefix == String.Empty) ? "" : localName, String.Empty); // dummy: Value should be completed else ProcessAttribute (prefix, localName, ns, String.Empty); // dummy: Value should be completed - }
-
+ } + private void ProcessNamespace (string prefix, string ns) { nsIndex++; @@ -586,87 +586,87 @@ namespace Mono.Xml.XPath attributes [attributeIndex - 1].NextAttribute = attributeIndex; } - public override void WriteEndAttribute ()
- {
- if (state != WriteState.Attribute)
- throw new InvalidOperationException ();
-
- openNamespace = false;
- state = WriteState.Element;
- }
-
- public override void WriteString (string text)
- {
- if (WriteState == WriteState.Attribute) {
- if (openNamespace)
- namespaces [nsIndex].Namespace += text;
- else
- attributes [attributeIndex].Value += text;
- }
- else
- AddTextNode (text);
- }
-
- // Well, they cannot be supported, but actually used to
- // disable-output-escaping = "true"
- public override void WriteRaw (string data)
- {
- WriteString (data);
- }
- - public override void WriteRaw (char [] data, int start, int len)
- {
- WriteString (new string (data, start, len));
- }
-
- public override void WriteName (string name)
- {
- WriteString (name);
- }
-
- public override void WriteNmToken (string name)
- {
- WriteString (name);
- }
-
- public override void WriteBase64 (byte [] buffer, int index, int count)
- {
- throw new NotSupportedException ();
- } - - public override void WriteBinHex (byte [] buffer, int index, int count)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteChars (char [] buffer, int index, int count)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteCharEntity (char c)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteDocType (string name, string pub, string sys, string intSubset)
- {
- throw new NotSupportedException ();
- }
+ public override void WriteEndAttribute () + { + if (state != WriteState.Attribute) + throw new InvalidOperationException (); + + openNamespace = false; + state = WriteState.Element; + } + + public override void WriteString (string text) + { + if (WriteState == WriteState.Attribute) { + if (openNamespace) + namespaces [nsIndex].Namespace += text; + else + attributes [attributeIndex].Value += text; + } + else + AddTextNode (text); + } + + // Well, they cannot be supported, but actually used to + // disable-output-escaping = "true" + public override void WriteRaw (string data) + { + WriteString (data); + } + + public override void WriteRaw (char [] data, int start, int len) + { + WriteString (new string (data, start, len)); + } + + public override void WriteName (string name) + { + WriteString (name); + } + + public override void WriteNmToken (string name) + { + WriteString (name); + } + + public override void WriteBase64 (byte [] buffer, int index, int count) + { + throw new NotSupportedException (); + } + + public override void WriteBinHex (byte [] buffer, int index, int count) + { + throw new NotSupportedException (); + } + + public override void WriteChars (char [] buffer, int index, int count) + { + throw new NotSupportedException (); + } + + public override void WriteCharEntity (char c) + { + throw new NotSupportedException (); + } + + public override void WriteDocType (string name, string pub, string sys, string intSubset) + { + throw new NotSupportedException (); + } public override void WriteEntityRef (string name) { - throw new NotSupportedException ();
+ throw new NotSupportedException (); + } + + public override void WriteQualifiedName (string localName, string ns) + { + throw new NotSupportedException (); } - public override void WriteQualifiedName (string localName, string ns)
- {
- throw new NotSupportedException ();
- }
-
- public override void WriteSurrogateCharEntity (char high, char low)
- {
- throw new NotSupportedException ();
+ public override void WriteSurrogateCharEntity (char high, char low) + { + throw new NotSupportedException (); } private bool IsWhitespace (string data) @@ -683,7 +683,7 @@ namespace Mono.Xml.XPath } } return true; - }
+ } #endregion } } |