Browse Source

Process XslLiteralElements with only child attributes as empty ones.
Fixes #14751

Marcos Henrich 11 years ago
parent
commit
af4dcd117d

+ 2 - 1
mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs

@@ -140,7 +140,8 @@ namespace Mono.Xml.Xsl.Operations {
 
 			if (children != null) children.Evaluate (p);
 
-			if (isEmptyElement)
+			var templateContent = children as XslTemplateContent;
+			if (isEmptyElement || (templateContent != null && templateContent.IsEmptyElement))
 				p.Out.WriteEndElement ();
 			else
 				p.Out.WriteFullEndElement ();

+ 13 - 0
mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslTemplateContent.cs

@@ -46,6 +46,7 @@ namespace Mono.Xml.Xsl.Operations
 		int stackSize;
 		XPathNodeType parentType;
 		bool xslForEach;
+		bool isEmptyElement;
 		
 		public XslTemplateContent (Compiler c,
 			XPathNodeType parentType, bool xslForEach)
@@ -60,6 +61,10 @@ namespace Mono.Xml.Xsl.Operations
 			get { return parentType; }
 		}
 
+		public bool IsEmptyElement {
+			get { return isEmptyElement; }
+		}
+
 		protected override void Compile (Compiler c)
 		{
 			if (c.Debugger != null)
@@ -178,6 +183,14 @@ namespace Mono.Xml.Xsl.Operations
 				
 			} while (c.Input.MoveToNext ());
 			
+			isEmptyElement = true;
+			foreach (var n in content) {
+				if (n is XslAttribute)
+					continue;
+
+				isEmptyElement = false;
+				break;
+			}
 			
 			if (hasStack) {
 				stackSize = c.PopScope ().VariableHighTide;