public XmlDsigXsltTransform (bool includeComments)
{
comments = includeComments;
- Algorithm = "http://www.w3.org/TR/1999/REC-xslt-19991116";
+ Algorithm = XmlSignature.AlgorithmNamespaces.XmlDsigXsltTransform;
}
public override Type [] InputTypes {
get {
if (input == null) {
- lock (this) {
- // this way the result is cached if called multiple time
- input = new Type [3];
- input [0] = typeof (System.IO.Stream);
- input [1] = typeof (System.Xml.XmlDocument);
- input [2] = typeof (System.Xml.XmlNodeList);
- }
+ input = new Type [3];
+ input [0] = typeof (System.IO.Stream);
+ input [1] = typeof (System.Xml.XmlDocument);
+ input [2] = typeof (System.Xml.XmlNodeList);
}
return input;
}
public override Type [] OutputTypes {
get {
if (output == null) {
- lock (this) {
- // this way the result is cached if called multiple time
- output = new Type [1];
- output [0] = typeof (System.IO.Stream);
- }
+ output = new Type [1];
+ output [0] = typeof (System.IO.Stream);
}
return output;
}
public override object GetOutput ()
{
-#if NET_2_0
if (xnl == null)
throw new ArgumentNullException ("LoadInnerXml before transformation.");
-#endif
+
XmlResolver resolver = GetResolver ();
XslTransform xsl = new XslTransform ();
XmlDocument doc = new XmlDocument ();
-#if NET_1_1
doc.XmlResolver = resolver;
-#endif
foreach (XmlNode n in xnl)
doc.AppendChild (doc.ImportNode (n, true));
-#if NET_1_1
xsl.Load (doc, resolver);
-#else
- xsl.Load (doc);
-#endif
if (inputDoc == null)
-#if NET_2_0
throw new ArgumentNullException ("LoadInput before transformation.");
-#else
- throw new NullReferenceException ("LoadInput before transformation.");
-#endif
MemoryStream stream = new MemoryStream ();
// only possible output: Stream
-#if NET_1_1
xsl.XmlResolver = resolver;
-#endif
xsl.Transform (inputDoc, null, stream);
stream.Seek (0, SeekOrigin.Begin);
public override object GetOutput (Type type)
{
- if (type != Type.GetType ("System.IO.Stream"))
+ if (type != typeof (Stream))
throw new ArgumentException ("type");
return GetOutput ();
}
public override void LoadInput (object obj)
{
// possible input: Stream, XmlDocument, and XmlNodeList
- if (obj is Stream) {
+ Stream s = (obj as Stream);
+ if (s != null) {
inputDoc = new XmlDocument ();
-#if NET_1_1
inputDoc.XmlResolver = GetResolver ();
-#endif
// inputDoc.Load (obj as Stream);
- inputDoc.Load (new XmlSignatureStreamReader (
- new StreamReader (obj as Stream)));
+ inputDoc.Load (new XmlSignatureStreamReader (new StreamReader (s)));
+ return;
}
- else if (obj is XmlDocument) {
- inputDoc= obj as XmlDocument;
+
+ XmlDocument xd = (obj as XmlDocument);
+ if (xd != null) {
+ inputDoc = xd;
+ return;
}
- else if (obj is XmlNodeList) {
+
+ XmlNodeList nl = (obj as XmlNodeList);
+ if (nl != null) {
inputDoc = new XmlDocument ();
-#if NET_1_1
inputDoc.XmlResolver = GetResolver ();
-#endif
- XmlNodeList nl = (XmlNodeList) obj;
for (int i = 0; i < nl.Count; i++)
inputDoc.AppendChild (inputDoc.ImportNode (nl [i], true));
}