diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-03-02 19:22:58 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-03-02 19:22:58 +0300 |
commit | cd68f60029fdb83372d0452d3382b27f0edd0099 (patch) | |
tree | cace6dc4b422d5eec2bc1985d9bf773caa8d014f /mcs/class/System.XML/Mono.Xml.Xsl.Operations | |
parent | 8cd71d6795ccd13a1103b957308db9476b9b9cc2 (diff) |
2005-03-02 Atsushi Enomoto <atsushi@ximian.com>
* XslCompiledContext.cs, XslTransformProcessor.cs,
XslElement.cs, XslCopyOf.cs, XslLiteralElement.cs, XslCopy.cs :
According to errata E25, those namespaces 1) that has the same
name as current element's prefix, or an empty name when current
element's namespace URI is empty, are not written to output.
So added current element information to XPathContext and added
prefix parameter to PushElementState(), added xsl:copy check to
TryElementNamespacesOutput().
http://www.w3.org/1999/11/REC-xslt-19991116-errata/
svn path=/trunk/mcs/; revision=41363
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.Xsl.Operations')
5 files changed, 34 insertions, 11 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog index 714bc28b3f9..2a2a0dc90a1 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog @@ -1,3 +1,14 @@ +2005-03-02 Atsushi Enomoto <atsushi@ximian.com> + + * XslElement.cs, XslCopyOf.cs, XslLiteralElement.cs, XslCopy.cs : + According to errata E25, those namespaces 1) that has the same + name as current element's prefix, or an empty name when current + element's namespace URI is empty, are not written to output. + So added current element information to XPathContext and added + prefix parameter to PushElementState(), added xsl:copy check to + TryElementNamespacesOutput(). + http://www.w3.org/1999/11/REC-xslt-19991116-errata/ + 2005-02-24 Atsushi Enomoto <atsushi@ximian.com> * XslAttribute.cs : reduced reference to stylesheet XPathNavigator by diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs index 735d0ab33e3..3d70d27716d 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopy.cs @@ -83,16 +83,19 @@ namespace Mono.Xml.Xsl.Operations { break; case XPathNodeType.Element: bool isCData = p.InsideCDataElement; - p.PushElementState (p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI, true); - p.Out.WriteStartElement (p.CurrentNode.Prefix, p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI); + string prefix = p.CurrentNode.Prefix; + p.PushElementState (prefix, p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI, true); + p.Out.WriteStartElement (prefix, p.CurrentNode.LocalName, p.CurrentNode.NamespaceURI); - p.TryElementNamespacesOutput (nsDecls, null); + p.TryElementNamespacesOutput (nsDecls, null, prefix); if (useAttributeSets != null) foreach (XmlQualifiedName s in useAttributeSets) p.ResolveAttributeSet (s).Evaluate (p); if (p.CurrentNode.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml)) { do { + if (p.CurrentNode.LocalName == prefix) + continue; p.Out.WriteNamespaceDecl (p.CurrentNode.LocalName, p.CurrentNode.Value); } while (p.CurrentNode.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml)); p.CurrentNode.MoveToParent (); @@ -127,7 +130,8 @@ namespace Mono.Xml.Xsl.Operations { break; case XPathNodeType.Namespace: - p.Out.WriteNamespaceDecl (p.CurrentNode.Name, p.CurrentNode.Value); + if (p.XPathContext.ElementPrefix != p.CurrentNode.Name) + p.Out.WriteNamespaceDecl (p.CurrentNode.Name, p.CurrentNode.Value); break; default: diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs index 459c5492566..34473656ef7 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslCopyOf.cs @@ -58,12 +58,18 @@ namespace Mono.Xml.Xsl.Operations { case XPathNodeType.Element: bool isCData = p.InsideCDataElement; - p.PushElementState (nav.LocalName, nav.NamespaceURI, false); - outputter.WriteStartElement (nav.Prefix, nav.LocalName, nav.NamespaceURI); + string prefix = nav.Prefix; + string ns = nav.NamespaceURI; + p.PushElementState (prefix, nav.LocalName, ns, false); + outputter.WriteStartElement (prefix, nav.LocalName, ns); if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml)) { do { + if (prefix == nav.Name) + continue; + if (nav.Name.Length == 0 && ns.Length == 0) + continue; outputter.WriteNamespaceDecl (nav.Name, nav.Value); } while (nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml)); nav.MoveToParent (); @@ -93,7 +99,9 @@ namespace Mono.Xml.Xsl.Operations { break; case XPathNodeType.Namespace: - outputter.WriteNamespaceDecl (nav.Name, nav.Value); + if (nav.Name != p.XPathContext.ElementPrefix && + (p.XPathContext.ElementNamespace.Length > 0 || nav.Name.Length > 0)) + outputter.WriteNamespaceDecl (nav.Name, nav.Value); break; case XPathNodeType.Attribute: outputter.WriteAttributeString (nav.Prefix, nav.LocalName, nav.NamespaceURI, nav.Value); diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs index 8b0bb7ee07e..9ac2fb0f7f5 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslElement.cs @@ -120,9 +120,9 @@ namespace Mono.Xml.Xsl.Operations { XmlConvert.VerifyName (nm); bool isCData = p.InsideCDataElement; - p.PushElementState (localName, nmsp, false); + p.PushElementState (prefix, localName, nmsp, false); p.Out.WriteStartElement (prefix, localName, nmsp); - p.TryElementNamespacesOutput (null, null); +// p.TryElementNamespacesOutput (null, null, null); if (useAttributeSets != null) foreach (XmlQualifiedName s in useAttributeSets) diff --git a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs index 0d9952b16fc..1fd7dcf14dd 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslLiteralElement.cs @@ -120,7 +120,7 @@ namespace Mono.Xml.Xsl.Operations { GetCorrectNames (); bool isCData = p.InsideCDataElement; - p.PushElementState (localname, nsUri, true); + p.PushElementState (prefix, localname, nsUri, true); p.Out.WriteStartElement (prefix, localname, nsUri); if (useAttributeSets != null) @@ -133,7 +133,7 @@ namespace Mono.Xml.Xsl.Operations { ((XslLiteralAttribute)attrs [i]).Evaluate (p); } - p.TryElementNamespacesOutput (nsDecls, null); + p.TryElementNamespacesOutput (nsDecls, null, null); if (children != null) children.Evaluate (p); |