You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(174) |
Nov
(85) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(56) |
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(1) |
Jul
(132) |
Aug
(5) |
Sep
|
Oct
(314) |
Nov
(133) |
Dec
(18) |
2006 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Oleg T. <he...@us...> - 2005-11-15 22:17:35
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13690/v2/src/Xsl Modified Files: IXmlTransform.cs MvpXslTransform.cs Log Message: Index: MvpXslTransform.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/MvpXslTransform.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MvpXslTransform.cs 14 Nov 2005 21:35:48 -0000 1.2 +++ MvpXslTransform.cs 15 Nov 2005 22:17:25 -0000 1.3 @@ -3,7 +3,8 @@ using System.IO; using System.Xml; using System.Xml.Xsl; -using System.Xml.XPath; +using System.Xml.XPath; +using System.Reflection; #endregion namespace Mvp.Xml.Common.Xsl { @@ -16,33 +17,37 @@ this.compiledTransform = transform; } - public virtual void Transform(XmlInput defaulDocument, XsltArgumentList args, XmlOutput output) { + public virtual void Transform(XmlInput defaultDocument, XsltArgumentList args, XmlOutput output) { XmlWriter xmlWriter = output.destination as XmlWriter; bool closeWriter = false; - if (xmlWriter != null) { + if (xmlWriter == null) + { closeWriter = true; - while (true) { - TextWriter txtWriter = output.destination as TextWriter; - if (txtWriter != null) { - xmlWriter = XmlWriter.Create(txtWriter, this.compiledTransform.OutputSettings); - break; - } - Stream strm = output.destination as Stream; - if (strm != null) { - xmlWriter = XmlWriter.Create(strm, this.compiledTransform.OutputSettings); - break; - } - String str = output.destination as String; - if (str != null) { - // BugBug: We should read doc before creating output file in case they are the same - xmlWriter = XmlWriter.Create(str, this.compiledTransform.OutputSettings); - break; - } - throw new Exception("Unexpected XmlOutput"); + + TextWriter txtWriter = output.destination as TextWriter; + if (txtWriter != null) + { + xmlWriter = XmlWriter.Create(txtWriter, this.compiledTransform.OutputSettings); + break; } + Stream strm = output.destination as Stream; + if (strm != null) + { + xmlWriter = XmlWriter.Create(strm, this.compiledTransform.OutputSettings); + break; + } + String str = output.destination as String; + if (str != null) + { + // BugBug: We should read doc before creating output file in case they are the same + xmlWriter = XmlWriter.Create(str, this.compiledTransform.OutputSettings); + break; + } + throw new Exception("Unexpected XmlOutput"); + } try { - TransformToWriter(defaulDocument, args, xmlWriter); + TransformToWriter(defaultDocument, args, xmlWriter); } finally { if (closeWriter) { xmlWriter.Close(); @@ -56,47 +61,48 @@ ReaderSettings.ProhibitDtd = true; } - private void TransformToWriter(XmlInput defaulDocument, XsltArgumentList args, XmlWriter xmlWriter) { - XmlReader xmlReader = defaulDocument.source as XmlReader; + private void TransformToWriter(XmlInput defaultDocument, XsltArgumentList args, XmlWriter xmlWriter) { + XmlReader xmlReader = defaultDocument.source as XmlReader; if (xmlReader != null) { - compiledTransform.Transform(xmlReader, args, xmlWriter, defaulDocument.resolver); + compiledTransform.Transform(xmlReader, args, xmlWriter, defaultDocument.resolver); return; } - string str = defaulDocument.source as string; + IXPathNavigable nav = defaultDocument.source as IXPathNavigable; + if (nav != null) + { + TransformIXPathNavigable(nav, args, xmlWriter, defaultDocument.resolver); + return; + } + string str = defaultDocument.source as string; if (str != null) { using (XmlReader reader = XmlReader.Create(str, ReaderSettings)) { - compiledTransform.Transform(reader, args, xmlWriter, defaulDocument.resolver); + compiledTransform.Transform(reader, args, xmlWriter, defaultDocument.resolver); } return; } - Stream strm = defaulDocument.source as Stream; + Stream strm = defaultDocument.source as Stream; if (strm != null) { using (XmlReader reader = XmlReader.Create(strm, ReaderSettings)) { - compiledTransform.Transform(reader, args, xmlWriter, defaulDocument.resolver); + compiledTransform.Transform(reader, args, xmlWriter, defaultDocument.resolver); } return; } - TextReader txtReader = defaulDocument.source as TextReader; + TextReader txtReader = defaultDocument.source as TextReader; if (txtReader != null) { using (XmlReader reader = XmlReader.Create(txtReader, ReaderSettings)) { - compiledTransform.Transform(reader, args, xmlWriter, defaulDocument.resolver); - } - return; - } - IXPathNavigable nav = defaulDocument.source as IXPathNavigable; - if (nav != null) { - if (defaulDocument.resolver is XmlUrlResolver) { - compiledTransform.Transform(nav, args, xmlWriter); - } else { - // ToDo: It s just API limitation. We can implement it though reflection. - // Limitatio of this approach is that part of MvpXslransform will work only in FullTrust scenarious. - throw new NotImplementedException("IXPathNavigable + XmlResolver is not suported by XslCompiledTransform."); + compiledTransform.Transform(reader, args, xmlWriter, defaultDocument.resolver); } return; - } + } throw new Exception("Unexpected XmlInput"); } + private void TransformIXPathNavigable(IXPathNavigable nav, XsltArgumentList args, XmlWriter xmlWriter, XmlResolver resolver) + { + compiledTransform.GetType().GetMethod( + compiledTransform.Transform(nav, args, xmlWriter); + } + XmlWriterSettings DefaultWriterSettings { get { if (this.compiledTransform != null) { Index: IXmlTransform.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/IXmlTransform.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IXmlTransform.cs 7 Nov 2005 13:58:19 -0000 1.1 +++ IXmlTransform.cs 15 Nov 2005 22:17:25 -0000 1.2 @@ -15,10 +15,11 @@ public class XmlInput { internal object source ; internal XmlResolver resolver; - public XmlInput(XmlReader reader, XmlResolver resolver) { this.source = reader; this.resolver = resolver; } - public XmlInput(TextReader reader, XmlResolver resolver) { this.source = reader; this.resolver = resolver; } - public XmlInput(Stream stream, XmlResolver resolver) { this.source = stream; this.resolver = resolver; } - public XmlInput(String uri , XmlResolver resolver) { this.source = uri ; this.resolver = resolver; } + public XmlInput(XmlReader reader, XmlResolver resolver) { this.source = reader; this.resolver = resolver; } + public XmlInput(TextReader reader, XmlResolver resolver) { this.source = reader; this.resolver = resolver; } + public XmlInput(Stream stream, XmlResolver resolver) { this.source = stream; this.resolver = resolver; } + public XmlInput(String uri , XmlResolver resolver) { this.source = uri ; this.resolver = resolver; } + public XmlInput(IXPathNavigable nav , XmlResolver resolver) { this.source = nav ; this.resolver = resolver; } public XmlInput(XmlReader reader) : this(reader, new XmlUrlResolver()) {} public XmlInput(TextReader reader) : this(reader, new XmlUrlResolver()) {} public XmlInput(Stream stream) : this(stream, new XmlUrlResolver()) {} |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-11-15 17:29:30
|
Update of /cvsroot/mvp-xml/Design/v2/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19060/v2/tests Modified Files: CustomerSchema.Serialization.cs CustomerSchema.cs Log Message: Updated tests and generator for a bug in debug compilations of the generator when multiple types are generated, that causes generation of code that didn't compile. Index: CustomerSchema.Serialization.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.Serialization.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CustomerSchema.Serialization.cs 31 Oct 2005 12:28:17 -0000 1.3 +++ CustomerSchema.Serialization.cs 15 Nov 2005 17:29:04 -0000 1.4 @@ -1,3 +1,283 @@ +#region Original XmlSerializer code +/* ------------------------------------------------------------------------------------- +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif +[assembly:System.Reflection.AssemblyVersionAttribute("1.0.2145.25559")] +namespace Microsoft.Xml.Serialization.GeneratedAssembly { + + public class XmlSerializationWriterCustomerSchema : System.Xml.Serialization.XmlSerializationWriter { + + public void Write4_CustomerSchema(object o) { + WriteStartDocument(); + if (o == null) { + WriteEmptyTag(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + return; + } + TopLevelElement(); + Write3_CustomerSchema(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchema)o), false, false); + } + + void Write3_CustomerSchema(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchema o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementString(@"Name", @"http://tempuri.org/CustomerSchema.xsd", ((global::System.String)o.@Name)); + Write2_CustomerSchemaOrders(@"Orders", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o.@Orders), false, false); + WriteEndElement(o); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementStringRaw(@"Date", @"http://tempuri.org/CustomerSchema.xsd", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + + public class XmlSerializationReaderCustomerSchema : System.Xml.Serialization.XmlSerializationReader { + + public object Read4_CustomerSchema() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchema && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read3_CustomerSchema(false, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @"http://tempuri.org/CustomerSchema.xsd:CustomerSchema"); + } + return (object)o; + } + + global::Mvp.Xml.Design.Tests.CustomerSchema Read3_CustomerSchema(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchema o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchema(); + bool[] paramsRead = new bool[2]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id4_Name && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Name = Reader.ReadElementString(); + } + paramsRead[0] = true; + } + else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id5_Orders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o.@Orders = Read2_CustomerSchemaOrders(false, true); + paramsRead[1] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations1 = 0; + int readerCount1 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id6_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations1, ref readerCount1); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchema; + string id4_Name; + string id2_Item; + string id6_Date; + string id3_Item; + string id5_Orders; + + protected override void InitIDs() { + id1_CustomerSchema = Reader.NameTable.Add(@"CustomerSchema"); + id4_Name = Reader.NameTable.Add(@"Name"); + id2_Item = Reader.NameTable.Add(@"http://tempuri.org/CustomerSchema.xsd"); + id6_Date = Reader.NameTable.Add(@"Date"); + id3_Item = Reader.NameTable.Add(@""); + id5_Orders = Reader.NameTable.Add(@"Orders"); + } + } + + public abstract class XmlSerializer1 : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new XmlSerializationReaderCustomerSchema(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new XmlSerializationWriterCustomerSchema(); + } + } + + public sealed class CustomerSchemaSerializer : XmlSerializer1 { + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((XmlSerializationWriterCustomerSchema)writer).Write4_CustomerSchema(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((XmlSerializationReaderCustomerSchema)reader).Read4_CustomerSchema(); + } + } + + public class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new XmlSerializationReaderCustomerSchema(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new XmlSerializationWriterCustomerSchema(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Read4_CustomerSchema"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Write4_CustomerSchema"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:", new CustomerSchemaSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return new CustomerSchemaSerializer(); + return null; + } + } +} + +-------------------------------------------------------------------------------------*/ +#endregion //------------------------------------------------------------------------------ // <autogenerated> // This code was generated by the Mvp.Xml.XGen tool. @@ -402,7 +682,209 @@ } -#pragma warning restore 0642, 0219//------------------------------------------------------------------------------ +#pragma warning restore 0642, 0219 + +#region Original XmlSerializer code +/* ------------------------------------------------------------------------------------- +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif +[assembly:System.Reflection.AssemblyVersionAttribute("1.0.2145.25559")] +namespace Microsoft.Xml.Serialization.GeneratedAssembly { + + public class XmlSerializationWriterCustomerSchemaOrders : System.Xml.Serialization.XmlSerializationWriter { + + public void Write3_CustomerSchemaOrders(object o) { + WriteStartDocument(); + if (o == null) { + WriteNullTagLiteral(@"CustomerSchemaOrders", @""); + return; + } + TopLevelElement(); + Write2_CustomerSchemaOrders(@"CustomerSchemaOrders", @"", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o), true, false); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @""); + WriteElementStringRaw(@"Date", @"", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + + public class XmlSerializationReaderCustomerSchemaOrders : System.Xml.Serialization.XmlSerializationReader { + + public object Read3_CustomerSchemaOrders() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchemaOrders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read2_CustomerSchemaOrders(true, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @":CustomerSchemaOrders"); + } + return (object)o; + } + + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id2_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id3_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @":Date"); + } + } + else { + UnknownNode((object)o, @":Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchemaOrders; + string id3_Date; + string id2_Item; + + protected override void InitIDs() { + id1_CustomerSchemaOrders = Reader.NameTable.Add(@"CustomerSchemaOrders"); + id3_Date = Reader.NameTable.Add(@"Date"); + id2_Item = Reader.NameTable.Add(@""); + } + } + + public abstract class XmlSerializer1 : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new XmlSerializationReaderCustomerSchemaOrders(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new XmlSerializationWriterCustomerSchemaOrders(); + } + } + + public sealed class CustomerSchemaOrdersSerializer : XmlSerializer1 { + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchemaOrders", @""); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((XmlSerializationWriterCustomerSchemaOrders)writer).Write3_CustomerSchemaOrders(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((XmlSerializationReaderCustomerSchemaOrders)reader).Read3_CustomerSchemaOrders(); + } + } + + public class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new XmlSerializationReaderCustomerSchemaOrders(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new XmlSerializationWriterCustomerSchemaOrders(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::"] = @"Read3_CustomerSchemaOrders"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::"] = @"Write3_CustomerSchemaOrders"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::", new CustomerSchemaOrdersSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) return new CustomerSchemaOrdersSerializer(); + return null; + } + } +} + +-------------------------------------------------------------------------------------*/ +#endregion +//------------------------------------------------------------------------------ // <autogenerated> // This code was generated by the Mvp.Xml.XGen tool. // Tool Version: 1.1.1.0 @@ -706,3 +1188,5 @@ #pragma warning restore 0642, 0219 + + Index: CustomerSchema.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CustomerSchema.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ CustomerSchema.cs 15 Nov 2005 17:29:04 -0000 1.2 @@ -1,3 +1,15 @@ +//------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by the Mvp.Xml.XsdGen tool. +// Tool Version: 1.1.1.0 +// Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +//------------------------------------------------------------------------------ +// Workaround for bug http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=d457a36e-0ce8-4368-9a27-92762860d8e1 +#pragma warning disable 1591 namespace Mvp.Xml.Design.Tests { @@ -68,3 +80,5 @@ } } } + +#pragma warning restore 1591 \ No newline at end of file |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-11-15 17:29:12
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19060/v2/src/CustomTools/XGen Modified Files: XGenTool.cs XmlSerializerGenerator.cs Log Message: Updated tests and generator for a bug in debug compilations of the generator when multiple types are generated, that causes generation of code that didn't compile. Index: XGenTool.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XGenTool.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XGenTool.cs 31 Oct 2005 12:28:17 -0000 1.5 +++ XGenTool.cs 15 Nov 2005 17:29:04 -0000 1.6 @@ -193,10 +193,12 @@ private void CopyDesignToOutput(string outputPath) { // Copy Design assembly to output for the isolated AppDomain. - string asmfile = GetAssemblyPath(Assembly.GetExecutingAssembly()); + string asmFile = GetAssemblyPath(Assembly.GetExecutingAssembly()); + string targetFile = Path.Combine(outputPath, Path.GetFileName(asmFile)); try { - File.Copy(asmfile, Path.Combine(outputPath, Path.GetFileName(asmfile)), true); + if (File.Exists(targetFile)) File.Delete(targetFile); + File.Copy(asmFile, targetFile, true); } catch (Exception ex) { Index: XmlSerializerGenerator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XmlSerializerGenerator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XmlSerializerGenerator.cs 1 Nov 2005 06:44:41 -0000 1.4 +++ XmlSerializerGenerator.cs 15 Nov 2005 17:29:04 -0000 1.5 @@ -231,7 +231,7 @@ foreach (Type type in types) { - output += GenerateCodeForType(type, targetNamespace, output); + output += GenerateCodeForType(type, targetNamespace, output) + Environment.NewLine ; } return output; @@ -275,7 +275,8 @@ output = @" #pragma warning disable 0642, 0219 " + output + @" -#pragma warning restore 0642, 0219"; +#pragma warning restore 0642, 0219 +"; output = CustomTool.GetToolGeneratedCodeWarning(typeof(XGenTool)) + output; @@ -421,8 +422,11 @@ if (!previousOutput.Contains(delegateName)) { // Create a delegate for the event to expose. - // public delegate void [objectBeingRead]DeserializedHandler(Mvp.Xml.Design.Tests.Customer customer); + // internal delegate void [objectBeingRead]DeserializedHandler([objectBeingRead] value); + // Due to bug http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=a0bf7d07-bd96-4672-a1cb-f7fe7ff0b29e, + // the delegate will always be public. CodeTypeDelegate del = new CodeTypeDelegate(delegateName); + del.Attributes = MemberAttributes.Assembly; del.Parameters.Add(new CodeParameterDeclarationExpression( readMethodMatch.Groups[ReadMethodReturnType].Value, MakeFirstLower(objectBeingRead))); |
From: Oleg T. <he...@us...> - 2005-11-14 21:35:56
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3238/v2/src/Xsl Modified Files: MvpXslTransform.cs XslReader.cs Log Message: Index: MvpXslTransform.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/MvpXslTransform.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MvpXslTransform.cs 12 Nov 2005 21:28:59 -0000 1.1 +++ MvpXslTransform.cs 14 Nov 2005 21:35:48 -0000 1.2 @@ -1,24 +1,21 @@ +#region using using System; using System.IO; using System.Xml; using System.Xml.Xsl; -using System.Xml.XPath; +using System.Xml.XPath; +#endregion namespace Mvp.Xml.Common.Xsl { - public class MvpXslTransform { + + public class MvpXslTransform : IXmlTransform { XslCompiledTransform compiledTransform; + public MvpXslTransform(XslCompiledTransform transform) { if (transform == null) throw new ArgumentNullException("transform"); this.compiledTransform = transform; } -#if false - // do we want support old transform here as well? - XslTransform oldTransform; - public MvpXslTransform(XslTransform transform) { - if (transform == null) throw new ArgumentNullException("transform"); - this.oldTransform = transform; - } -#endif + public virtual void Transform(XmlInput defaulDocument, XsltArgumentList args, XmlOutput output) { XmlWriter xmlWriter = output.destination as XmlWriter; bool closeWriter = false; Index: XslReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/XslReader.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- XslReader.cs 14 Nov 2005 16:57:30 -0000 1.5 +++ XslReader.cs 14 Nov 2005 21:35:48 -0000 1.6 @@ -18,7 +18,9 @@ /// architectural and performance reasons the <see cref="XslCompiledTransform"/> /// class doesn't support transforming to an <see cref="XmlReader"/> as obsolete /// <see cref="XslTransform"/> class did and XslReader's goal is to - /// supplement such functionality.</para> + /// supplement such functionality.</para> + /// <para>XslReader has been developed and contributed to the Mvp.Xml project + /// by Sergey Dubinets (Microsoft XML Team).</para> /// </summary> /// <remarks> /// <para>XslReader can work in a singlethreaded (fully buffering) or a @@ -41,7 +43,10 @@ /// </para> /// <para>By default XslReader works in a multithreaded mode. You can choose the mode /// and the buffer size using <c>multiThread</c> and <c>initialBufferSize</c> arguments - /// when instantiating XslReader object.</para> + /// when instantiating XslReader object. On small XSLT outputs XslReader performs + /// better in a singlethreaded mode, but on medium and big outputs multithreaded + /// mode is preferrable. You are adviced to measure performance in both modes to + /// find out which suites better for your particular scenario.</para> /// <para>XslReader designed to be reused. Just provide another inoput XML or XSLT /// stylesheet, start transformation and read the output. If the <c>StartTransform()</c> /// method is called when previous @@ -61,9 +66,44 @@ /// After that create XslReader instance optionally choosing multithreaded or /// singlethreaded mode and initial buffer size.<br/> /// Finally start transformation by calling <c>StartTransform()</c> method and then - /// read transformation output via XslReader's object, which implements + /// you can read transformation output via XslReader object, which implements /// <see cref="XmlReader"/> API. - /// + /// </para> + /// <para> + /// Basic XslReader usage sample: + /// <code> + /// //Prepare XslCompiledTransform + /// XslCompiledTransform xslt = new XslCompiledTransform(); + /// xslt.Load("catalog.xslt"); + /// //Prepare input XML + /// XmlInput input = new XmlInput("books.xml"); + /// //Create XslReader + /// XslReader xslReader = new XslReader(xslt); + /// //Initiate transformation + /// xslReader.StartTransform(input, null); + /// //Now read XSLT output from the reader + /// XPathDocument results = new XPathDocument(xslReader); + /// </code> + /// A more advanced sample: + /// <code> + /// //Prepare XslCompiledTransform + /// XslCompiledTransform xslt = new XslCompiledTransform(); + /// xslt.Load("../../catalog.xslt"); + /// //Prepare XmlResolver to be used by the document() function + /// XmlResolver resolver = new XmlUrlResolver(); + /// resolver.Credentials = new NetworkCredential("user42", "god"); + /// //Prepare input XML + /// XmlInput input = new XmlInput("../../books.xml", resolver); + /// //Create XslReader, multithreaded mode, initial buffer for 32 nodes + /// XslReader xslReader = new XslReader(xslt, true, 32); + /// //XSLT parameters + /// XsltArgumentList prms = new XsltArgumentList(); + /// prms.AddParam("param2", "", "red"); + /// //Initiate transformation + /// xslReader.StartTransform(input, prms); + /// //Now read XSLT output from the reader + /// XPathDocument results = new XPathDocument(xslReader); + /// </code> /// </para> /// </example> public class XslReader : XmlReader { @@ -99,7 +139,7 @@ /// <param name="xslTransform">Loaded <see cref="XslCompiledTransform"/> object</param> /// <param name="multiThread">Defines in which mode (multithreaded or singlethreaded) /// this instance of XslReader will operate</param> - /// <param name="initialBufferSize">Initial buffer size</param> + /// <param name="initialBufferSize">Initial buffer size (number of nodes, not bytes)</param> public XslReader(XslCompiledTransform xslTransform, bool multiThread, int initialBufferSize) { this.xslCompiledTransform = xslTransform; this.multiThread = multiThread; |
From: Oleg T. <he...@us...> - 2005-11-14 16:57:38
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5218/v2/src/Xsl Modified Files: XslReader.cs Log Message: Index: XslReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/XslReader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XslReader.cs 13 Nov 2005 22:10:31 -0000 1.4 +++ XslReader.cs 14 Nov 2005 16:57:30 -0000 1.5 @@ -18,18 +18,54 @@ /// architectural and performance reasons the <see cref="XslCompiledTransform"/> /// class doesn't support transforming to an <see cref="XmlReader"/> as obsolete /// <see cref="XslTransform"/> class did and XslReader's goal is to - /// supplement such functionality.</para> + /// supplement such functionality.</para> + /// </summary> + /// <remarks> /// <para>XslReader can work in a singlethreaded (fully buffering) or a - /// multithreaded mode. In a singlethreaded mode XslReader runs an XSL transformation + /// multithreaded mode.</para> + /// <para>In a multithreaded mode XslReader runs an XSL transformation + /// in a separate dedicated thread. XSLT output is being recorded into a buffer + /// and once the buffer is full, transformation thread gets suspended. In a main + /// thread XslReader reads recorded XSLT output from a buffer as a client calls + /// XslReader methods. Whenever the buffer is read, the transformation thread + /// is resumed to produce next portion of an XSLT output.<br/> + /// In effect that means that an XSL transformation happens on demand portion by + /// portion as a client calls XslReader methods. In terms of memory footprint + /// that means that at any time at most buffer size of XSLT output is buffered.</para> + /// <para>In a singlethreaded mode XslReader runs an XSL transformation /// to the end and records full XSLT output into a buffer (using effective - /// binary representation). After that it reads the buffer when a client calls XslReader - /// methods. In effect that means that in this mode before first call to the + /// binary representation though). After that it reads the buffer when a client + /// calls XslReader methods. So in this mode before first call to the /// XslReader.Read() method returns, XSL transformation is over and XSLT output - /// is buffered internally as a whole.<br/> - /// In a multithreaded mode XslReader runs XSL transformation in a separate thread, - /// which + /// is buffered internally as a whole. /// </para> - /// </summary> + /// <para>By default XslReader works in a multithreaded mode. You can choose the mode + /// and the buffer size using <c>multiThread</c> and <c>initialBufferSize</c> arguments + /// when instantiating XslReader object.</para> + /// <para>XslReader designed to be reused. Just provide another inoput XML or XSLT + /// stylesheet, start transformation and read the output. If the <c>StartTransform()</c> + /// method is called when previous + /// transformation isn't over yet, it will be aborted, the buffer cleaned and + /// the XslReader object will be reset to an initial state automatically.</para> + /// <para>XslReader is not thread safe, keep separate instances of the XslReader + /// for each thread.</para> + /// </remarks> + /// <example> + /// <para>Here is an example of using XslReader class. First you need to create + /// an <see cref="XslCompiledTransform"/> object and load XSLT stylesheet you want to + /// execute. Then prepare XML input as <see cref="XmlInput"/> object providing + /// XML source in a form of URI, <see cref="Stream"/>, <see cref="TextReader"/>, + /// <see cref="XmlReader"/> or <see cref="IXPathNavigable"/> along with an optional + /// <see cref="XmlResolver"/> object, which will be used to resolve URIs for + /// the XSLT document() function calls.<br/> + /// After that create XslReader instance optionally choosing multithreaded or + /// singlethreaded mode and initial buffer size.<br/> + /// Finally start transformation by calling <c>StartTransform()</c> method and then + /// read transformation output via XslReader's object, which implements + /// <see cref="XmlReader"/> API. + /// + /// </para> + /// </example> public class XslReader : XmlReader { static string NsXml = "http://www.w3.org/XML/1998/namespace"; static string NsXmlNs = "http://www.w3.org/2000/xmlns/"; @@ -54,6 +90,16 @@ XmlInput defaulDocument; XsltArgumentList args; + /// <summary> + /// Creates new XslReader instance with given <see cref="XslCompiledTransform"/>, + /// mode (multithreaded/singlethreaded) and initial buffer size. The buffer will be + /// expanded if necessary to be able to store any element start tag with all its + /// attributes. + /// </summary> + /// <param name="xslTransform">Loaded <see cref="XslCompiledTransform"/> object</param> + /// <param name="multiThread">Defines in which mode (multithreaded or singlethreaded) + /// this instance of XslReader will operate</param> + /// <param name="initialBufferSize">Initial buffer size</param> public XslReader(XslCompiledTransform xslTransform, bool multiThread, int initialBufferSize) { this.xslCompiledTransform = xslTransform; this.multiThread = multiThread; @@ -66,9 +112,27 @@ SetUndefinedState(ReadState.Initial); } + /// <summary> + /// Creates new XslReader instance with given <see cref="XslCompiledTransform"/>, + /// operating in a multithreaded mode and having default initial buffer size. + /// </summary> + /// <param name="xslTransform">Loaded <see cref="XslCompiledTransform"/> object</param> public XslReader(XslCompiledTransform xslTransform) : this(xslTransform, true, defaultBufferSize) { } - public XmlReader Transform(XmlInput input, XsltArgumentList args) { + /// <summary> + /// Starts XSL transformation of given <see cref="XmlInput"/> object with + /// specified <see cref="XsltArgumentList"/>. After this method returns + /// you can read the transformation output out of XslReader object via + /// standard <see cref="XmleRader"/> methods such as Read() or MoveXXX(). + /// </summary> + /// <remarks>If the <c>StartTransform()</c> method is called when previous + /// transformation isn't over yet, it will be aborted, buffer cleaned and + /// XslReader object reset to an initial state automatically.</remarks> + /// <param name="input">An input XML to be transformed</param> + /// <param name="args">A collection of global parameter values and + /// extension objects.</param> + /// <returns></returns> + public XmlReader StartTransform(XmlInput input, XsltArgumentList args) { this.defaulDocument = input; this.args = args; Start(); @@ -142,11 +206,22 @@ } } + /// <summary> + /// Loaded <see cref="XslCompiledTransform"/> object, which is used + /// to run XSL transformations. You can reuse XslReader for running + /// another transformation by replacing <see cref="XslCompiledTransform"/> + /// object. + /// </summary> public XslCompiledTransform XslCompiledTransform { get { return this.xslCompiledTransform; } set { this.xslCompiledTransform = value; } } + /// <summary> + /// Initial buffer size. The buffer will be + /// expanded if necessary to be able to store any element start tag with + /// all its attributes. + /// </summary> public int InitialBufferSize { get { return initialBufferSize; } set { initialBufferSize = value; } @@ -177,7 +252,10 @@ } return true; } - + + /// <summary> + /// See <see cref="XmlReader.Read()"/>. + /// </summary> public override bool Read() { // Leave Current node switch (nodeType) { @@ -262,25 +340,40 @@ return true; } + /// <summary>See <see cref="XmlReader.AttributeCount"/>.</summary> public override int AttributeCount { get { return attCount; } } // issue: What should be BaseURI in XslReader? xslCompiledTransform.BaseURI ? + /// <summary>See <see cref="XmlReader.BaseURI"/>.</summary> public override string BaseURI { get { return string.Empty; } } + /// <summary>See <see cref="XmlReader.NameTable"/>.</summary> public override XmlNameTable NameTable { get { return nameTable; } } + /// <summary>See <see cref="XmlReader.Depth"/>.</summary> public override int Depth { get { return depth; } } + /// <summary>See <see cref="XmlReader.EOF"/>.</summary> public override bool EOF { get { return ReadState == ReadState.EndOfFile; } } + /// <summary>See <see cref="XmlReader.HasValue"/>.</summary> public override bool HasValue { get { return 0 != (/*HasValueBitmap:*/0x2659C & (1 << (int)nodeType)); } } + /// <summary>See <see cref="XmlReader.NodeType"/>.</summary> public override XmlNodeType NodeType { get { return nodeType; } } // issue: We may want return true if element doesn't have content. Iteresting to know what + /// <summary>See <see cref="XmlReader.IsEmptyElement"/>.</summary> public override bool IsEmptyElement { get { return false; } } + /// <summary>See <see cref="XmlReader.LocalName"/>.</summary> public override string LocalName { get { return qname.Local; } } + /// <summary>See <see cref="XmlReader.NamespaceURI"/>.</summary> public override string NamespaceURI { get { return qname.NsUri; } } + /// <summary>See <see cref="XmlReader.Prefix"/>.</summary> public override string Prefix { get { return qname.Prefix; } } + /// <summary>See <see cref="XmlReader.Value"/>.</summary> public override string Value { get { return value; } } + /// <summary>See <see cref="XmlReader.ReadState"/>.</summary> public override ReadState ReadState { get { return readState; } } + /// <summary>See <see cref="XmlReader.Close()"/>.</summary> public override void Close() { SetUndefinedState(ReadState.Closed); } + /// <summary>See <see cref="XmlReader.GetAttribute(int)"/>.</summary> public override string GetAttribute(int i) { if (IsInsideElement()) { if (0 <= i && i < attCount) { @@ -323,6 +416,7 @@ } return 0; } + /// <summary>See <see cref="XmlReader.GetAttribute(string)"/>.</summary> public override string GetAttribute(string name) { int attNum = FindAttribute(name); if (attNum != 0) { @@ -330,6 +424,7 @@ } return null; } + /// <summary>See <see cref="XmlReader.GetAttribute(string, string)"/>.</summary> public override string GetAttribute(string name, string ns) { if (IsInsideElement()) { for (int i = 1; i <= attCount; i++) { @@ -343,7 +438,9 @@ } return null; } + /// <summary>See <see cref="XmlReader.LookupNamespace(string)"/>.</summary> public override string LookupNamespace(string prefix) { return scope.LookupNamespace(prefix); } + /// <summary>See <see cref="XmlReader.Close()"/>.</summary> public override bool MoveToAttribute(string name) { int attNum = FindAttribute(name); if (attNum != 0) { @@ -352,6 +449,7 @@ } return false; } + /// <summary>See <see cref="XmlReader.MoveToAttribute(int)"/>.</summary> public override void MoveToAttribute(int i) { if (IsInsideElement()) { if (0 <= i && i < attCount) { @@ -364,6 +462,7 @@ } throw new ArgumentOutOfRangeException("i"); } + /// <summary>See <see cref="XmlReader.MoveToAttribute(string, string)"/>.</summary> public override bool MoveToAttribute(string name, string ns) { if (IsInsideElement()) { for (int i = 1; i <= attCount; i ++) { @@ -401,6 +500,7 @@ break; } } + /// <summary>See <see cref="XmlReader.MoveToElement()"/>.</summary> public override bool MoveToElement() { if ( nodeType == XmlNodeType.Attribute || @@ -414,11 +514,13 @@ } return false; } + /// <summary>See <see cref="XmlReader.MoveToFirstAttribute()"/>.</summary> public override bool MoveToFirstAttribute() { ChangeDepthToElement(); attOffset = 0; return MoveToNextAttribute(); } + /// <summary>See <see cref="XmlReader.MoveToNextAttribute()"/>.</summary> public override bool MoveToNextAttribute() { if (attOffset < attCount) { ChangeDepthToElement(); @@ -430,6 +532,7 @@ } return false; } + /// <summary>See <see cref="XmlReader.ReadAttributeValue()"/>.</summary> public override bool ReadAttributeValue() { if (nodeType == XmlNodeType.Attribute) { nodeType = XmlNodeType.Text; @@ -438,9 +541,12 @@ } return false; } + /// <summary>See <see cref="XmlReader.ResolveEntity()"/>.</summary> public override void ResolveEntity() { throw new InvalidOperationException(); } + /// <summary>See <see cref="XmlReader.XmlLang"/>.</summary> public override string XmlLang { get { return scope.Lang; } } + /// <summary>See <see cref="XmlReader.XmlSpace"/>.</summary> public override XmlSpace XmlSpace { get { return scope.Space; } } #endregion // XmlReader Implementation |
From: Oleg T. <he...@us...> - 2005-11-13 22:10:38
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31167/v2/src/Xsl Modified Files: XslReader.cs Log Message: Index: XslReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/XslReader.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XslReader.cs 12 Nov 2005 21:28:59 -0000 1.3 +++ XslReader.cs 13 Nov 2005 22:10:31 -0000 1.4 @@ -18,7 +18,17 @@ /// architectural and performance reasons the <see cref="XslCompiledTransform"/> /// class doesn't support transforming to an <see cref="XmlReader"/> as obsolete /// <see cref="XslTransform"/> class did and XslReader's goal is to - /// supplement such functionality.</para> + /// supplement such functionality.</para> + /// <para>XslReader can work in a singlethreaded (fully buffering) or a + /// multithreaded mode. In a singlethreaded mode XslReader runs an XSL transformation + /// to the end and records full XSLT output into a buffer (using effective + /// binary representation). After that it reads the buffer when a client calls XslReader + /// methods. In effect that means that in this mode before first call to the + /// XslReader.Read() method returns, XSL transformation is over and XSLT output + /// is buffered internally as a whole.<br/> + /// In a multithreaded mode XslReader runs XSL transformation in a separate thread, + /// which + /// </para> /// </summary> public class XslReader : XmlReader { static string NsXml = "http://www.w3.org/XML/1998/namespace"; |
From: Oleg T. <he...@us...> - 2005-11-12 21:29:07
|
Update of /cvsroot/mvp-xml/Common/v2/test/XslReaderTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018/v2/test/XslReaderTests Modified Files: XslReaderTests.cs Log Message: Index: XslReaderTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/test/XslReaderTests/XslReaderTests.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XslReaderTests.cs 7 Nov 2005 13:58:19 -0000 1.1 +++ XslReaderTests.cs 12 Nov 2005 21:28:59 -0000 1.2 @@ -170,8 +170,7 @@ } CompareWithStandardReader(true, 0); CompareWithStandardReader(true, 1); - CompareWithStandardReader(true, int.MinValue); - CompareWithStandardReader(true, int.MaxValue); + CompareWithStandardReader(true, int.MinValue); } /// <summary> @@ -200,5 +199,12 @@ xslReader.Transform(new XmlInput(GetReader(Globals.NorthwindResource)), null); CompareReaders(standard, xslReader); } + + [Test] + [ExpectedException(typeof(OverflowException))] + public void Test7() + { + CompareWithStandardReader(true, int.MaxValue / 2 + 2); + } } } |
From: Oleg T. <he...@us...> - 2005-11-12 21:29:06
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018/v2/src/Xsl Modified Files: XslReader.cs Added Files: MvpXslTransform.cs Log Message: --- NEW FILE: MvpXslTransform.cs --- using System; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; namespace Mvp.Xml.Common.Xsl { public class MvpXslTransform { XslCompiledTransform compiledTransform; public MvpXslTransform(XslCompiledTransform transform) { if (transform == null) throw new ArgumentNullException("transform"); this.compiledTransform = transform; } #if false // do we want support old transform here as well? XslTransform oldTransform; public MvpXslTransform(XslTransform transform) { if (transform == null) throw new ArgumentNullException("transform"); this.oldTransform = transform; } #endif public virtual void Transform(XmlInput defaulDocument, XsltArgumentList args, XmlOutput output) { XmlWriter xmlWriter = output.destination as XmlWriter; bool closeWriter = false; if (xmlWriter != null) { closeWriter = true; while (true) { TextWriter txtWriter = output.destination as TextWriter; if (txtWriter != null) { xmlWriter = XmlWriter.Create(txtWriter, this.compiledTransform.OutputSettings); break; } Stream strm = output.destination as Stream; if (strm != null) { xmlWriter = XmlWriter.Create(strm, this.compiledTransform.OutputSettings); break; } String str = output.destination as String; if (str != null) { // BugBug: We should read doc before creating output file in case they are the same xmlWriter = XmlWriter.Create(str, this.compiledTransform.OutputSettings); break; } throw new Exception("Unexpected XmlOutput"); } } try { TransformToWriter(defaulDocument, args, xmlWriter); } finally { if (closeWriter) { xmlWriter.Close(); } } } private static XmlReaderSettings ReaderSettings; static MvpXslTransform() { ReaderSettings = new XmlReaderSettings(); ReaderSettings.ProhibitDtd = true; } private void TransformToWriter(XmlInput defaulDocument, XsltArgumentList args, XmlWriter xmlWriter) { XmlReader xmlReader = defaulDocument.source as XmlReader; if (xmlReader != null) { compiledTransform.Transform(xmlReader, args, xmlWriter, defaulDocument.resolver); return; } string str = defaulDocument.source as string; if (str != null) { using (XmlReader reader = XmlReader.Create(str, ReaderSettings)) { compiledTransform.Transform(reader, args, xmlWriter, defaulDocument.resolver); } return; } Stream strm = defaulDocument.source as Stream; if (strm != null) { using (XmlReader reader = XmlReader.Create(strm, ReaderSettings)) { compiledTransform.Transform(reader, args, xmlWriter, defaulDocument.resolver); } return; } TextReader txtReader = defaulDocument.source as TextReader; if (txtReader != null) { using (XmlReader reader = XmlReader.Create(txtReader, ReaderSettings)) { compiledTransform.Transform(reader, args, xmlWriter, defaulDocument.resolver); } return; } IXPathNavigable nav = defaulDocument.source as IXPathNavigable; if (nav != null) { if (defaulDocument.resolver is XmlUrlResolver) { compiledTransform.Transform(nav, args, xmlWriter); } else { // ToDo: It s just API limitation. We can implement it though reflection. // Limitatio of this approach is that part of MvpXslransform will work only in FullTrust scenarious. throw new NotImplementedException("IXPathNavigable + XmlResolver is not suported by XslCompiledTransform."); } return; } throw new Exception("Unexpected XmlInput"); } XmlWriterSettings DefaultWriterSettings { get { if (this.compiledTransform != null) { return this.compiledTransform.OutputSettings; } else { return new XmlWriterSettings(); } } } } } Index: XslReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/XslReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XslReader.cs 12 Nov 2005 15:44:06 -0000 1.2 +++ XslReader.cs 12 Nov 2005 21:28:59 -0000 1.3 @@ -1,3 +1,4 @@ +#region using using System; using System.Collections.Generic; using System.Text; @@ -6,10 +7,20 @@ using System.Xml.Xsl; using System.Xml.XPath; using System.Diagnostics; -using System.Threading; +using System.Threading; +#endregion namespace Mvp.Xml.Common.Xsl { - class XslReader : XmlReader { + + /// <summary> + /// <para>XslReader provides an efficient way to read results of an XSL + /// transformation via an <see cref="XmlReader"/> API. Due to + /// architectural and performance reasons the <see cref="XslCompiledTransform"/> + /// class doesn't support transforming to an <see cref="XmlReader"/> as obsolete + /// <see cref="XslTransform"/> class did and XslReader's goal is to + /// supplement such functionality.</para> + /// </summary> + public class XslReader : XmlReader { static string NsXml = "http://www.w3.org/XML/1998/namespace"; static string NsXmlNs = "http://www.w3.org/2000/xmlns/"; static int defaultBufferSize = 256; @@ -67,14 +78,14 @@ this.depth = 0; SetUndefinedState(ReadState.Initial); if (multiThread) { - this.thread = new Thread(new ThreadStart(this.StrartTransform)); + this.thread = new Thread(new ThreadStart(this.StartTransform)); this.thread.Start(); } else { - StrartTransform(); + StartTransform(); } } - private void StrartTransform() { + private void StartTransform() { try { while (true) { XmlReader xmlReader = defaulDocument.source as XmlReader; |
From: Oleg T. <he...@us...> - 2005-11-12 21:29:06
|
Update of /cvsroot/mvp-xml/Common/v2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17018/v2/src Modified Files: Common.csproj changelog.txt Log Message: Index: changelog.txt =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/changelog.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- changelog.txt 24 Oct 2005 12:08:27 -0000 1.2 +++ changelog.txt 12 Nov 2005 21:28:59 -0000 1.3 @@ -1,3 +1,9 @@ +November 12, 2005 + +Added XslReader (olegt) + +--------------------------------------------------------- + October 24, 2005 Converted to .NET 2.0 (olegt) Index: Common.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Common.csproj,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Common.csproj 7 Nov 2005 13:58:18 -0000 1.9 +++ Common.csproj 12 Nov 2005 21:28:59 -0000 1.10 @@ -146,6 +146,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="Xsl\IXmlTransform.cs" /> + <Compile Include="Xsl\MvpXslTransform.cs" /> <Compile Include="Xsl\XslReader.cs" /> <Content Include="changelog.txt" /> <EmbeddedResource Include="Serialization\PerfCounterInstaller.resx"> |
From: Oleg T. <he...@us...> - 2005-11-12 15:44:13
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2184/v2/src/Xsl Modified Files: XslReader.cs Log Message: Index: XslReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Xsl/XslReader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XslReader.cs 7 Nov 2005 13:58:19 -0000 1.1 +++ XslReader.cs 12 Nov 2005 15:44:06 -0000 1.2 @@ -1,4 +1,3 @@ -#region using using System; using System.Collections.Generic; using System.Text; @@ -7,13 +6,13 @@ using System.Xml.Xsl; using System.Xml.XPath; using System.Diagnostics; -using System.Threading; -#endregion +using System.Threading; namespace Mvp.Xml.Common.Xsl { - public class XslReader : XmlReader { - static string NsXml = "http://www.w3.org/XML/1998/namespace"; - static int defaultBufferSize = 256; + class XslReader : XmlReader { + static string NsXml = "http://www.w3.org/XML/1998/namespace"; + static string NsXmlNs = "http://www.w3.org/2000/xmlns/"; + static int defaultBufferSize = 256; XmlNameTable nameTable; TokenPipe pipe; BufferWriter writer; @@ -217,11 +216,10 @@ if (attType != XmlNodeType.Attribute) { break; // We are done with attributes for this element } - if (attName == writer.QNameXmlLang) { - scope.AddLang(attText); - } else if (attName == writer.QNameXmlSpace) { - scope.AddSpace(attText); - } + if (RefEquals(attName.Prefix, "xmlns") ) { scope.AddNamespace(attName.Local , attText); } + else if (RefEquals(attName, writer.QNameXmlNs )) { scope.AddNamespace(attName.Prefix, attText); } // prefix is atomized empty string + else if (RefEquals(attName, writer.QNameXmlLang )) { scope.AddLang(attText); } + else if (RefEquals(attName, writer.QNameXmlSpace)) { scope.AddSpace(attText); } } scope.PushScope(qname); break; @@ -426,6 +424,22 @@ #endregion // XmlReader Implementation #region ------------------------------- Supporting classes ------------------------------ + private static bool RefEquals(string strA, string strB) { + Debug.Assert( + ((object)strA == (object)strB) || !String.Equals(strA, strB), + "String atomization Failure: '" + strA + "'" + ); + return (object)strA == (object)strB; + } + + private static bool RefEquals(QName qnA, QName qnB) { + Debug.Assert( + ((object)qnA == (object)qnB) || qnA.Local != qnB.Local || qnA.NsUri != qnB.NsUri || qnA.Prefix != qnB.Prefix, + "QName atomization Failure: '" + qnA.ToString() + "'" + ); + return (object)qnA == (object)qnB; + } + // QName is imutable. private class QName { string local; @@ -476,15 +490,16 @@ public QName QNameXmlSpace; public QName QNameXmlLang; public QName QNameEmpty; - + public QName QNameXmlNs; public BufferWriter(TokenPipe pipe, XmlNameTable nameTable) { this.pipe = pipe; this.qnameTable = new QNameTable(nameTable); this.sbuilder = new StringBuilder(); - QNameXmlSpace = qnameTable.GetQName("space", NsXml, "xml"); - QNameXmlLang = qnameTable.GetQName("lang" , NsXml, "xml"); - QNameEmpty = qnameTable.GetQName("", "", ""); + QNameXmlSpace = qnameTable.GetQName("space", NsXml , "xml" ); // xml:space + QNameXmlLang = qnameTable.GetQName("lang" , NsXml , "xml" ); // xml:lang + QNameXmlNs = qnameTable.GetQName("xmlns", NsXmlNs, "" ); // xmlsn="" + QNameEmpty = qnameTable.GetQName("" , "" , "" ); } public void Reset() { @@ -620,13 +635,6 @@ return s; } } - public static bool RefEquals(string strA, string strB) { - Debug.Assert( - ((object) strA == (object) strB) || ! String.Equals(strA, strB), - "Atomization Failure: '" + strA + "'" - ); - return (object) strA == (object) strB; - } } } @@ -676,9 +684,9 @@ if (record.Local != null) { break; // this record is Element QName } - if ((object) record.Prefix == (object) atomLang) { + if (RefEquals(record.Prefix, atomLang)) { currentLang = record.NsUri; - } else if ((object) record.Prefix == (object) atomSpace) { + } else if (RefEquals(record.Prefix, atomSpace)) { currentSpace = Str2Space(record.NsUri); } } while (true); @@ -696,11 +704,12 @@ public void AddNamespace(string prefix, string uri) { Debug.Assert(prefix != null); Debug.Assert(uri != null); - prefix = nameTable.Add(prefix); + Debug.Assert(prefix == nameTable.Add(prefix), "prefixes are expected to be already atomized in this NameTable"); uri = nameTable.Add(uri ); Debug.Assert( - (object)prefix != (object)atomLang && - (object)prefix != (object)atomSpace, + ! RefEquals(prefix, atomLang ) && + ! RefEquals(prefix, atomSpace) + , "This assumption is important to distinct NsDecl from xml:space and xml:lang" ); AddRecord(new QName(null, uri, prefix)); @@ -709,7 +718,7 @@ public void AddLang(string lang) { Debug.Assert(lang != null); lang = nameTable.Add(lang); - if ((object) lang == (object) currentLang) { + if (RefEquals(lang, currentLang)) { return; } AddRecord(new QName(null, currentLang, atomLang)); @@ -748,7 +757,7 @@ prefix = nameTable.Get(prefix); for (int i = lastRecord - 2; 0 <= i; i -- ) { QName record = records[i]; - if (record.Local == null && (object)record.Prefix == (object)prefix) { + if (record.Local == null && RefEquals(record.Prefix, prefix)) { return record.NsUri; } } |
From: Oleg T. <he...@us...> - 2005-11-12 15:44:13
|
Update of /cvsroot/mvp-xml/Common/v2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2184/v2 Modified Files: Common.sln Removed Files: license.txt Log Message: --- license.txt DELETED --- Index: Common.sln =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/Common.sln,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Common.sln 16 Oct 2005 16:52:07 -0000 1.1 +++ Common.sln 12 Nov 2005 15:44:06 -0000 1.2 @@ -6,7 +6,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E8818B26-3C1E-4175-BE5B-8BBF1940F55A}" ProjectSection(SolutionItems) = preProject - license.txt = license.txt + ..\..\Global\license.txt = ..\..\Global\license.txt EndProjectSection EndProject Global |
From: Oleg T. <he...@us...> - 2005-11-08 13:30:09
|
Update of /cvsroot/mvp-xml/WebSite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8501 Modified Files: license.html Log Message: Index: license.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/license.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- license.html 1 Nov 2004 17:19:17 -0000 1.1 +++ license.html 8 Nov 2005 13:29:52 -0000 1.2 @@ -1,240 +1,39 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> - <title>Mvp.Xml project's License</title> + <title>Mvp.Xml Project's License</title> </head> <body> -Common Public License Version 1.0<br> -<br> -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON -PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF -THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.<br> -<br> -1. DEFINITIONS<br> -<br> -"Contribution" means:<br> -<br> -a) in the case of the initial Contributor, the initial code and -documentation distributed under this Agreement, and<br> -<br> -b) in the case of each subsequent Contributor:<br> -<br> -i) changes to the Program, and<br> -<br> -ii) additions to the Program;<br> -<br> -where such changes and/or additions to the Program originate from and -are distributed by that particular Contributor. A Contribution -'originates' from a Contributor if it was added to the Program by such -Contributor itself or anyone acting on such Contributor's behalf. -Contributions do not include additions to the Program which: (i) are -separate modules of software distributed in conjunction with the -Program under their own license agreement, and (ii) are not derivative -works of the Program.<br> -<br> -"Contributor" means any person or entity that distributes the Program.<br> -<br> -"Licensed Patents " mean patent claims licensable by a Contributor -which are necessarily infringed by the use or sale of its Contribution -alone or when combined with the Program.<br> -<br> -"Program" means the Contributions distributed in accordance with this -Agreement.<br> -<br> -"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors.<br> -<br> -2. GRANT OF RIGHTS<br> -<br> -a) Subject to the terms of this Agreement, each Contributor hereby -grants Recipient a non-exclusive, worldwide, royalty-free copyright -license to reproduce, prepare derivative works of, publicly display, -publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and -object code form.<br> -<br> -b) Subject to the terms of this Agreement, each Contributor hereby -grants Recipient a non-exclusive, worldwide, royalty-free patent -license under Licensed Patents to make, use, sell, offer to sell, -import and otherwise transfer the Contribution of such Contributor, if -any, in source code and object code form. This patent license shall -apply to the combination of the Contribution and the Program if, at the -time the Contribution is added by the Contributor, such addition of the -Contribution causes such combination to be covered by the Licensed -Patents. The patent license shall not apply to any other combinations -which include the Contribution. No hardware per se is licensed -hereunder.<br> -<br> -c) Recipient understands that although each Contributor grants the -licenses to its Contributions set forth herein, no assurances are -provided by any Contributor that the Program does not infringe the -patent or other intellectual property rights of any other entity. Each -Contributor disclaims any liability to Recipient for claims brought by -any other entity based on infringement of intellectual property rights -or otherwise. As a condition to exercising the rights and licenses -granted hereunder, each Recipient hereby assumes sole responsibility to -secure any other intellectual property rights needed, if any. For -example, if a third party patent license is required to allow Recipient -to distribute the Program, it is Recipient's responsibility to acquire -that license before distributing the Program.<br> -<br> -d) Each Contributor represents that to its knowledge it has sufficient -copyright rights in its Contribution, if any, to grant the copyright -license set forth in this Agreement.<br> -<br> -3. REQUIREMENTS<br> -<br> -A Contributor may choose to distribute the Program in object code form -under its own license agreement, provided that:<br> -<br> -a) it complies with the terms and conditions of this Agreement; and<br> -<br> -b) its license agreement:<br> -<br> -i) effectively disclaims on behalf of all Contributors all warranties -and conditions, express and implied, including warranties or conditions -of title and non-infringement, and implied warranties or conditions of -merchantability and fitness for a particular purpose;<br> -<br> -ii) effectively excludes on behalf of all Contributors all liability -for damages, including direct, indirect, special, incidental and -consequential damages, such as lost profits;<br> -<br> -iii) states that any provisions which differ from this Agreement are -offered by that Contributor alone and not by any other party; and<br> -<br> -iv) states that source code for the Program is available from such -Contributor, and informs licensees how to obtain it in a reasonable -manner on or through a medium customarily used for software exchange. <br> -<br> -When the Program is made available in source code form:<br> -<br> -a) it must be made available under this Agreement; and<br> -<br> -b) a copy of this Agreement must be included with each copy of the -Program. <br> -<br> -Contributors may not remove or alter any copyright notices contained -within the Program.<br> -<br> -Each Contributor must identify itself as the originator of its -Contribution, if any, in a manner that reasonably allows subsequent -Recipients to identify the originator of the Contribution.<br> -<br> -4. COMMERCIAL DISTRIBUTION<br> -<br> -Commercial distributors of software may accept certain responsibilities -with respect to end users, business partners and the like. While this -license is intended to facilitate the commercial use of the Program, -the Contributor who includes the Program in a commercial product -offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes -the Program in a commercial product offering, such Contributor -("Commercial Contributor") hereby agrees to defend and indemnify every -other Contributor ("Indemnified Contributor") against any losses, -damages and costs (collectively "Losses") arising from claims, lawsuits -and other legal actions brought by a third party against the -Indemnified Contributor to the extent caused by the acts or omissions -of such Commercial Contributor in connection with its distribution of -the Program in a commercial product offering. The obligations in this -section do not apply to any claims or Losses relating to any actual or -alleged intellectual property infringement. In order to qualify, an -Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial -Contributor to control, and cooperate with the Commercial Contributor -in, the defense and any related settlement negotiations. The -Indemnified Contributor may participate in any such claim at its own -expense.<br> -<br> -For example, a Contributor might include the Program in a commercial -product offering, Product X. That Contributor is then a Commercial -Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance -claims and warranties are such Commercial Contributor's responsibility -alone. Under this section, the Commercial Contributor would have to -defend claims against the other Contributors related to those -performance claims and warranties, and if a court requires any other -Contributor to pay any damages as a result, the Commercial Contributor -must pay those damages.<br> -<br> -5. NO WARRANTY<br> -<br> -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS -PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY -WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR -FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible -for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights -under this Agreement, including but not limited to the risks and costs -of program errors, compliance with applicable laws, damage to or loss -of data, programs or equipment, and unavailability or interruption of -operations.<br> -<br> -6. DISCLAIMER OF LIABILITY<br> -<br> -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR -ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING -WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR -DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED -HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.<br> -<br> -7. GENERAL<br> -<br> -If any provision of this Agreement is invalid or unenforceable under -applicable law, it shall not affect the validity or enforceability of -the remainder of the terms of this Agreement, and without further -action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.<br> -<br> -If Recipient institutes patent litigation against a Contributor with -respect to a patent applicable to software (including a cross-claim or -counterclaim in a lawsuit), then any patent licenses granted by that -Contributor to such Recipient under this Agreement shall terminate as -of the date such litigation is filed. In addition, if Recipient -institutes patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or -hardware) infringes such Recipient's patent(s), then such Recipient's -rights granted under Section 2(b) shall terminate as of the date such -litigation is filed.<br> -<br> -All Recipient's rights under this Agreement shall terminate if it fails -to comply with any of the material terms or conditions of this -Agreement and does not cure such failure in a reasonable period of time -after becoming aware of such noncompliance. If all Recipient's rights -under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted -by Recipient relating to the Program shall continue and survive.<br> -<br> -Everyone is permitted to copy and distribute copies of this Agreement, -but in order to avoid inconsistency the Agreement is copyrighted and -may only be modified in the following manner. The Agreement Steward -reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement -Steward has the right to modify this Agreement. IBM is the initial -Agreement Steward. IBM may assign the responsibility to serve as the -Agreement Steward to a suitable separate entity. Each new version of -the Agreement will be given a distinguishing version number. The -Program (including Contributions) may always be distributed subject to -the version of the Agreement under which it was received. In addition, -after a new version of the Agreement is published, Contributor may -elect to distribute the Program (including its Contributions) under the -new version. Except as expressly stated in Sections 2(a) and 2(b) -above, Recipient receives no rights or licenses to the intellectual -property of any Contributor under this Agreement, whether expressly, by -implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.<br> -<br> -This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to -this Agreement will bring a legal action under this Agreement more than -one year after the cause of action arose. Each party waives its rights -to a jury trial in any resulting litigation.<br> -<br> +<pre> +Copyright (c) 2005, XMLMVP Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. +* Neither the name of the XMLMVP Project nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +</pre> </body> </html> |
From: Oleg T. <he...@us...> - 2005-11-08 13:27:32
|
Update of /cvsroot/mvp-xml/Global In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7939 Modified Files: license.txt Log Message: Index: license.txt =================================================================== RCS file: /cvsroot/mvp-xml/Global/license.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- license.txt 29 Sep 2004 11:48:16 -0000 1.1 +++ license.txt 8 Nov 2005 13:27:19 -0000 1.2 @@ -1,87 +1,29 @@ -Common Public License Version 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and - - b) in the case of each subsequent Contributor: - - i) changes to the Program, and - - ii) additions to the Program; - - where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. - - b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. - - c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. - - d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: - - a) it complies with the terms and conditions of this Agreement; and - - b) its license agreement: - - i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; - - ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; - - iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and - - iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. - -When the Program is made available in source code form: - - a) it must be made available under this Agreement; and - - b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the Program. - -Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. - -If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. +Copyright (c) 2005, XMLMVP Project +All rights reserved. -All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: -Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. +* Neither the name of the XMLMVP Project nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. -This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. |
From: Oleg T. <he...@us...> - 2005-11-08 13:27:03
|
Update of /cvsroot/mvp-xml/Common/v1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7798/v1 Removed Files: license.txt Log Message: --- license.txt DELETED --- |
From: Oleg T. <he...@us...> - 2005-11-07 16:17:27
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/tests/EXSLT/DatesAndTimes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18680/v2/test/ExsltTest/tests/EXSLT/DatesAndTimes Modified Files: format-date.xslt source.xml Log Message: Index: format-date.xslt =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/tests/EXSLT/DatesAndTimes/format-date.xslt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- format-date.xslt 16 Oct 2005 20:13:09 -0000 1.1 +++ format-date.xslt 7 Nov 2005 16:17:13 -0000 1.2 @@ -34,6 +34,9 @@ <test10> <xsl:value-of select="date:format-date(date, '')"/> </test10> + <test11> + <xsl:value-of select="date:format-date(date4, 'EEE, d MMM yyyy HH:mm:ss.SSSSSSS Z')" /> + </test11> </out> </xsl:template> </xsl:stylesheet> Index: source.xml =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/tests/EXSLT/DatesAndTimes/source.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- source.xml 16 Oct 2005 20:13:09 -0000 1.1 +++ source.xml 7 Nov 2005 16:17:13 -0000 1.2 @@ -4,6 +4,7 @@ <date>2001-07-04T12:08:56+02:00</date> <date2>2001-09-12T07:59:02+02:00</date2> <date3>2001-09-12T07:59:02</date3> + <date4> 2005-08-06T05:05:27.9759775-07:00</date4> <time>07:59:02+02:00</time> <time2>07:59:02</time2> <bad-date>2001/07/04</bad-date> |
From: Oleg T. <he...@us...> - 2005-11-07 16:17:24
|
Update of /cvsroot/mvp-xml/EXSLT/v2/src/Exslt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18680/v2/src/Exslt Modified Files: ExsltDatesAndTimes.cs Log Message: Index: ExsltDatesAndTimes.cs =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/ExsltDatesAndTimes.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ExsltDatesAndTimes.cs 30 Oct 2005 13:50:54 -0000 1.3 +++ ExsltDatesAndTimes.cs 7 Nov 2005 16:17:13 -0000 1.4 @@ -299,7 +299,29 @@ { return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", - "yyyy-MM-dd\"T\"HH:mm:ss"}; + "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f" +}; } } @@ -326,6 +348,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "yyyy-MM-ddzzz", "yyyy-MM-ddZ", "yyyy-MM-dd"}; @@ -353,6 +396,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "HH:mm:sszzz", "HH:mm:ssZ", "HH:mm:ss"}; @@ -381,6 +445,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "yyyy-MM-dd", "yyyy-MM"}; } @@ -408,6 +493,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "yyyy-MM-dd", "yyyy-MM", "yyyy"}; @@ -436,6 +542,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "yyyy-MM-dd", "yyyy-MM", "--MM--"}; @@ -464,6 +591,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "yyyy-MM-dd", "---dd", "--MM-dd"}; @@ -492,6 +640,27 @@ return new string[] {"yyyy-MM-dd\"T\"HH:mm:sszzz", "yyyy-MM-dd\"T\"HH:mm:ssZ", "yyyy-MM-dd\"T\"HH:mm:ss", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fffff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ffff", + "yyyy-MM-dd\"T\"HH:mm:ss.fffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.fff", + "yyyy-MM-dd\"T\"HH:mm:ss.ffzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.ffZ", + "yyyy-MM-dd\"T\"HH:mm:ss.ff", + "yyyy-MM-dd\"T\"HH:mm:ss.fzzz", + "yyyy-MM-dd\"T\"HH:mm:ss.fZ", + "yyyy-MM-dd\"T\"HH:mm:ss.f", "yyyy-MM-dd", "--MM-dd"}; } @@ -1552,10 +1721,10 @@ for (int i=0; i < format.Length;) { int s = i; - switch(format.Substring(i, 1)) + switch(format[i]) { - case "G":// era designator (Text) AD - while (i < format.Length && format.Substring(i, 1)=="G"){i++;} + case 'G':// era designator (Text) AD + while (i < format.Length && format[i]=='G'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || @@ -1573,8 +1742,8 @@ } break; - case "y":// year (Number) 1996 - while (i < format.Length && format.Substring(i, 1)=="y"){i++;} + case 'y':// year (Number) 1996 + while (i < format.Length && format[i]=='y'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1591,8 +1760,8 @@ } } break; - case "M":// month in year (Text & Number) July & 07 - while (i < format.Length && format.Substring(i, 1)=="M"){i++;} + case 'M':// month in year (Text & Number) July & 07 + while (i < format.Length && format[i]=='M'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || @@ -1609,8 +1778,8 @@ retString.Append(monthName(oDate.d.Month)); } break; - case "d":// day in month (Number) 10 - while (i < format.Length && format.Substring(i, 1)=="d"){i++;} + case 'd':// day in month (Number) 10 + while (i < format.Length && format[i]=='d'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || @@ -1622,8 +1791,8 @@ retString.Append(oDate.d.Day.ToString().PadLeft(i-s, '0')); } break; - case "h":// hour in am/pm (1~12) (Number) 12 - while (i < format.Length && format.Substring(i, 1)=="h"){i++;} + case 'h':// hour in am/pm (1~12) (Number) 12 + while (i < format.Length && format[i]=='h'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1636,8 +1805,8 @@ retString.Append(hour.ToString().PadLeft(i-s, '0')); } break; - case "H":// hour in day (0~23) (Number) 0 - while (i < format.Length && format.Substring(i, 1)=="H"){i++;} + case 'H':// hour in day (0~23) (Number) 0 + while (i < format.Length && format[i]=='H'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1647,8 +1816,8 @@ retString.Append(oDate.d.Hour.ToString().PadLeft(i-s, '0')); } break; - case "m":// minute in hour (Number) 30 - while (i < format.Length && format.Substring(i, 1)=="m"){i++;} + case 'm':// minute in hour (Number) 30 + while (i < format.Length && format[i]=='m'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1658,8 +1827,8 @@ retString.Append(oDate.d.Minute.ToString().PadLeft(i-s, '0')); } break; - case "s":// second in minute (Number) 55 - while (i < format.Length && format.Substring(i, 1)=="s"){i++;} + case 's':// second in minute (Number) 55 + while (i < format.Length && format[i]=='s'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1669,12 +1838,19 @@ retString.Append(oDate.d.Second.ToString().PadLeft(i-s, '0')); } break; - case "S":// millisecond (Number) 978 - while (i < format.Length && format.Substring(i, 1)=="S"){i++;} - // Millisecond not supported as input, so why support as output? + case 'S':// millisecond (Number) 978 + while (i < format.Length && format[i]=='S'){i++;} + if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || + Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || + Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || + Object.ReferenceEquals(oDate.GetType(), typeof(TimeTZ)) || + Object.ReferenceEquals(oDate.GetType(), typeof(YearTZ))) + { + retString.Append(oDate.d.Millisecond.ToString().PadLeft(i-s, '0')); + } break; - case "E":// day in week (Text) Tuesday - while (i < format.Length && format.Substring(i, 1)=="E"){i++;} + case 'E':// day in week (Text) Tuesday + while (i < format.Length && format[i]=='E'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || @@ -1691,8 +1867,8 @@ } } break; - case "D":// day in year (Number) 189 - while (i < format.Length && format.Substring(i, 1)=="D"){i++;} + case 'D':// day in year (Number) 189 + while (i < format.Length && format[i]=='D'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1701,8 +1877,8 @@ retString.Append(oDate.d.DayOfYear.ToString().PadLeft(i-s, '0')); } break; - case "F":// day of week in month (Number) 2 (2nd Wed in July) - while (i < format.Length && format.Substring(i, 1)=="F"){i++;} + case 'F':// day of week in month (Number) 2 (2nd Wed in July) + while (i < format.Length && format[i]=='F'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1713,8 +1889,8 @@ retString.Append(dayOfWeekInMonth(oDate.d.Day).ToString().PadLeft(i-s, '0')); } break; - case "w":// week in year (Number) 27 - while (i < format.Length && format.Substring(i, 1)=="w"){i++;} + case 'w':// week in year (Number) 27 + while (i < format.Length && format[i]=='w'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1723,8 +1899,8 @@ retString.Append(weekInYear(oDate.d)); } break; - case "W":// week in month (Number) 2 - while (i < format.Length && format.Substring(i, 1)=="W"){i++;} + case 'W':// week in month (Number) 2 + while (i < format.Length && format[i]=='W'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1733,8 +1909,8 @@ retString.Append(weekInMonth(oDate.d)); } break; - case "a":// am/pm marker (Text) PM - while (i < format.Length && format.Substring(i, 1)=="a"){i++;} + case 'a':// am/pm marker (Text) PM + while (i < format.Length && format[i]=='a'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1747,8 +1923,8 @@ retString.Append("PM"); } break; - case "k":// hour in day (1~24) (Number) 24 - while (i < format.Length && format.Substring(i, 1)=="k"){i++;} + case 'k':// hour in day (1~24) (Number) 24 + while (i < format.Length && format[i]=='k'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1759,8 +1935,8 @@ retString.Append(hour.ToString().PadLeft(i-s, '0')); } break; - case "K":// hour in am/pm (0~11) (Number) 0 - while (i < format.Length && format.Substring(i, 1)=="K"){i++;} + case 'K':// hour in am/pm (0~11) (Number) 0 + while (i < format.Length && format[i]=='K'){i++;} if (Object.ReferenceEquals(oDate.GetType(), typeof(DateTimeTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(oDate.GetType(), typeof(YearMonth)) || @@ -1771,34 +1947,34 @@ retString.Append(hour.ToString().PadLeft(i-s, '0')); } break; - case "z":// time zone (Text) Pacific Standard Time - while (i < format.Length && format.Substring(i, 1)=="z"){i++;} + case 'z':// time zone (Text) Pacific Standard Time + while (i < format.Length && format[i]=='z'){i++;} // // BUGBUG: Need to convert to full timezone names or timezone abbrevs // if they are available. Now cheating by using GMT offsets. retString.Append(oDate.GetGMTOffsetTimeZone()); break; - case "Z":// rfc 822 time zone - while (i < format.Length && format.Substring(i, 1)=="Z"){i++;} + case 'Z':// rfc 822 time zone + while (i < format.Length && format[i]=='Z'){i++;} retString.Append(oDate.Get822TimeZone()); break; - case "'":// escape for text (Delimiter) - if (i < format.Length && format.Substring(i+1, 1) == "'") + case '\'':// escape for text (Delimiter) + if (i < format.Length && format[i+1] == '\'') { i++; - while (i < format.Length && format.Substring(i, 1)=="'"){i++;} + while (i < format.Length && format[i]=='\''){i++;} retString.Append("'"); } else { i++; - while (i < format.Length && format.Substring(i, 1)!="'" && i <= format.Length){retString.Append(format.Substring(i++, 1));} + while (i < format.Length && format[i]!='\'' && i <= format.Length){retString.Append(format.Substring(i++, 1));} if (i >= format.Length)return ""; i++; } break; default: - retString.Append(format.Substring(i, 1)); + retString.Append(format[i]); i++; break; } @@ -1935,7 +2111,7 @@ else { // Simulate casting to the most truncated format. i.e. if one - // arg is DateTZ and the other is DateTimeTZ, get rid of the time + // Arg is DateTZ and the other is DateTimeTZ, get rid of the time // for both. if (Object.ReferenceEquals(startdate.GetType(), typeof(DateTZ)) || Object.ReferenceEquals(enddate.GetType(), typeof(DateTZ))) |
From: Oleg T. <he...@us...> - 2005-11-07 16:17:24
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results/EXSLT/DatesAndTimes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18680/v2/test/ExsltTest/results/EXSLT/DatesAndTimes Modified Files: format-date.xml Log Message: Index: format-date.xml =================================================================== RCS file: /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results/EXSLT/DatesAndTimes/format-date.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- format-date.xml 16 Oct 2005 20:13:08 -0000 1.1 +++ format-date.xml 7 Nov 2005 16:17:13 -0000 1.2 @@ -9,4 +9,5 @@ <test8>010704120856+0200</test8> <test9></test9> <test10></test10> + <test11>Sat, 6 Aug 2005 05:05:27.0000975 -0700</test11> </out> \ No newline at end of file |
From: Oleg T. <he...@us...> - 2005-11-07 13:58:40
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16810/v2/src/Xsl Added Files: IXmlTransform.cs XslReader.cs Log Message: --- NEW FILE: IXmlTransform.cs --- #region using using System; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; #endregion namespace Mvp.Xml.Common.Xsl { public interface IXmlTransform { void Transform(XmlInput defaulDocument, XsltArgumentList args, XmlOutput output); XmlWriterSettings DefaultWriterSettings { get; } } public class XmlInput { internal object source ; internal XmlResolver resolver; public XmlInput(XmlReader reader, XmlResolver resolver) { this.source = reader; this.resolver = resolver; } public XmlInput(TextReader reader, XmlResolver resolver) { this.source = reader; this.resolver = resolver; } public XmlInput(Stream stream, XmlResolver resolver) { this.source = stream; this.resolver = resolver; } public XmlInput(String uri , XmlResolver resolver) { this.source = uri ; this.resolver = resolver; } public XmlInput(XmlReader reader) : this(reader, new XmlUrlResolver()) {} public XmlInput(TextReader reader) : this(reader, new XmlUrlResolver()) {} public XmlInput(Stream stream) : this(stream, new XmlUrlResolver()) {} public XmlInput(String uri ) : this(uri , new XmlUrlResolver()) {} public XmlInput(IXPathNavigable nav ) { this.source = nav ; } // We can add set of implicit constructors. // I am not shre that this will be for good, so I commented them for now. //public static implicit operator XmlInput(XmlReader reader) { return new XmlInput(reader); } //public static implicit operator XmlInput(TextReader reader) { return new XmlInput(reader); } //public static implicit operator XmlInput(Stream stream) { return new XmlInput(stream); } //public static implicit operator XmlInput(String uri ) { return new XmlInput(uri ); } //public static implicit operator XmlInput(XPathNavigator nav ) { return new XmlInput(nav ); } // the trick doesn't work with interfaces } public class XmlOutput { internal object destination; public XmlOutput(XmlWriter writer) { this.destination = writer; } public XmlOutput(TextWriter writer) { this.destination = writer; } public XmlOutput(Stream strm ) { this.destination = strm ; } public XmlOutput(String uri ) { this.destination = uri ; } // We will add overrides with XmlOutputResolver here later to support multiple output documents (<xsl:result-document>) } } --- NEW FILE: XslReader.cs --- #region using using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; using System.Diagnostics; using System.Threading; #endregion namespace Mvp.Xml.Common.Xsl { public class XslReader : XmlReader { static string NsXml = "http://www.w3.org/XML/1998/namespace"; static int defaultBufferSize = 256; XmlNameTable nameTable; TokenPipe pipe; BufferWriter writer; ScopeManager scope; Thread thread; XslCompiledTransform xslCompiledTransform; bool multiThread = false; int initialBufferSize; private static XmlReaderSettings ReaderSettings; static XslReader() { ReaderSettings = new XmlReaderSettings(); ReaderSettings.ProhibitDtd = true; } // Transform Parameters XmlInput defaulDocument; XsltArgumentList args; public XslReader(XslCompiledTransform xslTransform, bool multiThread, int initialBufferSize) { this.xslCompiledTransform = xslTransform; this.multiThread = multiThread; this.initialBufferSize = initialBufferSize; nameTable = new NameTable(); pipe = this.multiThread ? new TokenPipeMultiThread(initialBufferSize) : new TokenPipe(initialBufferSize); writer = new BufferWriter(pipe, nameTable); scope = new ScopeManager(nameTable); SetUndefinedState(ReadState.Initial); } public XslReader(XslCompiledTransform xslTransform) : this(xslTransform, true, defaultBufferSize) { } public XmlReader Transform(XmlInput input, XsltArgumentList args) { this.defaulDocument = input; this.args = args; Start(); return this; } private void Start() { if (thread != null && thread.IsAlive) { // We can also reuse this thread or use ThreadPool. For simplicity we create new thread each time. // Some problem with TreadPool will be the need to notify transformation thread when user calls new Start() befor previous transformation completed thread.Abort(); thread.Join(); } this.writer.Reset(); this.scope.Reset(); this.pipe.Reset(); this.depth = 0; SetUndefinedState(ReadState.Initial); if (multiThread) { this.thread = new Thread(new ThreadStart(this.StrartTransform)); this.thread.Start(); } else { StrartTransform(); } } private void StrartTransform() { try { while (true) { XmlReader xmlReader = defaulDocument.source as XmlReader; if (xmlReader != null) { xslCompiledTransform.Transform(xmlReader, args, writer, defaulDocument.resolver); break; } IXPathNavigable nav = defaulDocument.source as IXPathNavigable; if (nav != null) { xslCompiledTransform.Transform(nav, args, writer); break; } string str = defaulDocument.source as string; if (str != null) { using (XmlReader reader = XmlReader.Create(str, ReaderSettings)) { xslCompiledTransform.Transform(reader, args, writer, defaulDocument.resolver); } break; } Stream strm = defaulDocument.source as Stream; if (strm != null) { using (XmlReader reader = XmlReader.Create(strm, ReaderSettings)) { xslCompiledTransform.Transform(reader, args, writer, defaulDocument.resolver); } break; } TextReader txtReader = defaulDocument.source as TextReader; if (txtReader != null) { using (XmlReader reader = XmlReader.Create(txtReader, ReaderSettings)) { xslCompiledTransform.Transform(reader, args, writer, defaulDocument.resolver); } break; } throw new Exception("Unexpected XmlInput"); } writer.Close(); } catch (Exception e) { if (multiThread) { // we need this exception on main thread. So pass it through pipe. pipe.WriteException(e); } else { throw; } } } public XslCompiledTransform XslCompiledTransform { get { return this.xslCompiledTransform; } set { this.xslCompiledTransform = value; } } public int InitialBufferSize { get { return initialBufferSize; } set { initialBufferSize = value; } } #region XmlReader Implementation int attOffset = 0; // 0 - means reader is positioned on element, when reader potitionrd on the first attribute attOffset == 1 int attCount; int depth; XmlNodeType nodeType = XmlNodeType.None; ReadState readState = ReadState.Initial; QName qname; string value; void SetUndefinedState(ReadState readState) { this.qname = writer.QNameEmpty; this.value = string.Empty; this.nodeType = XmlNodeType.None; this.attCount = 0; this.readState = readState; } bool IsWhitespace(string s) { // Because our xml is presumably valid only and all ws chars <= ' ' foreach (char c in s) { if (' ' < c) { return false; } } return true; } public override bool Read() { // Leave Current node switch (nodeType) { case XmlNodeType.None : if (readState == ReadState.EndOfFile || readState == ReadState.Closed) { return false; } readState = ReadState.Interactive; break; case XmlNodeType.Attribute: attOffset = 0; depth--; goto case XmlNodeType.Element; case XmlNodeType.Element: pipe.FreeTokens(1 + attCount); depth++; break; case XmlNodeType.EndElement : scope.PopScope(); pipe.FreeTokens(1); break; case XmlNodeType.Text : if (attOffset != 0) { // We are on text node inside of the attribute attOffset = 0; depth -= 2; goto case XmlNodeType.Element; } pipe.FreeTokens(1); break; case XmlNodeType.ProcessingInstruction : case XmlNodeType.Comment: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Whitespace: pipe.FreeTokens(1); break; default : throw new InvalidProgramException("Internal Error: unexpected node type"); } Debug.Assert(attOffset == 0); Debug.Assert(readState == ReadState.Interactive); attCount = 0; // Step on next node pipe.Read(out nodeType, out qname, out value); if (nodeType == XmlNodeType.None) { SetUndefinedState(ReadState.EndOfFile); return false; } switch (nodeType) { case XmlNodeType.Element: for (attCount = 0; true; attCount ++) { XmlNodeType attType; QName attName; string attText; pipe.Read(out attType, out attName, out attText); if (attType != XmlNodeType.Attribute) { break; // We are done with attributes for this element } if (attName == writer.QNameXmlLang) { scope.AddLang(attText); } else if (attName == writer.QNameXmlSpace) { scope.AddSpace(attText); } } scope.PushScope(qname); break; case XmlNodeType.EndElement : qname = scope.Name; depth--; break; case XmlNodeType.Comment: case XmlNodeType.ProcessingInstruction : break; case XmlNodeType.Text: if (IsWhitespace(value)) { nodeType = XmlSpace == XmlSpace.Preserve ? XmlNodeType.SignificantWhitespace : XmlNodeType.Whitespace; } break; default : throw new InvalidProgramException("Internal Error: unexpected node type"); } return true; } public override int AttributeCount { get { return attCount; } } // issue: What should be BaseURI in XslReader? xslCompiledTransform.BaseURI ? public override string BaseURI { get { return string.Empty; } } public override XmlNameTable NameTable { get { return nameTable; } } public override int Depth { get { return depth; } } public override bool EOF { get { return ReadState == ReadState.EndOfFile; } } public override bool HasValue { get { return 0 != (/*HasValueBitmap:*/0x2659C & (1 << (int)nodeType)); } } public override XmlNodeType NodeType { get { return nodeType; } } // issue: We may want return true if element doesn't have content. Iteresting to know what public override bool IsEmptyElement { get { return false; } } public override string LocalName { get { return qname.Local; } } public override string NamespaceURI { get { return qname.NsUri; } } public override string Prefix { get { return qname.Prefix; } } public override string Value { get { return value; } } public override ReadState ReadState { get { return readState; } } public override void Close() { SetUndefinedState(ReadState.Closed); } public override string GetAttribute(int i) { if (IsInsideElement()) { if (0 <= i && i < attCount) { QName attName; string attValue; pipe.GetToken(i + 1, out attName, out attValue); return value; } } throw new ArgumentOutOfRangeException("i"); } static char[] qnameSeparator = new char[] { ':' }; private int FindAttribute(string name) { if (IsInsideElement()) { string prefix, local; string[] strings = name.Split(qnameSeparator, StringSplitOptions.None); switch(strings.Length) { case 1: prefix = string.Empty; local = name; break; case 2: if (strings[0].Length == 0) { return 0; // ":local-name" } prefix = strings[0]; local = strings[1]; break; default : return 0; } for (int i = 1; i <= attCount; i++) { QName attName; string attValue; pipe.GetToken(i, out attName, out attValue); if (attName.Local == local && attName.Prefix == prefix) { return i; } } } return 0; } public override string GetAttribute(string name) { int attNum = FindAttribute(name); if (attNum != 0) { return GetAttribute(attNum - 1); } return null; } public override string GetAttribute(string name, string ns) { if (IsInsideElement()) { for (int i = 1; i <= attCount; i++) { QName attName; string attValue; pipe.GetToken(i, out attName, out attValue); if (attName.Local == name && attName.NsUri == ns) { return attValue; } } } return null; } public override string LookupNamespace(string prefix) { return scope.LookupNamespace(prefix); } public override bool MoveToAttribute(string name) { int attNum = FindAttribute(name); if (attNum != 0) { MoveToAttribute(attNum - 1); return true; } return false; } public override void MoveToAttribute(int i) { if (IsInsideElement()) { if (0 <= i && i < attCount) { ChangeDepthToElement(); attOffset = i + 1; depth++; pipe.GetToken(attOffset, out qname, out value); nodeType = XmlNodeType.Attribute; } } throw new ArgumentOutOfRangeException("i"); } public override bool MoveToAttribute(string name, string ns) { if (IsInsideElement()) { for (int i = 1; i <= attCount; i ++) { QName attName; string attValue; pipe.GetToken(i , out attName, out attValue); if (attName.Local == name && attName.NsUri == ns) { ChangeDepthToElement(); nodeType = XmlNodeType.Attribute; attOffset = i; qname = attName; depth++; value = attValue; } } } return false; } private bool IsInsideElement() { return ( nodeType == XmlNodeType.Element || nodeType == XmlNodeType.Attribute || nodeType == XmlNodeType.Text && attOffset != 0 ); } private void ChangeDepthToElement() { switch (nodeType) { case XmlNodeType.Attribute : depth--; break; case XmlNodeType.Text : if (attOffset != 0) { depth -= 2; } break; } } public override bool MoveToElement() { if ( nodeType == XmlNodeType.Attribute || nodeType == XmlNodeType.Text && attOffset != 0 ) { ChangeDepthToElement(); nodeType = XmlNodeType.Element; attOffset = 0; pipe.GetToken(0, out qname, out value); return true; } return false; } public override bool MoveToFirstAttribute() { ChangeDepthToElement(); attOffset = 0; return MoveToNextAttribute(); } public override bool MoveToNextAttribute() { if (attOffset < attCount) { ChangeDepthToElement(); depth++; attOffset++; pipe.GetToken(attOffset, out qname, out value); nodeType = XmlNodeType.Attribute; return true; } return false; } public override bool ReadAttributeValue() { if (nodeType == XmlNodeType.Attribute) { nodeType = XmlNodeType.Text; depth++; return true; } return false; } public override void ResolveEntity() { throw new InvalidOperationException(); } public override string XmlLang { get { return scope.Lang; } } public override XmlSpace XmlSpace { get { return scope.Space; } } #endregion // XmlReader Implementation #region ------------------------------- Supporting classes ------------------------------ // QName is imutable. private class QName { string local; string nsUri; string prefix; public QName(string local, string nsUri, string prefix) { this.local = local ; this.nsUri = nsUri ; this.prefix = prefix; } public string Local { get { return this.local ; } } public string NsUri { get { return this.nsUri ; } } public string Prefix { get { return this.prefix; } } public override string ToString() { return (Prefix != null && Prefix.Length != 0) ? (Prefix + ':' + Local) : Local; } } // BufferWriter records information written to it in sequence of WriterEvents: [DebuggerDisplay("{NodeType}: name={Name}, Value={Value}")] private struct XmlToken { public XmlNodeType NodeType; public QName Name ; public string Value ; // it seams that it faster to set fields of structure in one call. // This trick is workaround of the C# limitation of declaring variable as ref to a struct. public static void Set(ref XmlToken evnt, XmlNodeType nodeType, QName name, string value) { evnt.NodeType = nodeType; evnt.Name = name ; evnt.Value = value ; } public static void Get(ref XmlToken evnt, out XmlNodeType nodeType, out QName name, out string value) { nodeType = evnt.NodeType; name = evnt.Name ; value = evnt.Value ; } } private class BufferWriter : XmlWriter { QNameTable qnameTable; TokenPipe pipe; string firstText; StringBuilder sbuilder; QName curAttribute; public QName QNameXmlSpace; public QName QNameXmlLang; public QName QNameEmpty; public BufferWriter(TokenPipe pipe, XmlNameTable nameTable) { this.pipe = pipe; this.qnameTable = new QNameTable(nameTable); this.sbuilder = new StringBuilder(); QNameXmlSpace = qnameTable.GetQName("space", NsXml, "xml"); QNameXmlLang = qnameTable.GetQName("lang" , NsXml, "xml"); QNameEmpty = qnameTable.GetQName("", "", ""); } public void Reset() { this.firstText = null; this.sbuilder.Length = 0; } private void AppendText(string text) { if (firstText == null) { Debug.Assert(sbuilder.Length == 0); firstText = text; } else if (sbuilder.Length == 0) { sbuilder.Append(firstText); } sbuilder.Append(text); } private string MergeText() { if (firstText == null) { return string.Empty; // There was no text ouptuted } if (sbuilder.Length != 0) { // merge content of sbuilder into firstText Debug.Assert(firstText != null); firstText = sbuilder.ToString(); sbuilder.Length = 0; } string result = firstText; firstText = null; return result; } private void FinishTextNode() { string text = MergeText(); if (text.Length != 0) { pipe.Write(XmlNodeType.Text, QNameEmpty, text); } } public override void WriteComment(string text) { FinishTextNode(); pipe.Write(XmlNodeType.Comment, QNameEmpty, text); } public override void WriteProcessingInstruction(string name, string text) { FinishTextNode(); pipe.Write(XmlNodeType.ProcessingInstruction, qnameTable.GetQName(name, string.Empty, string.Empty), text); } public override void WriteStartElement(string prefix, string name, string ns) { FinishTextNode(); pipe.Write(XmlNodeType.Element, qnameTable.GetQName(name, ns, prefix), ""); } public override void WriteEndElement() { FinishTextNode(); pipe.Write(XmlNodeType.EndElement, QNameEmpty, ""); } public override void WriteStartAttribute(string prefix, string name, string ns) { curAttribute = qnameTable.GetQName(name, ns, prefix); } public override void WriteEndAttribute(){ pipe.Write(XmlNodeType.Attribute, curAttribute, MergeText()); } public override void WriteString(string text) { AppendText(text); } public override void WriteFullEndElement() { WriteEndElement(); } public override void WriteRaw(string data) { WriteString(data); // In XslReader output we ignore disable-output-escaping } public override void Close() { FinishTextNode(); pipe.Close(); } public override void Flush() { } // XsltCompiledTransform never calls these methods and properties: public override void WriteStartDocument() { throw new NotSupportedException(); } public override void WriteStartDocument(bool standalone) { throw new NotSupportedException(); } public override void WriteEndDocument() { throw new NotSupportedException(); } public override void WriteDocType(string name, string pubid, string sysid, string subset) { throw new NotSupportedException(); } public override void WriteEntityRef(string name) { throw new NotSupportedException(); } public override void WriteCharEntity(char ch) { throw new NotSupportedException(); } public override void WriteSurrogateCharEntity(char lowChar, char highChar) { throw new NotSupportedException(); } public override void WriteWhitespace(string ws) { throw new NotSupportedException(); } public override void WriteChars(char[] buffer, int index, int count) { throw new NotSupportedException(); } public override void WriteRaw(char[] buffer, int index, int count) { throw new NotSupportedException(); } public override void WriteBase64(byte[] buffer, int index, int count) { throw new NotSupportedException(); } public override void WriteCData(string text) { throw new NotSupportedException(); } public override string LookupPrefix(string ns) { throw new NotSupportedException(); } public override WriteState WriteState { get { throw new NotSupportedException(); } } public override XmlSpace XmlSpace { get { throw new NotSupportedException(); } } public override string XmlLang { get { throw new NotSupportedException(); } } private class QNameTable { // This class atomizes QNames. XmlNameTable nameTable; Dictionary<string, List<QName>> qnames = new Dictionary<string, List<QName>>(); public QNameTable(XmlNameTable nameTable) { this.nameTable = nameTable; } public QName GetQName(string local, string nsUri, string prefix) { nsUri = nameTable.Add(nsUri ); prefix = nameTable.Add(prefix); List<QName> list; if (! qnames.TryGetValue(local, out list)) { list = new List<QName>(); qnames.Add(local, list); } else { foreach(QName qn in list) { Debug.Assert(qn.Local == local, "Atomization Failure: '" + local + "'"); if (RefEquals(qn.Prefix, prefix) && RefEquals(qn.NsUri, nsUri)) { return qn; } } } QName qname = new QName(nameTable.Add(local), nsUri, prefix); list.Add(qname); return qname; } private static string Atomize(string s, Dictionary<string, string> dic) { string atom; if (dic.TryGetValue(s, out atom)) { return atom; } else { dic.Add(s, s); return s; } } public static bool RefEquals(string strA, string strB) { Debug.Assert( ((object) strA == (object) strB) || ! String.Equals(strA, strB), "Atomization Failure: '" + strA + "'" ); return (object) strA == (object) strB; } } } private class ScopeManager { // We need the scope for the following reasons: // 1. Report QName on EndElement (local, nsUri, prefix ) // 2. Keep scope of Namespaces (null , nsUri, prefix ) // 3. Keep scope of xml:lang (null , lang , "lang" ) // 4. Keep scope of xml:space (null , space, "space") // On each StartElement we adding record(s) to the scope, // Its convinient to add QName last becuase in this case it will be directly available for EndElement static string atomLang = new String("lang" .ToCharArray()); static string atomSpace = new String("space".ToCharArray()); XmlNameTable nameTable; string stringEmpty; QName[] records = new QName[32]; int lastRecord; XmlSpace currentSpace; string currentLang; public ScopeManager(XmlNameTable nameTable) { this.nameTable = nameTable; this.stringEmpty = nameTable.Add(string.Empty); this.currentLang = this.stringEmpty; this.currentSpace = XmlSpace.None; Reset(); } public void Reset() { lastRecord = 0; records[lastRecord++] = new QName(null , nameTable.Add(NsXml), nameTable.Add("xml")); // xmlns:xml="http://www.w3.org/XML/1998/namespace" records[lastRecord++] = new QName(null , stringEmpty, stringEmpty); // xml="" records[lastRecord++] = new QName(stringEmpty, stringEmpty, stringEmpty); // -- lookup barier } public void PushScope(QName qname) { Debug.Assert(qname.Local != null, "Scope is Element Name"); AddRecord(qname); } public void PopScope() { Debug.Assert(records[lastRecord - 1].Local != null, "LastRecord in each scope is expected to be ElementName"); do { lastRecord--; Debug.Assert(0 < lastRecord, "Push/Pop balance error"); QName record = records[lastRecord-1]; if (record.Local != null) { break; // this record is Element QName } if ((object) record.Prefix == (object) atomLang) { currentLang = record.NsUri; } else if ((object) record.Prefix == (object) atomSpace) { currentSpace = Str2Space(record.NsUri); } } while (true); } private void AddRecord(QName qname) { if (lastRecord == records.Length) { QName[] temp = new QName[records.Length * 2]; records.CopyTo(temp, 0); records = temp; } records[lastRecord++] = qname; } public void AddNamespace(string prefix, string uri) { Debug.Assert(prefix != null); Debug.Assert(uri != null); prefix = nameTable.Add(prefix); uri = nameTable.Add(uri ); Debug.Assert( (object)prefix != (object)atomLang && (object)prefix != (object)atomSpace, "This assumption is important to distinct NsDecl from xml:space and xml:lang" ); AddRecord(new QName(null, uri, prefix)); } public void AddLang(string lang) { Debug.Assert(lang != null); lang = nameTable.Add(lang); if ((object) lang == (object) currentLang) { return; } AddRecord(new QName(null, currentLang, atomLang)); currentLang = lang; } public void AddSpace(string space) { Debug.Assert(space != null); XmlSpace xmlSpace = Str2Space(space); if (xmlSpace == XmlSpace.None) { throw new Exception("Unexpected value for xml:space attribute"); } if (xmlSpace == currentSpace) { return; } AddRecord(new QName(null, Space2Str(currentSpace), atomSpace)); currentSpace = xmlSpace; } private string Space2Str(XmlSpace space) { switch(space) { case XmlSpace.Preserve : return "preserve"; case XmlSpace.Default : return "default"; default : return "none"; } } private XmlSpace Str2Space(string space) { switch(space) { case "preserve" : return XmlSpace.Preserve; case "default" : return XmlSpace.Default; default : return XmlSpace.None; } } public string LookupNamespace(string prefix) { Debug.Assert(prefix != null); prefix = nameTable.Get(prefix); for (int i = lastRecord - 2; 0 <= i; i -- ) { QName record = records[i]; if (record.Local == null && (object)record.Prefix == (object)prefix) { return record.NsUri; } } return null; } public string Lang { get { return currentLang; } } public XmlSpace Space { get { return currentSpace; } } public QName Name { get { Debug.Assert(records[lastRecord-1].Local != null, "Element Name is expected"); return records[lastRecord - 1]; } } } private class TokenPipe { protected XmlToken[] buffer; protected int writePos; // position after last wrote token protected int readStartPos; // protected int readEndPos; // protected int mask; // used in TokenPipeMultiThread public TokenPipe(int bufferSize) { /*BuildMask*/ { if (bufferSize < 2) { bufferSize = defaultBufferSize; } // To make or round buffer work bufferSize should be == 2 power N and mask == bufferSize - 1 bufferSize--; mask = bufferSize; while ((bufferSize = bufferSize >> 1) != 0) { mask |= bufferSize; } } this.buffer = new XmlToken[mask + 1]; } public virtual void Reset() { readStartPos = readEndPos = writePos = 0; } public virtual void Write(XmlNodeType nodeType, QName name, string value) { Debug.Assert(writePos <= buffer.Length); if (writePos == buffer.Length) { XmlToken[] temp = new XmlToken[buffer.Length * 2]; buffer.CopyTo(temp, 0); buffer = temp; } Debug.Assert(writePos < buffer.Length); XmlToken.Set(ref buffer[writePos], nodeType, name, value); writePos++; } public virtual void WriteException(Exception e) { throw e; } public virtual void Read(out XmlNodeType nodeType, out QName name, out string value) { Debug.Assert(readEndPos < buffer.Length); XmlToken.Get(ref buffer[readEndPos], out nodeType, out name, out value); readEndPos++; } public virtual void FreeTokens(int num) { readStartPos += num; readEndPos = readStartPos; } public virtual void Close() { Write(XmlNodeType.None, null, null); } public virtual void GetToken(int attNum, out QName name, out string value) { Debug.Assert(0 <= attNum && attNum < readEndPos - readStartPos - 1); XmlNodeType nodeType; XmlToken.Get(ref buffer[readStartPos + attNum], out nodeType, out name, out value); Debug.Assert(nodeType == (attNum == 0 ? XmlNodeType.Element : XmlNodeType.Attribute), "We use GetToken() only to access parts of start element tag."); } } private class TokenPipeMultiThread : TokenPipe { Exception exception; public TokenPipeMultiThread(int bufferSize) : base(bufferSize) {} public override void Reset() { base.Reset(); exception = null; } private void ExpandBuffer() { // Buffer is too smal for this amount of attributes. Debug.Assert(writePos == readStartPos + buffer.Length, "no space to write next token"); Debug.Assert(writePos == readEndPos, "all tokens ware read"); int newMask = (mask << 1) | 1; XmlToken[] newBuffer = new XmlToken[newMask + 1]; for (int i = readStartPos; i < writePos; i ++) { newBuffer[i & newMask] = buffer[i & mask]; } buffer = newBuffer; mask = newMask; Debug.Assert(writePos < readStartPos + buffer.Length, "we should have now space to next write token"); } public override void Write(XmlNodeType nodeType, QName name, string value) { lock (this) { Debug.Assert(readEndPos <= writePos && writePos <= readStartPos + buffer.Length); if (writePos == readStartPos + buffer.Length) { if (writePos == readEndPos) { ExpandBuffer(); } else { Monitor.Wait(this); } } Debug.Assert(writePos < readStartPos + buffer.Length); XmlToken.Set(ref buffer[writePos & mask], nodeType, name, value); writePos++; if (readStartPos + buffer.Length <= writePos) { // This "if" is some heuristics, it may wrk or may not: // To minimize task switching we wakeup reader ony if we wrote enouph tokens. // So if reader already waits, let it sleep before we fill up the buffer. Monitor.Pulse(this); } } } public override void WriteException(Exception e) { lock (this) { exception = e; Monitor.Pulse(this); } } public override void Read(out XmlNodeType nodeType, out QName name, out string value) { lock (this) { Debug.Assert(readEndPos <= writePos && writePos <= readStartPos + buffer.Length); if (readEndPos == writePos) { if (readEndPos == readStartPos + buffer.Length) { ExpandBuffer(); Monitor.Pulse(this); } Monitor.Wait(this); } if (exception != null) { throw new XsltException("Exception happened during transformation. See inner exception for details:\n", exception); } } Debug.Assert(readEndPos < writePos); XmlToken.Get(ref buffer[readEndPos & mask], out nodeType, out name, out value); readEndPos++; } public override void FreeTokens(int num) { lock (this) { readStartPos += num; readEndPos = readStartPos; Monitor.Pulse(this); } } public override void Close() { Write(XmlNodeType.None, null, null); lock (this) { Monitor.Pulse(this); } } public override void GetToken(int attNum, out QName name, out string value) { Debug.Assert(0 <= attNum && attNum < readEndPos - readStartPos - 1); XmlNodeType nodeType; XmlToken.Get(ref buffer[(readStartPos + attNum) & mask], out nodeType, out name, out value); Debug.Assert(nodeType == (attNum == 0 ? XmlNodeType.Element : XmlNodeType.Attribute), "We use GetToken() only to access parts of start element tag."); } } #endregion ------------------------------- Supporting classes ------------------------------ } } |
From: Oleg T. <he...@us...> - 2005-11-07 13:58:32
|
Update of /cvsroot/mvp-xml/Common/v2/test/XmlSerializerCacheTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16810/v2/test/XmlSerializerCacheTests Modified Files: PerfCounterManagerTests.cs Log Message: Index: PerfCounterManagerTests.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/test/XmlSerializerCacheTests/PerfCounterManagerTests.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PerfCounterManagerTests.cs 28 Oct 2005 20:07:56 -0000 1.1 +++ PerfCounterManagerTests.cs 7 Nov 2005 13:58:18 -0000 1.2 @@ -30,7 +30,7 @@ internal static string GetCounterInstanceName(int index) { string fileName = Environment.CommandLine.Split(' ')[0]; - foreach (char c in System.IO.Path.InvalidPathChars) + foreach (char c in System.IO.Path.GetInvalidPathChars()) { fileName = fileName.Replace(c, '%'); } |
From: Oleg T. <he...@us...> - 2005-11-07 13:58:32
|
Update of /cvsroot/mvp-xml/Common/v2/test/XslReaderTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16810/v2/test/XslReaderTests Added Files: XslReaderTests.cs test1.xslt Log Message: --- NEW FILE: test1.xslt --- <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <out xmlns="foo" bar="" baz="a&b" xmlns:foo="http://schemas.microsoft.com/xsd/catalog"> <xsl:comment> @#$$ comment</xsl:comment> <xsl:processing-instruction name="pi">ghghghgh gh gh"" ''</xsl:processing-instruction> <xsl:copy-of select="/" /> </out> </xsl:template> </xsl:stylesheet> --- NEW FILE: XslReaderTests.cs --- using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.Xml.Xsl; using System.Xml.XPath; using System.IO; using Mvp.Xml.Common.Xsl; using Mvp.Xml.Tests; using NUnit.Framework; namespace Mvp.Xml.Tests.XslReaderTests { [TestFixture] public class XslReaderTests { static string copyTransform = @"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'> <xsl:copy-of select='/' /> </xsl:template> </xsl:stylesheet>"; public static XmlReader GetReader(string xml) { XmlReaderSettings s = new XmlReaderSettings(); s.ProhibitDtd = false; return XmlReader.Create(Globals.GetResource(xml), s); } /// <summary> /// Compare with standard XmlReader test /// </summary> [Test] public void Test1() { CompareWithStandardReader(true, 16); } private void CompareWithStandardReader(bool multiThread, int bufSize) { XmlReader r = GetReader(Globals.NorthwindResource); XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("../../XslReaderTests/test1.xslt"); MemoryStream ms = new MemoryStream(); XmlWriterSettings s = new XmlWriterSettings(); s.OmitXmlDeclaration = true; XmlWriter w = XmlWriter.Create(ms, s); xslt.Transform(r, w); r.Close(); w.Close(); byte[] buf = ms.ToArray(); XmlReader standard = XmlReader.Create(new MemoryStream(buf)); XslReader xslReader = new XslReader(xslt, multiThread, bufSize); xslReader.Transform(new XmlInput(GetReader(Globals.NorthwindResource)), null); CompareReaders(standard, xslReader); } private void CompareReaders(XmlReader standard, XmlReader custom) { while (standard.Read()) { Assert.IsTrue(custom.Read()); CompareReaderProperties(standard, custom); if (standard.HasAttributes) { while (standard.MoveToNextAttribute()) { Assert.IsTrue(custom.MoveToNextAttribute()); CompareReaderProperties(standard, custom); } standard.MoveToElement(); Assert.IsTrue(custom.MoveToElement()); } } } private static void CompareReaderProperties(XmlReader standard, XmlReader custom) { Assert.AreEqual(standard.AttributeCount, custom.AttributeCount); Assert.AreEqual(standard.BaseURI, custom.BaseURI); Assert.AreEqual(standard.Depth, custom.Depth); Assert.AreEqual(standard.EOF, custom.EOF); Assert.AreEqual(standard.HasAttributes, custom.HasAttributes); Assert.AreEqual(standard.HasValue, custom.HasValue); Assert.AreEqual(standard.IsDefault, custom.IsDefault); Assert.AreEqual(standard.IsEmptyElement, custom.IsEmptyElement); Assert.AreEqual(standard.LocalName, custom.LocalName); Assert.AreEqual(standard.Name, custom.Name); Assert.AreEqual(standard.NamespaceURI, custom.NamespaceURI); Assert.AreEqual(standard.NodeType, custom.NodeType); Assert.AreEqual(standard.Prefix, custom.Prefix); Assert.AreEqual(standard.QuoteChar, custom.QuoteChar); Assert.AreEqual(standard.ReadState, custom.ReadState); Assert.AreEqual(standard.Value, custom.Value); Assert.AreEqual(standard.ValueType, custom.ValueType); Assert.AreEqual(standard.XmlLang, custom.XmlLang); Assert.AreEqual(standard.XmlSpace, custom.XmlSpace); Assert.AreEqual(standard.LookupNamespace("foo"), custom.LookupNamespace("foo")); } /// <summary> /// Test LookupNamespace() /// </summary> [Test] public void Test2() { string xml = @"<foo xmlns:f=""bar""/>"; XmlReader standard = XmlReader.Create(new StringReader(xml)); XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(XmlReader.Create(new StringReader(copyTransform))); XslReader xslReader = new XslReader(xslt); xslReader.Transform(new XmlInput(new StringReader(xml)), null); standard.MoveToContent(); xslReader.MoveToContent(); Assert.IsTrue(standard.NodeType == xslReader.NodeType); Assert.IsTrue(standard.Name == xslReader.Name); string nsUri1 = standard.LookupNamespace("f"); string nsUri2 = xslReader.LookupNamespace("f"); Assert.IsTrue(nsUri1 == nsUri2, string.Format("'{0}' != '{1}'", nsUri1, nsUri2)); } /// <summary> /// Test Read() after EOF /// </summary> [Test] public void Test3() { string xml = @"<foo xmlns:f=""bar""/>"; XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(XmlReader.Create(new StringReader(copyTransform))); XslReader xslReader = new XslReader(xslt); xslReader.Transform(new XmlInput(new StringReader(xml)), null); while (!xslReader.EOF) { xslReader.Read(); } Assert.IsFalse(xslReader.Read()); } /// <summary> /// Test singlethread with small buffer /// </summary> [Test] public void Test4() { CompareWithStandardReader(false, 2); } /// <summary> /// Test different bufer sizes /// </summary> [Test] public void Test5() { for (int b = -1024; b < 1024; b+=100) { CompareWithStandardReader(false, b); } for (int b = -1024; b < 1024; b+=100) { CompareWithStandardReader(true, b); } CompareWithStandardReader(true, 0); CompareWithStandardReader(true, 1); CompareWithStandardReader(true, int.MinValue); CompareWithStandardReader(true, int.MaxValue); } /// <summary> /// Test reader restart /// </summary> [Test] public void Test6() { XmlReader r = GetReader(Globals.NorthwindResource); XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("../../XslReaderTests/test1.xslt"); MemoryStream ms = new MemoryStream(); XmlWriterSettings s = new XmlWriterSettings(); s.OmitXmlDeclaration = true; XmlWriter w = XmlWriter.Create(ms, s); xslt.Transform(r, w); r.Close(); w.Close(); byte[] buf = ms.ToArray(); XmlReader standard = XmlReader.Create(new MemoryStream(buf)); XslReader xslReader = new XslReader(xslt, true, 16); xslReader.Transform(new XmlInput(GetReader(Globals.NorthwindResource)), null); xslReader.MoveToContent(); xslReader.Read(); //Now restart it xslReader.Transform(new XmlInput(GetReader(Globals.NorthwindResource)), null); CompareReaders(standard, xslReader); } } } |
From: Oleg T. <he...@us...> - 2005-11-07 13:58:30
|
Update of /cvsroot/mvp-xml/Common/v2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16810/v2/test Modified Files: CommonTest.csproj IndexingXPathNavigatorTest.cs Added Files: EntryPoint.cs Log Message: Index: CommonTest.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/test/CommonTest.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CommonTest.csproj 29 Oct 2005 21:13:11 -0000 1.4 +++ CommonTest.csproj 7 Nov 2005 13:58:18 -0000 1.5 @@ -111,6 +111,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="EmptyXPathNodeIteratorTests.cs" /> + <Compile Include="EntryPoint.cs" /> <Compile Include="Globals.cs"> <SubType>Code</SubType> </Compile> @@ -175,7 +176,9 @@ <Compile Include="XPathSortBug.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="XslReaderTests\XslReaderTests.cs" /> <Content Include="changelog.txt" /> + <Content Include="XslReaderTests\test1.xslt" /> <EmbeddedResource Include="library.xml" /> <EmbeddedResource Include="northwind.xml" /> <EmbeddedResource Include="pubs.xml" /> --- NEW FILE: EntryPoint.cs --- using System; using System.Collections.Generic; using System.Text; using Mvp.Xml.Tests.XslReaderTests; namespace Mvp.Xml.Tests.Common { class EntryPoint { static void Main(string[] args) { XslReaderTests.XslReaderTests t = new XslReaderTests.XslReaderTests(); t.Test5(); } } } Index: IndexingXPathNavigatorTest.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/test/IndexingXPathNavigatorTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IndexingXPathNavigatorTest.cs 28 Oct 2005 20:01:48 -0000 1.2 +++ IndexingXPathNavigatorTest.cs 7 Nov 2005 13:58:18 -0000 1.3 @@ -17,11 +17,11 @@ [Test] public void RunTests() { - Main(new string[0]); + Main2(new string[0]); } [STAThread] - static void Main(string[] args) + static void Main2(string[] args) { Stopwatch stopWatch = new Stopwatch(); int repeat = 1000; |
From: Oleg T. <he...@us...> - 2005-11-07 13:58:30
|
Update of /cvsroot/mvp-xml/Common/v2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16810/v2/src Modified Files: Common.csproj Log Message: Index: Common.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Common.csproj,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Common.csproj 30 Oct 2005 13:48:26 -0000 1.8 +++ Common.csproj 7 Nov 2005 13:58:18 -0000 1.9 @@ -145,6 +145,8 @@ <Compile Include="XPath\XPathVariable.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="Xsl\IXmlTransform.cs" /> + <Compile Include="Xsl\XslReader.cs" /> <Content Include="changelog.txt" /> <EmbeddedResource Include="Serialization\PerfCounterInstaller.resx"> <DependentUpon>PerfCounterInstaller.cs</DependentUpon> |
From: Oleg T. <he...@us...> - 2005-11-07 13:56:03
|
Update of /cvsroot/mvp-xml/Common/v2/test/XslReaderTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16263/XslReaderTests Log Message: Directory /cvsroot/mvp-xml/Common/v2/test/XslReaderTests added to the repository |
From: Oleg T. <he...@us...> - 2005-11-07 13:55:48
|
Update of /cvsroot/mvp-xml/Common/v2/src/Xsl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16216/Xsl Log Message: Directory /cvsroot/mvp-xml/Common/v2/src/Xsl added to the repository |
From: Oleg T. <he...@us...> - 2005-11-07 11:35:47
|
Update of /cvsroot/mvp-xml/Common/v2/src/Serialization In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7132/v2/src/Serialization Modified Files: PerfCounterManager.cs Log Message: Index: PerfCounterManager.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v2/src/Serialization/PerfCounterManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- PerfCounterManager.cs 30 Oct 2005 12:01:04 -0000 1.2 +++ PerfCounterManager.cs 7 Nov 2005 11:35:37 -0000 1.3 @@ -43,7 +43,7 @@ counters.Add(GetCacheHitCounterData()); counters.Add(GetCachedInstancesCounterData()); PerformanceCounterCategory.Create( - CATEGORY, CATEGORY_DESCRIPTION, PerformanceCounterCategoryType.SingleInstance, + CATEGORY, CATEGORY_DESCRIPTION, PerformanceCounterCategoryType.MultiInstance, counters); } } |