Просмотр исходного кода

2006-04-07 Atsushi Enomoto <[email protected]>

	* XslTransformProcessor.cs : in NodesetMoveNext() take
	  XPathContext.PreserveWhitespace() into consideration.

	* XslTransformTests.cs : added StripSpace().

	* stripspace.xml, stripspace.xsl : added strip-space testcases.


svn path=/trunk/mcs/; revision=59160
Atsushi Eno 20 лет назад
Родитель
Сommit
2253f74608

+ 5 - 0
mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog

@@ -1,3 +1,8 @@
+2006-04-07  Atsushi Enomoto  <[email protected]>
+
+	* XslTransformProcessor.cs : in NodesetMoveNext() take
+	  XPathContext.PreserveWhitespace() into consideration.
+
 2006-03-15  Atsushi Enomoto  <[email protected]>
 
 	* XslTransformProcessor.cs,

+ 5 - 1
mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs

@@ -442,7 +442,11 @@ namespace Mono.Xml.Xsl {
 		
 		public bool NodesetMoveNext ()
 		{
-			return CurrentNodeset.MoveNext ();
+			if (!CurrentNodeset.MoveNext ())
+				return false;
+			if (CurrentNodeset.Current.NodeType == XPathNodeType.Whitespace && !XPathContext.PreserveWhitespace (CurrentNodeset.Current))
+				return NodesetMoveNext ();
+			return true;
 		}
 		
 		public void PushNodeset (XPathNodeIterator itr)

+ 4 - 0
mcs/class/System.XML/Test/System.Xml.Xsl/ChangeLog

@@ -1,3 +1,7 @@
+2006-04-07  Atsushi Enomoto  <[email protected]>
+
+	* XslTransformTests.cs : added StripSpace().
+
 2006-01-13  Atsushi Enomoto  <[email protected]>
 
 	* XslTransformTests.cs : added DocTypeAfterText().

+ 24 - 0
mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs

@@ -1874,5 +1874,29 @@ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-micros
 			} catch {
 			}
 		}
+
+		[Test]
+		public void StripSpace ()
+		{
+			string result = @"
+MonoDevelop
+ProjectTemplates
+FileTemplates
+IDE
+StartupHandlers
+FileTemplateTypes
+Workspace
+Applications
+Services
+";
+
+			XslTransform t = new XslTransform ();
+			t.Load ("Test/XmlFiles/xsl/stripspace.xsl");
+			XPathDocument d = new XPathDocument (
+				"Test/XmlFiles/xsl/stripspace.xml", XmlSpace.Preserve);
+			StringWriter sw = new StringWriter ();
+			t.Transform (d, null, sw);
+			Assert.AreEqual (result, sw.ToString ());
+		}
 	}
 }

+ 4 - 0
mcs/class/System.XML/Test/XmlFiles/xsl/ChangeLog

@@ -1,3 +1,7 @@
+2006-04-07  Atsushi Enomoto <[email protected]>
+
+	* stripspace.xml, stripspace.xsl : added strip-space testcases.
+
 2005-11-17  Atsushi Enomoto <[email protected]>
 
 	* 91834.xml, 91834a.xml, 91834.xsl : I ended up to add new files here.

+ 17 - 0
mcs/class/System.XML/Test/XmlFiles/xsl/stripspace.xml

@@ -0,0 +1,17 @@
+<Tree>
+    <Node name="">
+      <Node name="MonoDevelop">
+        <Node name="ProjectTemplates" />
+        <Node name="FileTemplates" />
+        <Node name="IDE">
+          <Node name="StartupHandlers" />
+        </Node>
+        <Node name="FileTemplateTypes" />
+      </Node>
+      <Node name="Workspace">
+        <Node name="Applications" />
+        <Node name="Services" />
+      </Node>
+    </Node>
+</Tree>
+

+ 16 - 0
mcs/class/System.XML/Test/XmlFiles/xsl/stripspace.xsl

@@ -0,0 +1,16 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:strip-space elements="*" />
+<xsl:output method="html" indent="no" />
+
+<xsl:template match="/">
+<xsl:apply-templates select="Tree/*"/>
+</xsl:template>
+
+<xsl:template match="Node">
+<xsl:value-of select="@name"/><xsl:text>
+</xsl:text>
+<xsl:apply-templates/>
+</xsl:template>
+
+</xsl:stylesheet>
+