Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-08-09 14:47:20 +0400
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-08-09 14:47:20 +0400
commitb62bb260ec7df8a51fadcbe09a0831aebaa5fe89 (patch)
tree80c26159fe2ab81c992850b7fd456fc1db68c1bf /mcs/class/System.XML
parent2f334102cd62ec43da50fda3a50db4a339a9b3bb (diff)
Fix bug #4344 - xsl:stylesheet always ignored xsl template contents.
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs3
-rw-r--r--mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs33
2 files changed, 34 insertions, 2 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
index 31a488b7b81..4950c30aadd 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
@@ -376,6 +376,8 @@ namespace Mono.Xml.Xsl {
return; // Already done.
c.PushInputDocument (included);
+ included.MoveToRoot ();
+ included.MoveToFirstChild ();
while (c.Input.NodeType != XPathNodeType.Element)
if (!c.Input.MoveToNext ())
@@ -387,6 +389,7 @@ namespace Mono.Xml.Xsl {
templates.Add (new XslTemplate (c));
}
else {
+ c.Input.MoveToFirstChild ();
do {
if (c.Input.NodeType != XPathNodeType.Element)
continue;
diff --git a/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs b/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
index b276342806c..16573e3beee 100644
--- a/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
+++ b/mcs/class/System.XML/Test/System.Xml.Xsl/XslTransformTests.cs
@@ -2226,7 +2226,6 @@ NO
Assert.IsTrue (sw.ToString ().IndexOf ("NO") > 0);
}
-#if NET_2_0
[Test] // bug #349375
public void PreserveWhitespace ()
{
@@ -2416,6 +2415,36 @@ NO
}
private bool valueHasBeenSet;
-#endif
+
+ [Test] // bug #4434
+ public void IncludeProcessStylesheet ()
+ {
+ string includedXsl = @"<?xml version='1.0' ?>
+<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:doc='http://nwalsh.com/xsl/documentation/1.0' exclude-result-prefixes='doc' version='1.0'>
+ <doc:template name='foo' />
+ <xsl:template name='foo'>
+ <foo />
+ </xsl:template>
+</xsl:stylesheet>";
+ StreamWriter includedWriter = new StreamWriter ("include.xsl");
+ includedWriter.WriteLine (includedXsl);
+ includedWriter.Close ();
+ XslCompiledTransform transform = new XslCompiledTransform ();
+ string xsl = @"<?xml version='1.0' ?>
+<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+ <xsl:include href='include.xsl' />
+ <xsl:template match='/'>
+ <xsl:call-template name='foo' />
+ </xsl:template>
+</xsl:stylesheet>";
+ XmlReader xslReader = XmlReader.Create (new StringReader (xsl));
+ transform.Load (xslReader);
+ XmlReader inputReader = XmlReader.Create (new StringReader ("<bar />"));
+ var sw = new StringWriter ();
+ XmlWriter outputWriter = XmlWriter.Create (sw);
+ transform.Transform (inputReader, outputWriter);
+ outputWriter.Close ();
+ Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?><foo />", sw.ToString (), "#1");
+ }
}
}