// (C) 2003 Oleg Tkachenko, Atsushi Enomoto
//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
using System.Collections;
+using System.Globalization;
using System.Xml;
using System.IO;
using System.Text;
/// Implements attributes dublicate checking, nemaspace stuff and
/// choosing of right Emitter implementation.
/// </summary>
- public class GenericOutputter : Outputter {
+ internal class GenericOutputter : Outputter {
private Hashtable _outputs;
//Current xsl:output
private XslOutput _currentOutput;
: this (writer, outputs, encoding, false)
{
}
-
+
internal GenericOutputter (XmlWriter writer, Hashtable outputs, Encoding encoding, bool isVariable)
: this (outputs, encoding)
{
this.pendingTextWriter = writer;
}
+
+ internal GenericOutputter (TextWriter writer, Hashtable outputs)
+ : this (writer, outputs, null)
+ {
+ }
+
+ internal GenericOutputter (XmlWriter writer, Hashtable outputs)
+ : this (writer, outputs, null)
+ {
+ }
+
private Emitter Emitter {
get {
if (_emitter == null)
{
XslOutput xslOutput = (XslOutput)_outputs [String.Empty];
switch (xslOutput.Method) {
- case OutputMethod.Unknown: //TODO: handle xml vs html
- if (localName != null && localName.ToLower () == "html" && ns == String.Empty)
+ case OutputMethod.Unknown:
+ if (localName != null && String.Compare (localName, "html", true, CultureInfo.InvariantCulture) == 0 && ns == String.Empty)
goto case OutputMethod.HTML;
goto case OutputMethod.XML;
case OutputMethod.HTML:
_emitter = new TextEmitter (pendingTextWriter);
break;
case OutputMethod.Custom:
- throw new NotImplementedException ("Custom output method is not implemented yet.");
+ throw new NotSupportedException ("Custom output method is not supported in this version.");
}
pendingTextWriter = null;
}
Attribute attr = pendingAttributes [i];
string prefix = attr.Prefix;
if (prefix == String.Empty)
- prefix = _nsManager.LookupPrefix (attr.Namespace);
+ prefix = _nsManager.LookupPrefix (attr.Namespace, false);
Emitter.WriteAttributeString (prefix, attr.LocalName, attr.Namespace, attr.Value);
}
- foreach (string prefix in _currentNsPrefixes) {
+ for (int i = 0; i < _currentNsPrefixes.Count; i++) {
+ string prefix = (string) _currentNsPrefixes [i];
string uri = _currentNamespaceDecls [prefix] as string;
if (prefix != String.Empty)
Emitter.WriteAttributeString ("xmlns", prefix, XmlNamespaceManager.XmlnsXmlns, uri);
public override void WriteNamespaceDecl (string prefix, string nsUri)
{
- if (_nsManager.LookupNamespace (prefix) == nsUri)
+ if (_nsManager.LookupNamespace (prefix, false) == nsUri)
return;
if (prefix == String.Empty) {
//Default namespace
if (_nsManager.DefaultNamespace != nsUri)
_nsManager.AddNamespace (prefix, nsUri);
- } else if (_nsManager.LookupPrefix (nsUri) == null)
+ } else if (_nsManager.LookupPrefix (nsUri, false) == null)
//That's new namespace - add it to the collection
_nsManager.AddNamespace (prefix, nsUri);