1 //------------------------------------------------------------------------------
2 // <copyright file="XmlSignificantWhiteSpace.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
11 using System.Xml.XPath;
13 using System.Diagnostics;
15 // Represents the text content of an element or attribute.
16 public class XmlSignificantWhitespace : XmlCharacterData {
17 protected internal XmlSignificantWhitespace( string strData, XmlDocument doc ) : base( strData, doc ) {
18 if ( !doc.IsLoading && !base.CheckOnData( strData ) )
19 throw new ArgumentException(Res.GetString(Res.Xdom_WS_Char));
22 // Gets the name of the node.
23 public override String Name {
25 return OwnerDocument.strSignificantWhitespaceName;
29 // Gets the name of the current node without the namespace prefix.
30 public override String LocalName {
32 return OwnerDocument.strSignificantWhitespaceName;
36 // Gets the type of the current node.
37 public override XmlNodeType NodeType {
39 return XmlNodeType.SignificantWhitespace;
43 public override XmlNode ParentNode {
45 switch (parentNode.NodeType) {
46 case XmlNodeType.Document:
47 return base.ParentNode;
48 case XmlNodeType.Text:
49 case XmlNodeType.CDATA:
50 case XmlNodeType.Whitespace:
51 case XmlNodeType.SignificantWhitespace:
52 XmlNode parent = parentNode.parentNode;
53 while (parent.IsText) {
54 parent = parent.parentNode;
63 // Creates a duplicate of this node.
64 public override XmlNode CloneNode(bool deep) {
65 Debug.Assert( OwnerDocument != null );
66 return OwnerDocument.CreateSignificantWhitespace( Data );
69 public override String Value {
75 if ( CheckOnData( value ) )
78 throw new ArgumentException(Res.GetString(Res.Xdom_WS_Char));
82 // Saves the node to the specified XmlWriter.
83 public override void WriteTo(XmlWriter w) {
87 // Saves all the children of the node to the specified XmlWriter.
88 public override void WriteContentTo(XmlWriter w) {
89 // Intentionally do nothing
92 internal override XPathNodeType XPNodeType {
94 XPathNodeType xnt = XPathNodeType.SignificantWhitespace;
95 DecideXPNodeTypeForTextNodes(this, ref xnt);
100 internal override bool IsText {
106 public override XmlNode PreviousText {
108 if (parentNode.IsText) {