1 //------------------------------------------------------------------------------
2 // <copyright file="WhitespaceRule.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 using System.Diagnostics;
11 using System.Xml.Xsl.Runtime;
13 namespace System.Xml.Xsl.Qil {
15 /// Data structure for storing whitespace rules generated by xsl:strip-space and xsl:preserve-space
17 internal class WhitespaceRule {
18 private string localName;
19 private string namespaceName;
20 private bool preserveSpace;
23 /// Allow derived classes to construct empty whitespace rule.
25 protected WhitespaceRule() {
29 /// Construct new whitespace rule.
31 public WhitespaceRule(string localName, string namespaceName, bool preserveSpace) {
32 Init(localName, namespaceName, preserveSpace);
36 /// Initialize whitespace rule after it's been constructed.
38 protected void Init(string localName, string namespaceName, bool preserveSpace) {
39 this.localName = localName;
40 this.namespaceName = namespaceName;
41 this.preserveSpace = preserveSpace;
45 /// Local name of the element.
47 public string LocalName {
48 get { return localName; }
49 set { localName = value; }
53 /// Namespace name (uri) of the element.
55 public string NamespaceName {
56 get { return namespaceName; }
57 set { namespaceName = value; }
61 /// True, if this element is whitespace-preserving.
62 /// False, if this element is whitespace-stripping.
64 public bool PreserveSpace {
65 get { return preserveSpace; }
69 /// Serialize the object to BinaryWriter.
71 public void GetObjectData(XmlQueryDataWriter writer) {
72 Debug.Assert(this.GetType() == typeof(WhitespaceRule), "Serialization of WhitespaceRule subclasses is not implemented");
74 writer.WriteStringQ(localName);
75 // string namespaceName;
76 writer.WriteStringQ(namespaceName);
77 // bool preserveSpace;
78 writer.Write(preserveSpace);
82 /// Deserialize the object from BinaryReader.
84 public WhitespaceRule(XmlQueryDataReader reader) {
86 this.localName = reader.ReadStringQ();
87 // string namespaceName;
88 this.namespaceName = reader.ReadStringQ();
89 // bool preserveSpace;
90 this.preserveSpace = reader.ReadBoolean();