|
| 1 | +/* |
| 2 | + This file is licensed to You under the Apache License, Version 2.0 |
| 3 | + (the "License"); you may not use this file except in compliance with |
| 4 | + the License. You may obtain a copy of the License at |
| 5 | +
|
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | + Unless required by applicable law or agreed to in writing, software |
| 9 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + See the License for the specific language governing permissions and |
| 12 | + limitations under the License. |
| 13 | +*/ |
| 14 | + |
| 15 | +using Org.XmlUnit.Util; |
| 16 | + |
| 17 | +namespace Org.XmlUnit.Input { |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// A source that is obtained from a different source by removing |
| 21 | + /// all empty text nodes and normalizing the non-empty ones. |
| 22 | + /// </summary> |
| 23 | + /// <remarks> |
| 24 | + /// <para> |
| 25 | + /// "normalized" in this context means all XML whitespace |
| 26 | + /// characters are replaced by space characters and |
| 27 | + /// consecutive XML whitespace characters are collapsed. |
| 28 | + /// </para> |
| 29 | + /// <para> |
| 30 | + /// This class is similiar to <see cref="XmlWhitespaceStrippedSource"/> |
| 31 | + /// but in addition "normalizes" XML whitespace. |
| 32 | + /// </para> |
| 33 | + /// <para> |
| 34 | + /// Unlike <see cref="WhitespaceNormalizedSource"/> this uses XML's idea |
| 35 | + /// of whitespace rather than the more extensive set considered |
| 36 | + /// whitespace by Unicode. |
| 37 | + /// </para> |
| 38 | + /// <para> |
| 39 | + /// since XMLUnit 2.10.0 |
| 40 | + /// </para> |
| 41 | + /// </remarks> |
| 42 | + public class XmlWhitespaceNormalizedSource : DOMSource { |
| 43 | + /// <summary> |
| 44 | + /// Creates a new Source with the same content as another source normalizing XML whitespace in Text nodes. |
| 45 | + /// </summary> |
| 46 | + /// <param name="originalSource">source with the original content</param> |
| 47 | + public XmlWhitespaceNormalizedSource(ISource originalSource) : |
| 48 | + base(Nodes.NormalizeXmlWhitespace(originalSource.ToDocument())) |
| 49 | + { |
| 50 | + SystemId = originalSource.SystemId; |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments