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@gmail.com>2007-12-27 17:34:30 +0300
committerAtsushi Eno <atsushieno@gmail.com>2007-12-27 17:34:30 +0300
commit51e9004e2fb0ed132f03d24e179dd311ddeef45b (patch)
treeddee24147cbdb60413e71ab70aa28f4f86f0441e /mcs/class/System.XML/Mono.Xml.Xsl
parentbfb0849d2b0ae161dc3681728dfdcfd1ccb59844 (diff)
2007-12-27 Atsushi Enomoto <atsushi@ximian.com>
* XslTemplate.cs, XslTransformProcessor.cs : Some disambiguation around whitespace handling (input strip/preserve and output control). * XslStylesheet.cs : change GetPreserveWhitespace() to match the actual behavior; it does not (and should not) really walk through ancestors. Default whitespace handling depends on the default ("*") handling. (Those changes should not affect anything.) svn path=/trunk/mcs/; revision=91939
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.Xsl')
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog10
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs40
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs2
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs15
4 files changed, 44 insertions, 23 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
index d6ec9cb759d..56f0a161c9b 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
@@ -1,3 +1,13 @@
+2007-12-27 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XslTemplate.cs, XslTransformProcessor.cs :
+ Some disambiguation around whitespace handling (input strip/preserve
+ and output control).
+ * XslStylesheet.cs : change GetPreserveWhitespace() to match the
+ actual behavior; it does not (and should not) really walk through
+ ancestors. Default whitespace handling depends on the default ("*")
+ handling. (Those changes should not affect anything.)
+
2007-10-30 Atsushi Enomoto <atsushi@ximian.com>
* Compiler.cs : added CheckExtraAttributes() to check invalid
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
index 41d1eb3a49b..1ee3be89201 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
@@ -233,11 +233,13 @@ namespace Mono.Xml.Xsl {
{
if (!HasSpaceControls)
return true;
- return GetPreserveWhitespaceInternal (nav.Clone ());
- }
+ nav = nav.Clone ();
+
+ if (!nav.MoveToParent () || nav.NodeType != XPathNodeType.Element) {
+ object def = GetDefaultXmlSpace ();
+ return def == null || (XmlSpace) def == XmlSpace.Preserve;
+ }
- private bool GetPreserveWhitespaceInternal (XPathNavigator nav)
- {
string localName = nav.LocalName;
string ns = nav.NamespaceURI;
@@ -263,16 +265,8 @@ namespace Mono.Xml.Xsl {
}
}
- if (o == null) {
- o = spaceControls [allMatchName];
- if (o == null) {
- for (int i = 0; i < imports.Count; i++) {
- o = ((XslStylesheet) imports [i]).SpaceControls [qname];
- if (o != null)
- break;
- }
- }
- }
+ if (o == null)
+ o = GetDefaultXmlSpace ();
if (o != null) {
switch ((XmlSpace) o) {
@@ -282,10 +276,20 @@ namespace Mono.Xml.Xsl {
return false;
}
}
- if (nav.MoveToParent () &&
- nav.NodeType == XPathNodeType.Element)
- return GetPreserveWhitespace (nav);
- return true;
+ throw new SystemException ("Mono BUG: should not reach here");
+ }
+
+ object GetDefaultXmlSpace ()
+ {
+ object o = spaceControls [allMatchName];
+ if (o == null) {
+ for (int i = 0; i < imports.Count; i++) {
+ o = ((XslStylesheet) imports [i]).SpaceControls [allMatchName];
+ if (o != null)
+ break;
+ }
+ }
+ return o;
}
bool countedNamespaceAliases;
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs
index 41c77bdcf10..1c7cc9c1628 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs
@@ -467,7 +467,7 @@ namespace Mono.Xml.Xsl {
public override void Evaluate (XslTransformProcessor p, Hashtable withParams)
{
if (p.CurrentNode.NodeType == XPathNodeType.Whitespace) {
- if (p.PreserveWhitespace ())
+ if (p.PreserveOutputWhitespace)
p.Out.WriteWhitespace (p.CurrentNode.Value);
}
else
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
index ea03b671105..ca41946dd9e 100644
--- a/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
+++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
@@ -457,6 +457,15 @@ namespace Mono.Xml.Xsl {
{
if (!iter.MoveNext ())
return false;
+ // FIXME: this check should not be required.
+ // Since removal of this check causes some regressions,
+ // there should be some wrong assumption on our
+ // BaseIterator usage. Actually BaseIterator should
+ // not do whitespace check and every PreserveWhitespace
+ // evaluation in XslTransform should be done at
+ // different level. One possible solution is to wrap
+ // the input XmlReader by a new XmlReader that takes
+ // whitespace stripping into consideration.
if (iter.Current.NodeType == XPathNodeType.Whitespace && !XPathContext.PreserveWhitespace (iter.Current))
return NodesetMoveNext (iter);
return true;
@@ -601,10 +610,8 @@ namespace Mono.Xml.Xsl {
Out.InsideCDataSection = XPathContext.IsCData;
}
- public bool PreserveWhitespace ()
- {
-// return XPathContext.PreserveWhitespace (CurrentNode);
- return XPathContext.Whitespace;
+ public bool PreserveOutputWhitespace {
+ get { return XPathContext.Whitespace; }
}
}
}