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-10-16 20:08:37
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results/EXSLT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13161/EXSLT Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results/EXSLT added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 20:08:37
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results/GotDotNet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13161/GotDotNet Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results/GotDotNet added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 20:08:28
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13131/tests Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/tests added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 20:08:28
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13131/results Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest/results added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 20:08:20
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13096/ExsltTest Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test/ExsltTest added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 20:08:20
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test/ExsltXPathTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13096/ExsltXPathTest Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test/ExsltXPathTest added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 20:08:11
|
Update of /cvsroot/mvp-xml/EXSLT/v2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13073/test Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/test added to the repository |
Update of /cvsroot/mvp-xml/EXSLT/v2/src/MethodRenamer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12843/v2/src/MethodRenamer Added Files: .cvsignore App.config MethodRenamer.cs MethodRenamer.csproj MethodRenamer.exe.config MethodRenamer.vshost.exe.config Log Message: --- NEW FILE: .cvsignore --- bin obj *.user *.suo *.pdb *.exe *.vspscc --- NEW FILE: MethodRenamer.vshost.exe.config --- (This appears to be a binary file; contents omitted.) --- NEW FILE: MethodRenamer.exe.config --- (This appears to be a binary file; contents omitted.) --- NEW FILE: MethodRenamer.csproj --- (This appears to be a binary file; contents omitted.) --- NEW FILE: MethodRenamer.cs --- using System; using System.Collections.Specialized; using System.Collections; using System.IO; using System.Text; using System.Configuration; namespace Mvp.Xml.Exslt.MethodRenamer { /// <summary> /// An utility to rename methods in MSIL code. /// </summary> public class MethodRenamer { [STAThread] static void Main(string[] args) { IDictionary dictionary = (IDictionary)ConfigurationManager.GetSection("names"); //Reads input IL code StreamReader reader = new StreamReader(args[0]); //Writes output IL code StreamWriter writer = new StreamWriter(args[1]); string line; //Go read line by line while ((line = reader.ReadLine()) != null) { //Method definition? if (line.Trim().StartsWith(".method")) { writer.WriteLine(line); line = reader.ReadLine(); if (line.IndexOf("(") != -1) { string methodName = line.Trim().Substring(0, line.Trim().IndexOf("(")); if (dictionary.Contains(methodName)) { writer.WriteLine(line.Replace(methodName + "(", "'" + (string)dictionary[methodName] + "'(")); Console.WriteLine("Found '" + methodName + "' method, renamed to '" + dictionary[methodName] + "'"); } else writer.WriteLine(line); } else writer.WriteLine(line); } else writer.WriteLine(line); } reader.Close(); writer.Close(); } } } --- NEW FILE: App.config --- (This appears to be a binary file; contents omitted.) |
From: Oleg T. <he...@us...> - 2005-10-16 20:07:19
|
Update of /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/MultiOutput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12843/v2/src/Exslt/MultiOutput Added Files: MultiXmlTextWriter.cs OutputState.cs Log Message: --- NEW FILE: MultiXmlTextWriter.cs --- #region using using System; using System.Xml; using System.Text; using System.Collections; using System.IO; using System.Security; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// Specifies the redirecting state of the <c>MultiXmlTextWriter</c>. /// </summary> internal enum RedirectState { /// <summary> /// The output is being relayed further (default). /// </summary> Relaying, /// <summary> /// The output is being redirected. /// </summary> Redirecting, /// <summary> /// <c><exsl:document></c> attributes are being written /// </summary> WritingRedirectElementAttrs, /// <summary> /// <c><exsl:document></c> attribute value is being written /// </summary> WritingRedirectElementAttrValue } /// <summary> /// <para><c>MultiXmlTextWriter</c> class extends standard <c>XmlTextWriter</c> class /// and represents an XML writer that provides a fast, /// non-cached, forward-only way of generating multiple output files containing /// either text data or XML data that conforms to the W3C Extensible Markup /// Language (XML) 1.0 and the Namespaces in XML recommendations.</para> /// </summary> /// <remarks> /// <para>Instances of <c>MultiXmlTextWriter</c> class regognize special element /// (<c><exsl:document></c> in <c>"http://exslt.org/common"</c> namespace) as /// instruction to redirect the output of this element's content to another file. /// When using with <c>XslTransform</c> class, <c>MultiXmlTextWriter</c> class /// allows to generate multiple XSL Transfromation results.</para> /// <para><c>MultiXmlTextWriter</c> class extends <c>System.Xml.XmlTextWriter</c> /// class, therefore its instances can be passed directly to the overloaded /// <c>XslTransform.Transform()</c> method, which accepts <c>XmlWriter</c> as /// object to write the transformation result to. All actual XML writing work /// <c>MultiXmlTextWriter</c> class delegates to its base class, but it overrides /// several <c>XmlTextWriter</c> class methods to implement output switching logic /// as follows: once <c><exsl:document></c> element start tag is detected in /// the XML stream, new writer (<c>XmlTextWriter</c> or <c>StreamWriter</c> depending on /// <c>method</c> attribute value) object is created with parameters as specified /// in the attributes of the <c><exsl:document></c> element and the output /// is switched to this newly created writer untill the end tag of the /// <c><exsl:document></c> element is encountered.</para> /// <para><c><exsl:document></c> element syntax is as follows: /// <code> /// <exsl:document /// href = { uri-reference } /// method = { "xml" | "text" } /// encoding = { string } /// omit-xml-declaration = { "yes" | "no" } /// standalone = { "yes" | "no" } /// doctype-public = { string } /// doctype-system = { string } /// indent = { "yes" | "no" } /// <-- Content: template --> /// </exsl:document> /// </code></para> /// <para> /// The <c>href</c> attribute specifies where new result document should be stored, /// it must be an absolute or relative URI. Relative URIs are resolved /// relatively to the parent result document base URI. If the <c>href</c> attribute /// specifies that the output should be redirected to a file in a directory /// and that directory does not exist, it will be created. This allows to create /// directory trees of any complexity.</para> /// <para>Semantics of the rest attributes is as defined in W3C XSLT 1.0 Recommendation /// for <c><xsl:output></c> element, see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a>. /// </para> /// <para><b>Note:</b> <c><exsl:document></c> element namespace prefix must be bound to /// <c>"http://exslt.org/common"</c> namespace URI in order to be recognized by /// <c>MultiXmlTextWriter</c> class as a redirecting instruction. </para> /// </remarks> /// <example>This example shows how to use <c>MultiXmlTextWriter</c> along with /// <c>XslTransform</c> to achieve create multiple result documents in one /// transfromation run: /// <para>In XSL stylesheet document declare <c>"http://exslt.org/common"</c> namespace /// and whenever you want to create new result document make use of <c><exsl:documnet></c> /// element:<br/> /// <c>style.xsl</c> stylesheet fragment: /// <code> /// <![CDATA[ /// <xsl:stylesheet version="1.0" /// xmlns:xsl="http://www.w3.org/1999/XSL/Transform" /// ]]><b>xmlns:exsl= "http://exslt.org/common"</b><![CDATA[ /// ]]><b>exclude-result-prefixes="exsl"</b>><![CDATA[ /// <xsl:template match="book"> /// <!-- Builds frameset --> /// <html> /// <head> /// <title><xsl:value-of select="@title"/></title> /// </head> /// <frameset cols="20%,80%"> /// <frame src="toc.html"/> /// <!-- Builds table of contents output document --> /// ]]><b><exsl:document href="toc.html" indent="yes"></b><![CDATA[ /// <html> /// <head> /// <title>Table of Contents</title> /// </head> /// <body> /// <ul> /// <xsl:apply-templates mode="toc"/> /// </ul> /// </body> /// </html> /// ]]><b></exsl:document></b><![CDATA[ /// <frame src="{chapter[1]/@id}.html" name="body" /> /// <xsl:apply-templates /> /// </frameset> /// </html> /// ... /// /// ]]> /// </code> /// C# code fragment: /// <code> /// XPathDocument doc = new XPathDocument("book.xml"); /// XslTransform xslt = new XslTransform(); /// xslt.Load("style.xsl"); /// MultiXmlTextWriter multiWriter = /// new MultiXmlTextWriter("index.html", Encoding.UTF8); /// multiWriter.Formatting = Formatting.Indented; /// xslt.Transform(doc, null, multiWriter); /// </code> /// </para> /// </example> public class MultiXmlTextWriter : XmlTextWriter { /// <summary> /// This constant is the namespace <c><exsl:document></c> element /// should belong to in order to be recognized as redirect instruction. /// It's <c>"http://exslt.org/common"</c> as defined by /// <a href="http://www.exslt.org">EXSLT community initiative</a>. /// </summary> protected const string RedirectNamespace = "http://exslt.org/common"; /// <summary> /// This constant is the redirect instruction element name. /// It's <c>"document"</c> as defined by /// <a href="http://www.exslt.org">EXSLT community initiative</a>. /// </summary> protected const string RedirectElementName = "document"; // Stack of output states Stack states = null; // Current output state OutputState state = null; // Currently processed attribute name string currentAttributeName; //Redirecting state - relaying by default RedirectState redirectState = RedirectState.Relaying; /// <summary> /// Creates an instance of the <c>MultiXmlTextWriter</c> class using the specified filename and /// encoding. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter"/>. /// Overridden to set output directory. /// </summary> /// <param name="fileName">The filename to write to. If the file exists, it will truncate it and overwrite it /// with the new content.</param> /// <param name="encoding">The encoding to generate. If encoding is a null reference it writes the file out /// as UTF-8, and omits the encoding attribute from the ProcessingInstruction.</param> /// <exception cref="ArgumentException">The encoding is not supported; the filename is empty, contains only /// white space, or contains one or more invalid characters.</exception> /// <exception cref="UnauthorizedAccessException">Access is denied.</exception> /// <exception cref="ArgumentNullException">The filename is a null reference.</exception> /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception> /// <exception cref="IOException">The filename includes an incorrect or invalid syntax /// for file name, directory name, or volume label syntax.</exception> /// <exception cref="SecurityException">The caller does not have the required permission.</exception> public MultiXmlTextWriter(String fileName, Encoding encoding):base(fileName, encoding) { DirectoryInfo dir = Directory.GetParent(fileName); Directory.SetCurrentDirectory(dir.ToString()); } /// <summary> /// Creates an instance of the <c>MultiXmlTextWriter</c> class using the specified /// <c>TextWriter</c>, see <see cref="TextWriter"/>. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter"/>. /// </summary> /// <param name="w">The <c>TextWriter</c> to write to. It is assumed that the <c>TextWriter</c> is /// already set to the correct encoding.</param> public MultiXmlTextWriter(TextWriter w):base(w) {} /// <summary> /// Creates an instance of the <c>MultiXmlTextWriter</c> class using the specified /// stream and encoding. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter"/>. /// </summary> /// <param name="w">The stream to which you want to write.</param> /// <param name="encoding">The encoding to generate. If encoding is a null /// reference it writes out the stream as UTF-8 and omits the encoding attribute /// from the ProcessingInstruction.</param> /// <exception cref="ArgumentException">The encoding is not supported or the stream /// cannot be written to.</exception> /// <exception cref="ArgumentNullException">w is a null reference.</exception> public MultiXmlTextWriter(Stream w, Encoding encoding):base(w, encoding) {} /// <summary> /// Checks possible start of <c><exsl:document></c> element content. /// </summary> /// <remarks> /// When <c><exsl:document></c> element start tag is detected, the beginning of the /// element's content might be detected as any next character data (not attribute /// value though), element start tag, processing instruction or comment. /// </remarks> /// <exception cref="ArgumentNullException">Thrown when <c>href</c> attribute is absent.</exception> /// <exception cref="ArgumentException">Thrown when a document, specified by <c>href</c> attribute is /// opened alreary. Two nested <c><exsl:document></c></exception> elements cannot specify the same /// output URI in their <c>href</c> attributes. private void CheckContentStart() { if (redirectState == RedirectState.WritingRedirectElementAttrs) { //Check required href attribute if (state.Href == null) throw new ArgumentNullException("'href' attribute of exsl:document element must be specified."); //Are we writing to this URI already? foreach (OutputState nestedState in states) if (nestedState.Href == state.Href) throw new ArgumentException("Cannot write to " + state.Href + " two documents simultaneously."); state.InitWriter(); redirectState = RedirectState.Redirecting; } } /// <summary> /// Writes the specified start tag and associates it with the given namespace and prefix. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteStartElement"/> /// Overridden to detect <c>exsl:document</c> element start tag. /// </summary> /// <param name="prefix">The namespace prefix of the element.</param> /// <param name="localName">The local name of the element.</param> /// <param name="ns">The namespace URI to associate with the element. If this namespace /// is already in scope and has an associated prefix then the writer will automatically write that prefix also. </param> /// <exception cref="InvalidOperationException">The writer is closed.</exception> public override void WriteStartElement(string prefix, string localName, string ns) { CheckContentStart(); //Is it exsl:document redirecting instruction? if (ns == RedirectNamespace && localName == RedirectElementName) { //Lazy stack of states if (states == null) states = new Stack(); //If we are redirecting already - push the current state into the stack if (redirectState == RedirectState.Redirecting) states.Push(state); //Initialize new state state = new OutputState(); redirectState = RedirectState.WritingRedirectElementAttrs; } else { if (redirectState == RedirectState.Redirecting) { if (state.Method == OutputMethod.Text) { state.Depth++; return; } //Write doctype before the first element if (state.Depth == 0 && state.SystemDoctype != null) if (prefix != String.Empty) state.XmlWriter.WriteDocType(prefix+":"+localName, state.PublicDoctype,state.SystemDoctype, null); else state.XmlWriter.WriteDocType(localName, state.PublicDoctype,state.SystemDoctype, null); state.XmlWriter.WriteStartElement(prefix, localName, ns); state.Depth++; } else base.WriteStartElement(prefix, localName, ns); } } /// <summary> /// Finishes output redirecting - closes current writer /// and pops previous state. /// </summary> internal void FinishRedirecting() { state.CloseWriter(); //Pop previous state if it exists if (states.Count != 0) { state = (OutputState)states.Pop(); redirectState = RedirectState.Redirecting; } else { state = null; redirectState = RedirectState.Relaying; } } /// <summary> /// Closes one element and pops the corresponding namespace scope. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteEndElement"/> /// Overridden to detect <c>exsl:document</c> element end tag. /// </summary> public override void WriteEndElement() { CheckContentStart(); if (redirectState == RedirectState.Redirecting) { //Check if that's exsl:document end tag if (state.Depth-- == 0) FinishRedirecting(); else { if (state.Method == OutputMethod.Text) return; state.XmlWriter.WriteEndElement(); } } else base.WriteEndElement(); } /// <summary> /// Closes one element and pops the corresponding namespace scope. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteFullEndElement"/> /// Overridden to detect <c>exsl:document</c> element end tag. /// </summary> public override void WriteFullEndElement() { CheckContentStart(); if (redirectState == RedirectState.Redirecting) { //Check if it's exsl:document end tag if (state.Depth-- == 0) FinishRedirecting(); else { if (state.Method == OutputMethod.Text) return; state.XmlWriter.WriteFullEndElement(); } } else base.WriteFullEndElement(); } /// <summary> /// Writes the start of an attribute. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteStartAttribute"/> /// Overridden to detect <c>exsl:document</c> attribute names and to redirect /// the output. /// </summary> /// <param name="prefix">Namespace prefix of the attribute.</param> /// <param name="localName">Local name of the attribute.</param> /// <param name="ns">Namespace URI of the attribute.</param> /// <exception cref="ArgumentException"><c>localName</c>c> is either a null reference or <c>String.Empty</c>.</exception> public override void WriteStartAttribute(string prefix, string localName, string ns) { if (redirectState == RedirectState.WritingRedirectElementAttrs) { redirectState = RedirectState.WritingRedirectElementAttrValue; currentAttributeName = localName; } else if (redirectState == RedirectState.Redirecting) { if (state.Method == OutputMethod.Text) return; state.XmlWriter.WriteStartAttribute(prefix, localName, ns); } else base.WriteStartAttribute(prefix, localName, ns); } /// <summary> /// Closes the previous <c>WriteStartAttribute</c> call. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteEndAttribute"/> /// Overridden to redirect the output. /// </summary> public override void WriteEndAttribute() { if (redirectState == RedirectState.WritingRedirectElementAttrValue) redirectState = RedirectState.WritingRedirectElementAttrs; else if (redirectState == RedirectState.Redirecting) { if (state.Method == OutputMethod.Text) return; state.XmlWriter.WriteEndAttribute(); } else base.WriteEndAttribute(); } /// <summary> /// Writes out a comment <!--...--> containing the specified text. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteComment"/> /// Overriden to redirect the output. /// </summary> /// <param name="text">Text to place inside the comment.</param> /// <exception cref="ArgumentException">The text would result in a non-well formed XML document.</exception> /// <exception cref="InvalidOperationException">The <c>WriteState</c> is Closed.</exception> public override void WriteComment(string text) { CheckContentStart(); if (redirectState == RedirectState.Redirecting) { if (state.Method == OutputMethod.Text) return; state.XmlWriter.WriteComment(text); } else base.WriteComment(text); } /// <summary> /// Writes out a processing instruction with a space between the name /// and text as follows: <?name text?>. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteProcessingInstruction"/> /// Overridden to redirect the output. /// </summary> /// <param name="name">Name of the processing instruction.</param> /// <param name="text">Text to include in the processing instruction.</param> /// <exception cref="ArgumentException"><para>The text would result in a non-well formed XML document.</para> /// <para><c>name</c> is either a null reference or <c>String.Empty</c>.</para> /// <para>This method is being used to create an XML declaration after /// <c>WriteStartDocument</c> has already been called.</para></exception> public override void WriteProcessingInstruction(string name, string text) { CheckContentStart(); if (redirectState == RedirectState.Redirecting) { if (state.Method == OutputMethod.Text) return; state.XmlWriter.WriteProcessingInstruction(name, text); } else base.WriteProcessingInstruction(name, text); } /// <summary> /// Writes the given text content. /// Inherited from <c>XmlTextWriter</c>, see <see cref="XmlTextWriter.WriteString"/> /// Overridden to detect <c>exsl:document</c> element attribute values and to /// redirect the output. /// </summary> /// <param name="text">Text to write.</param> /// <exception cref="ArgumentException">The text string contains an invalid surrogate pair.</exception> public override void WriteString(string text) { //Possible exsl:document's attribute value if (redirectState == RedirectState.WritingRedirectElementAttrValue) { switch (currentAttributeName) { case "href": state.Href = text; break; case "method": if (text == "text") state.Method = OutputMethod.Text; break; case "encoding": try { state.Encoding = Encoding.GetEncoding(text); } catch (Exception) {} break; case "indent": if (text == "yes") state.Indent = true; break; case "doctype-public": state.PublicDoctype = text; break; case "doctype-system": state.SystemDoctype = text; break; case "standalone": if (text == "yes") state.Standalone = true; break; case "omit-xml-declaration": if (text == "yes") state.OmitXmlDeclaration = true; break; default: break; } return; } else CheckContentStart(); if (redirectState == RedirectState.Redirecting) { if (state.Method == OutputMethod.Text) state.TextWriter.Write(text); else state.XmlWriter.WriteString(text); } else base.WriteString(text); } } } --- NEW FILE: OutputState.cs --- #region using using System; using System.Xml; using System.Text; using System.IO; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// XSLT output method enumeration, see W3C XSLT 1.0 Recommendation at /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a>. /// </summary> /// <remarks>Only <c>xml</c> and <c>text</c> methods are supported by this version of /// the <c>MultiXmlTextWriter</c>.</remarks> internal enum OutputMethod { Xml, Text }; /// <summary> /// This class represents redirected output state and properties. /// </summary> internal class OutputState { private XmlTextWriter xmlWriter; private StreamWriter textWriter; private int depth; private string href; private Encoding encoding; private bool indent; private string publicDoctype; private string systemDoctype; private bool standalone; private string storedDir; private OutputMethod method; private bool omitXmlDecl; /// <summary> /// Creates new <c>OutputState</c> with default properties values: /// UTF8 encoding, no indentation, nonstandalone document, XML output /// method. /// </summary> public OutputState() { encoding = System.Text.Encoding.UTF8; indent = false; standalone = false; omitXmlDecl = false; method = OutputMethod.Xml; } /// <summary> /// Initializes the writer to write redirected output. /// </summary> /// <remarks>Depending on the <c>method</c> attribute value, /// <c>XmlTextWriter</c> or <c>StreamWriter</c> is created. /// <c>XmlTextWriter</c> is used for outputting XML and /// <c>StreamWriter</c> - for plain text. /// </remarks> public void InitWriter() { // Save current directory storedDir = Directory.GetCurrentDirectory(); DirectoryInfo dir = Directory.GetParent(href); if (!dir.Exists) dir.Create(); // Create writer if (method == OutputMethod.Xml) { xmlWriter = new XmlTextWriter(href, encoding); if (indent) xmlWriter.Formatting = Formatting.Indented; if (!omitXmlDecl) { if (standalone) xmlWriter.WriteStartDocument(true); else xmlWriter.WriteStartDocument(); } } else textWriter = new StreamWriter(href, false, encoding); // Set new current directory Directory.SetCurrentDirectory(dir.ToString()); } /// <summary> /// Closes the writer that was used to write redirected output. /// </summary> public void CloseWriter() { if (method == OutputMethod.Xml) { if (!omitXmlDecl) { xmlWriter.WriteEndDocument(); } xmlWriter.Close(); } else textWriter.Close(); // Restore previous current directory Directory.SetCurrentDirectory(storedDir); } /// <summary> /// Specifies whether the result document should be written with /// a standalone XML document declaration. /// </summary> /// <value>Standalone XML declaration as per W3C XSLT 1.0 Recommendation (see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a> /// for more info).</value> /// <remarks>The property does not affect output while output method is <c>text</c>.</remarks> public bool Standalone { get { return standalone; } set { standalone = value; } } /// <summary> /// Specifies output method. /// </summary> /// <value>Output Method as per W3C XSLT 1.0 Recommendation (see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a> /// for more info).</value> public OutputMethod Method { get { return method; } set { method = value; } } /// <summary> /// Specifies the URI where the result document should be written to. /// </summary> /// <value>Absolute or relative URI of the output document.</value> public string Href { get { return href; } set { href = value; } } /// <summary> /// Specifies the preferred character encoding of the result document. /// </summary> /// <value>Output encoding as per W3C XSLT 1.0 Recommendation (see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a> /// for more info).</value> public Encoding Encoding { get { return encoding; } set { encoding = value; } } /// <summary> /// Specifies whether the result document should be written in the /// indented form. /// </summary> /// <value>Output document formatting as per W3C XSLT 1.0 Recommendation (see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a> /// for more info).</value> /// <remarks>The property does not affect output while output method is <c>text</c>.</remarks> public bool Indent { get { return indent; } set { indent = value; } } /// <summary> /// Specifies the public identifier to be used in the document /// type declaration. /// </summary> /// <value>Public part of the output document type definition as per W3C XSLT 1.0 Recommendation (see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a> /// for more info).</value> /// <remarks>The property does not affect output while output method is <c>text</c>.</remarks> public string PublicDoctype { get { return publicDoctype; } set { publicDoctype = value; } } /// <summary> /// Specifies the system identifier to be used in the document /// type declaration. /// </summary> /// <value>System part of the output document type definition as per W3C XSLT 1.0 Recommendation (see /// <a href="http://www.w3.org/TR/xslt.html#output">http://www.w3.org/TR/xslt.html#output</a> /// for more info).</value> /// <remarks>The property does not affect output while output method is <c>text</c>.</remarks> public string SystemDoctype { get { return systemDoctype; } set { systemDoctype = value; } } /// <summary> /// Actual <c>XmlTextWriter</c> used to write the redirected /// result document. /// </summary> /// <value><c>XmlWriter</c>, which is used to write the output document in XML method.</value> public XmlTextWriter XmlWriter { get { return xmlWriter; } } /// <summary> /// Actual <c>TextWriter</c> used to write the redirected /// result document in text output method. /// </summary> /// <value><c>StreamWriter</c>, which is used to write the output document in text method.</value> public StreamWriter TextWriter { get { return textWriter; } } /// <summary> /// Tree depth (used to detect end tag of the <c>exsl:document</c>). /// </summary> /// <value>Current output tree depth.</value> public int Depth { get { return depth; } set { depth = value; } } /// <summary> /// Specifies whether the XSLT processor should output an XML declaration. /// </summary> public bool OmitXmlDeclaration { get { return omitXmlDecl; } set { omitXmlDecl = value; } } } } |
Update of /cvsroot/mvp-xml/EXSLT/v2/src/Exslt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12843/v2/src/Exslt Added Files: .cvsignore AssemblyInfo.cs Exslt.csproj ExsltContext.cs ExsltContextFunction.cs ExsltDatesAndTimes.cs ExsltMath.cs ExsltNamespaces.cs ExsltNodeList.cs ExsltRandom.cs ExsltRegularExpressions.cs ExsltSets.cs ExsltStrings.cs ExsltTransform.cs GDNDatesAndTimes.cs GDNDynamic.cs GDNMath.cs GDNRegularExpressions.cs GDNSets.cs GDNStrings.cs Makefile MethodRenamer.exe MethodRenamer.exe.config PostBuildEvent.bat install.cmd uninstall.cmd Log Message: --- NEW FILE: ExsltNamespaces.cs --- namespace Mvp.Xml.Exslt { /// <summary> /// Exslt (and other) namespaces constants. /// </summary> public class ExsltNamespaces { public const string DatesAndTimes = "http://exslt.org/dates-and-times"; public const string Math = "http://exslt.org/math"; public const string Random = "http://exslt.org/random"; public const string RegularExpressions = "http://exslt.org/regular-expressions"; public const string Sets = "http://exslt.org/sets"; public const string Strings = "http://exslt.org/strings"; public const string GDNDatesAndTimes = "http://gotdotnet.com/exslt/dates-and-times"; public const string GDNMath = "http://gotdotnet.com/exslt/math"; public const string GDNRegularExpressions = "http://gotdotnet.com/exslt/regular-expressions"; public const string GDNSets = "http://gotdotnet.com/exslt/sets"; public const string GDNStrings = "http://gotdotnet.com/exslt/strings"; public const string GDNDynamic = "http://gotdotnet.com/exslt/dynamic"; } } --- NEW FILE: GDNStrings.cs --- namespace Mvp.Xml.Exslt { /// <summary> /// This class implements additional functions in the http://gotdotnet.com/exslt/strings namespace. /// </summary> public class GDNStrings { /// <summary> /// Implements the following function /// string uppercase(string) /// </summary> /// <param name="str"></param> /// <returns></returns> /// <remarks>THIS FUNCTION IS NOT IN EXSLT!!!</remarks> public string uppercase(string str) { return str.ToUpper(); } /// <summary> /// Implements the following function /// string lowercase(string) /// </summary> /// <param name="str"></param> /// <returns></returns> /// <remarks>THIS FUNCTION IS NOT IN EXSLT!!!</remarks> public string lowercase(string str) { return str.ToLower(); } } } --- NEW FILE: ExsltRandom.cs --- #region using using System; using System.Xml.XPath; using System.Xml; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements the EXSLT functions in the http://exslt.org/random namespace. /// </summary> public class ExsltRandom { /// <summary> /// Implements the following function /// number+ random:random-sequence(number?, number?) /// </summary> public XPathNodeIterator randomSequence() { return randomSequenceImpl(1, (int)DateTime.Now.Ticks); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public XPathNodeIterator randomSequence_RENAME_ME() { return randomSequence(); } /// <summary> /// Implements the following function /// number+ random:random-sequence(number?, number?) /// </summary> public XPathNodeIterator randomSequence(double number) { return randomSequenceImpl(number, (int)DateTime.Now.Ticks); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public XPathNodeIterator randomSequence_RENAME_ME(double number) { return randomSequence(number); } /// <summary> /// Implements the following function /// number+ random:random-sequence(number?, number?) /// </summary> public XPathNodeIterator randomSequence(double number, double seed) { return randomSequenceImpl(number, (int)(seed % int.MaxValue)); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public XPathNodeIterator randomSequence_RENAME_ME(double number, double seed) { return randomSequence(number, seed); } /// <summary> /// random-sequence() implementation; /// </summary> /// <param name="number"></param> /// <param name="seed"></param> /// <returns></returns> private XPathNodeIterator randomSequenceImpl(double number, int seed) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<randoms/>"); Random rand = new Random(seed); //Negative number is bad idea - fallback to default if (number < 0) number = 1; //we limit number of generated numbers to int.MaxValue if (number > int.MaxValue) number = int.MaxValue; for (int i=0; i<Convert.ToInt32(number); i++) { XmlElement elem = doc.CreateElement("random"); elem.InnerText = rand.NextDouble().ToString(); doc.DocumentElement.AppendChild(elem); } return doc.CreateNavigator().Select("/randoms/random"); } } } --- NEW FILE: Makefile --- all: @echo off @echo ########### Building Exslt library... csc /out:Mvp.Xml.Exslt.dll /target:library *.cs MultiOutput\*.cs /debug- /optimize+ nmake rename-methods rename-methods: @echo ########### Disassembing... ildasm Mvp.Xml.Exslt.dll /out=Mvp.Xml.Exslt.il /nobar @echo ########### Renaming methods... MethodRenamer.exe Mvp.Xml.Exslt.il Mvp.Xml.Exslt.Fixed.il @echo ########### Assembling library back... ilasm Mvp.Xml.Exslt.Fixed.il /RESOURCE=Mvp.Xml.Exslt.res /DLL /OUTPUT=Mvp.Xml.Exslt.dll /KEY=../../../../Global/v1/mvp-xml.snk nmake clean clean: @echo ########### Cleaning... del Mvp.Xml.Exslt.res del Mvp.Xml.Exslt.il del Mvp.Xml.Exslt.Fixed.il --- NEW FILE: ExsltDatesAndTimes.cs --- #region using using System; using System.Globalization; using System.Xml; using System.Xml.XPath; using System.Text; using System.Text.RegularExpressions; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements the EXSLT functions in the http://exslt.org/dates-and-times namespace. /// </summary> public class ExsltDatesAndTimes { private CultureInfo ci = new CultureInfo("en-US"); [...2135 lines suppressed...] /// string date:duration() /// </summary> /// <returns>seconds since the beginning of the epoch until now</returns> public string duration() { return duration(seconds()); } /// <summary> /// Implements the following function /// string date:duration(number) /// </summary> /// <param name="seconds"></param> /// <returns></returns> public string duration(double seconds) { return XmlConvert.ToString(new TimeSpan(0,0,(int)seconds)); } } } --- NEW FILE: GDNDatesAndTimes.cs --- #region using using System; using System.Globalization; using System.Xml; using System.Xml.XPath; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements additional functions in the /// "http://gotdotnet.com/exslt/dates-and-times" namespace. /// </summary> public class GDNDatesAndTimes : ExsltDatesAndTimes { #region date2:avg() /// <summary> /// Implements the following function /// string date2:avg(node-set) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-avg.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public string avg(XPathNodeIterator iterator) { TimeSpan sum = new TimeSpan(0,0,0,0); int count = iterator.Count; if(count == 0) { return ""; } try { while(iterator.MoveNext()) { sum = XmlConvert.ToTimeSpan(iterator.Current.Value).Add(sum); } } catch(FormatException) { return ""; } return duration(sum.TotalSeconds / count); } #endregion #region date2:min() /// <summary> /// Implements the following function /// string date2:min(node-set) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-min.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public string min(XPathNodeIterator iterator) { TimeSpan min, t; if(iterator.Count == 0) { return ""; } try { iterator.MoveNext(); min = XmlConvert.ToTimeSpan(iterator.Current.Value); while(iterator.MoveNext()) { t = XmlConvert.ToTimeSpan(iterator.Current.Value); min = (t < min)? t : min; } } catch(FormatException) { return ""; } return XmlConvert.ToString(min); } #endregion #region date2:max() /// <summary> /// Implements the following function /// string date2:max(node-set) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-max.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public string max(XPathNodeIterator iterator) { TimeSpan max, t; if(iterator.Count == 0) { return ""; } try { iterator.MoveNext(); max = XmlConvert.ToTimeSpan(iterator.Current.Value); while(iterator.MoveNext()) { t = XmlConvert.ToTimeSpan(iterator.Current.Value); max = (t > max)? t : max; } } catch(FormatException) { return ""; } return XmlConvert.ToString(max); } #endregion #region date2:day-abbreviation() /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public string dayAbbreviation_RENAME_ME(string d, string c) { return dayAbbreviation(d, c); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public new string dayAbbreviation_RENAME_ME(string c) { return dayAbbreviation(c); } /// <summary> /// Implements the following function /// string date2:day-abbreviation(string) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-day-abbreviation.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The abbreviated current day name according to /// specified culture or the empty string if the culture isn't /// supported.</returns> public new string dayAbbreviation(string culture) { try { CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetAbbreviatedDayName(DateTime.Now.DayOfWeek); } catch (Exception) { return ""; } } /// <summary> /// Implements the following function /// string date2:day-abbreviation(string, string) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-day-abbreviation.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The abbreviated day name of the specified date according to /// specified culture or the empty string if the input date is invalid or /// the culture isn't supported.</returns> public string dayAbbreviation(string d, string culture) { try { DateTZ date = new DateTZ(d); CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetAbbreviatedDayName(date.d.DayOfWeek); } catch (Exception) { return ""; } } #endregion #region date2:day-name() /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public string dayName_RENAME_ME(string d, string c) { return dayName(d, c); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public new string dayName_RENAME_ME(string c) { return dayName(c); } /// <summary> /// Implements the following function /// string date2:day-name(string, string?) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-day-name.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The day name of the specified date according to /// specified culture or the empty string if the input date is invalid or /// the culture isn't supported.</returns> public string dayName(string d, string culture) { try { DateTZ date = new DateTZ(d); CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetDayName(date.d.DayOfWeek); } catch (Exception) { return ""; } } /// <summary> /// Implements the following function /// string date2:day-name(string, string?) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-day-name.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The day name of the current date according to /// specified culture or the empty string if /// the culture isn't supported.</returns> public new string dayName(string culture) { try { CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek); } catch (Exception) { return ""; } } #endregion #region date2:month-abbreviation() /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public string monthAbbreviation_RENAME_ME(string d, string c) { return monthAbbreviation(d, c); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public new string monthAbbreviation_RENAME_ME(string c) { return monthAbbreviation(c); } /// <summary> /// Implements the following function /// string date2:month-abbreviation(string) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-month-abbreviation.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The abbreviated current month name according to /// specified culture or the empty string if the culture isn't /// supported.</returns> public new string monthAbbreviation(string culture) { try { CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Now.Month); } catch (Exception) { return ""; } } /// <summary> /// Implements the following function /// string date2:month-abbreviation(string, string) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-month-abbreviation.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The abbreviated month name of the specified date according to /// specified culture or the empty string if the input date is invalid or /// the culture isn't supported.</returns> public string monthAbbreviation(string d, string culture) { try { DateTZ date = new DateTZ(d); CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetAbbreviatedMonthName(date.d.Month); } catch (Exception) { return ""; } } #endregion #region date2:month-name() /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public string monthName_RENAME_ME(string d, string c) { return monthName(d, c); } /// <summary> /// This wrapper method will be renamed during custom build /// to provide conformant EXSLT function name. /// </summary> public new string monthName_RENAME_ME(string c) { return monthName(c); } /// <summary> /// Implements the following function /// string date2:month-name(string, string?) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-month-name.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The month name of the specified date according to /// specified culture or the empty string if the input date is invalid or /// the culture isn't supported.</returns> public string monthName(string d, string culture) { try { DateTZ date = new DateTZ(d); CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetMonthName(date.d.Month); } catch (Exception) { return ""; } } /// <summary> /// Implements the following function /// string date2:month-name(string, string?) /// See http://www.xmland.net/exslt/doc/GDNDatesAndTimes-month-name.xml /// </summary> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> /// <returns>The month name of the current date according to /// specified culture or the empty string if /// the culture isn't supported.</returns> public new string monthName(string culture) { try { CultureInfo ci = new CultureInfo(culture); return ci.DateTimeFormat.GetMonthName(DateTime.Now.Month); } catch (Exception) { return ""; } } #endregion } } --- NEW FILE: PostBuildEvent.bat --- @echo off @echo ########### Setting environment variables call "D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\..\Tools\vsvars32.bat" nmake if errorlevel 1 goto CSharpReportError goto CSharpEnd :CSharpReportError echo Project error: A tool returned an error code from the build event exit 1 :CSharpEnd --- NEW FILE: ExsltTransform.cs --- #region using using System; using System.Xml.Xsl; using System.Xml; using System.Xml.XPath; using System.IO; using System.Text; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// Enumeration used to indicate an EXSLT function namespace. /// </summary> [Flags] public enum ExsltFunctionNamespace{ None = 0, Common = 1, DatesAndTimes = 2, Math = 4, RegularExpressions = 8, Sets = 16, Strings = 32, GDNDatesAndTimes = 64, GDNSets = 128, GDNMath = 256, GDNRegularExpressions = 512, GDNStrings = 1024, Random = 2048, GDNDynamic = 4096, AllExslt = Common | DatesAndTimes | Math | Random | RegularExpressions | Sets | Strings, All = Common | DatesAndTimes | Math | Random | RegularExpressions | Sets | Strings | GDNDatesAndTimes | GDNSets | GDNMath | GDNRegularExpressions | GDNStrings | GDNDynamic } /// <summary> /// Transforms XML data using an XSLT stylesheet. Supports a number of EXSLT as /// defined at http://www.exslt.org /// </summary> /// <remarks> /// XslTransform supports the XSLT 1.0 syntax. The XSLT stylesheet must use the /// namespace http://www.w3.org/1999/XSL/Transform. Additional arguments can also be /// added to the stylesheet using the XsltArgumentList class. /// This class contains input parameters for the stylesheet and extension objects which can be called from the stylesheet. /// This class also recognizes functions from the following namespaces /// * http://exslt.org/common /// * http://exslt.org/dates-and-times /// * http://exslt.org/math /// * http://exslt.org/random /// * http://exslt.org/regular-expressions /// * http://exslt.org/sets /// * http://exslt.org/strings /// * http://gotdotnet.com/exslt/dates-and-times /// * http://gotdotnet.com/exslt/math /// * http://gotdotnet.com/exslt/regular-expressions /// * http://gotdotnet.com/exslt/sets /// * http://gotdotnet.com/exslt/strings /// * http://gotdotnet.com/exslt/dynamic /// </remarks> public class ExsltTransform { #region Private Fields and Properties /// <summary> /// Sync object. /// </summary> private object sync = new object(); /// <summary> /// The XslTransform object wrapped by this class. /// </summary> private XslCompiledTransform xslTransform; /// <summary> /// Bitwise enumeration used to specify which EXSLT functions should be accessible to /// the ExsltTransform object. The default value is ExsltFunctionNamespace.All /// </summary> private ExsltFunctionNamespace _supportedFunctions = ExsltFunctionNamespace.All; /// <summary> /// Extension object which implements the functions in the http://exslt.org/math namespace /// </summary> private ExsltMath exsltMath = new ExsltMath(); /// <summary> /// Extension object which implements the functions in the http://exslt.org/random namespace /// </summary> private ExsltRandom exsltRandom = new ExsltRandom(); /// <summary> /// Extension object which implements the functions in the http://exslt.org/dates-and-times namespace /// </summary> private ExsltDatesAndTimes exsltDatesAndTimes = new ExsltDatesAndTimes(); /// <summary> /// Extension object which implements the functions in the http://exslt.org/regular-expressions namespace /// </summary> private ExsltRegularExpressions exsltRegularExpressions = new ExsltRegularExpressions(); /// <summary> /// Extension object which implements the functions in the http://exslt.org/strings namespace /// </summary> private ExsltStrings exsltStrings = new ExsltStrings(); /// <summary> /// Extension object which implements the functions in the http://exslt.org/sets namespace /// </summary> private ExsltSets exsltSets = new ExsltSets(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/dates-and-times namespace /// </summary> private GDNDatesAndTimes gdnDatesAndTimes = new GDNDatesAndTimes(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/regular-expressions namespace /// </summary> private GDNRegularExpressions gdnRegularExpressions = new GDNRegularExpressions(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/math namespace /// </summary> private GDNMath gdnMath = new GDNMath(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/sets namespace /// </summary> private GDNSets gdnSets = new GDNSets(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/strings namespace /// </summary> private GDNStrings gdnStrings = new GDNStrings(); /// <summary> /// Extension object which implements the functions in the http://gotdotnet.com/exslt/dynamic namespace /// </summary> private GDNDynamic gdnDynamic = new GDNDynamic(); /// <summary> /// Boolean flag used to specify whether multiple output is supported. /// </summary> private bool _multiOutput = false; #endregion #region Public Fields and Properties /// <summary> /// Sets the XmlResolver used to resolve external resources when the /// Transform method is called. /// </summary> public XmlResolver XmlResolver { set { this.xslTransform.XmlResolver = value; } } /// <summary> /// Bitwise enumeration used to specify which EXSLT functions should be accessible to /// the ExsltTransform object. The default value is ExsltFunctionNamespace.All /// </summary> public ExsltFunctionNamespace SupportedFunctions{ set { if (Enum.IsDefined(typeof(ExsltFunctionNamespace), value)) this._supportedFunctions = value; } get { return this._supportedFunctions; } } /// <summary> /// Boolean flag used to specify whether multiple output (via exsl:document) is /// supported. /// Note: This property is ignored (hence multiple output is not supported) when /// transformation is done to XmlReader or XmlWriter (use overloaded method, /// which transforms to MultiXmlTextWriter instead). /// Note: Because of some restrictions and slight overhead this feature is /// disabled by default. If you need multiple output support, set this property to /// true before the Transform() call. /// </summary> public bool MultiOutput { get { return _multiOutput; } set { _multiOutput = value; } } #endregion #region Constructors /// <summary> /// Constructor initializes class. /// </summary> public ExsltTransform(){ this.xslTransform = new XslCompiledTransform(); } #endregion #region Load() method Overloads /// <summary> Loads the XSLT stylesheet contained in the IXPathNavigable</summary> public void Load(IXPathNavigable ixn){ this.xslTransform.Load(ixn); } /// <summary> Loads the XSLT stylesheet specified by a URL</summary> public void Load(string s){ this.xslTransform.Load(s); } /// <summary> Loads the XSLT stylesheet contained in the XmlReader</summary> public void Load(XmlReader reader){ this.xslTransform.Load(reader); } /// <summary> Loads the XSLT stylesheet contained in the XPathNavigator</summary> public void Load(XPathNavigator navigator){ this.xslTransform.Load(navigator); } /// <summary> Loads the XSLT stylesheet contained in the IXPathNavigable</summary> public void Load(IXPathNavigable ixn, XmlResolver resolver){ this.xslTransform.Load(ixn, resolver); } /// <summary> Loads the XSLT stylesheet specified by a URL</summary> public void Load(string s, XmlResolver resolver){ this.xslTransform.Load(s, resolver); } /// <summary> Loads the XSLT stylesheet contained in the XmlReader</summary> public void Load(XmlReader reader, XmlResolver resolver){ this.xslTransform.Load(reader, resolver); } /// <summary> Loads the XSLT stylesheet contained in the XPathNavigator</summary> public void Load(XPathNavigator navigator, XmlResolver resolver) {this.xslTransform.Load(navigator, resolver); } #endregion #region Transform() method Overloads /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to an XmlReader</summary> public XmlReader Transform(IXPathNavigable ixn, XsltArgumentList arglist) { return this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist)); } /// <summary> Transforms the XML data in the input file and outputs the result to an output file</summary> public void Transform(string infile, string outfile) { // Use using so that the file is not held open after the call using (StreamWriter outStream = new StreamWriter(outfile)) { if (_multiOutput) this.xslTransform.Transform(new XPathDocument(infile), this.AddExsltExtensionObjects(null), new MultiXmlTextWriter(outStream)); else this.xslTransform.Transform(new XPathDocument(infile), this.AddExsltExtensionObjects(null), outStream); } } /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an XmlReader</summary> public XmlReader Transform(XPathNavigator navigator, XsltArgumentList arglist) { return this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist)); } /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to a Stream</summary> public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, Stream stream) { if (_multiOutput) this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), new MultiXmlTextWriter(stream, Encoding.UTF8)); else this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), stream); } /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to a TextWriter</summary> public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, TextWriter writer) { if (_multiOutput) this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), new MultiXmlTextWriter(writer)); else this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), writer); } /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to an XmlWriter</summary> public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, XmlWriter writer) { this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), writer); } /// <summary> Transforms the XML data in the IXPathNavigable using the specified args and outputs the result to an MultiXmlTextWriter</summary> public void Transform(IXPathNavigable ixn, XsltArgumentList arglist, MultiXmlTextWriter writer) { this.xslTransform.Transform(ixn, this.AddExsltExtensionObjects(arglist), writer); } /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to a Stream</summary> public void Transform(XPathNavigator navigator, XsltArgumentList arglist, Stream stream) { if (_multiOutput) this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), new MultiXmlTextWriter(stream, Encoding.UTF8)); else this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), stream); } /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to a TextWriter</summary> public void Transform(XPathNavigator navigator, XsltArgumentList arglist, TextWriter writer) { if (_multiOutput) this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), new MultiXmlTextWriter(writer)); else this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); } /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an XmlWriter</summary> public void Transform(XPathNavigator navigator, XsltArgumentList arglist, XmlWriter writer) { this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); } /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an MultiXmlTextWriter</summary> public void Transform(XPathNavigator navigator, XsltArgumentList arglist, MultiXmlTextWriter writer) { this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); } #endregion #region Public Methods #endregion #region Private Methods /// <summary> /// Adds the objects that implement the EXSLT extensions to the provided argument /// list. The extension objects added depend on the value of the SupportedFunctions /// property. /// </summary> /// <param name="list">The argument list</param> /// <returns>An XsltArgumentList containing the contents of the list passed in /// and objects that implement the EXSLT. </returns> /// <remarks>If null is passed in then a new XsltArgumentList is constructed. </remarks> private XsltArgumentList AddExsltExtensionObjects(XsltArgumentList list){ if(list == null){ list = new XsltArgumentList(); } lock (sync) { //remove all our extension objects in case the XSLT argument list is being reused list.RemoveExtensionObject(ExsltNamespaces.Common); list.RemoveExtensionObject(ExsltNamespaces.Math); list.RemoveExtensionObject(ExsltNamespaces.Random); list.RemoveExtensionObject(ExsltNamespaces.DatesAndTimes); list.RemoveExtensionObject(ExsltNamespaces.RegularExpressions); list.RemoveExtensionObject(ExsltNamespaces.Strings); list.RemoveExtensionObject(ExsltNamespaces.Sets); list.RemoveExtensionObject(ExsltNamespaces.GDNDatesAndTimes); list.RemoveExtensionObject(ExsltNamespaces.GDNMath); list.RemoveExtensionObject(ExsltNamespaces.GDNRegularExpressions); list.RemoveExtensionObject(ExsltNamespaces.GDNSets); list.RemoveExtensionObject(ExsltNamespaces.GDNStrings); list.RemoveExtensionObject(ExsltNamespaces.GDNDynamic); //add extension objects as specified by SupportedFunctions if((this.SupportedFunctions & ExsltFunctionNamespace.Common) > 0) { list.AddExtensionObject(ExsltNamespaces.Common, this.exsltCommon); } if((this.SupportedFunctions & ExsltFunctionNamespace.Math) > 0) { list.AddExtensionObject(ExsltNamespaces.Math, this.exsltMath); } if((this.SupportedFunctions & ExsltFunctionNamespace.Random) > 0) { list.AddExtensionObject(ExsltNamespaces.Random, this.exsltRandom); } if((this.SupportedFunctions & ExsltFunctionNamespace.DatesAndTimes) > 0) { list.AddExtensionObject(ExsltNamespaces.DatesAndTimes, this.exsltDatesAndTimes); } if((this.SupportedFunctions & ExsltFunctionNamespace.RegularExpressions) > 0) { list.AddExtensionObject(ExsltNamespaces.RegularExpressions, this.exsltRegularExpressions); } if((this.SupportedFunctions & ExsltFunctionNamespace.Strings) > 0) { list.AddExtensionObject(ExsltNamespaces.Strings, this.exsltStrings); } if((this.SupportedFunctions & ExsltFunctionNamespace.Sets) > 0) { list.AddExtensionObject(ExsltNamespaces.Sets, this.exsltSets); } if((this.SupportedFunctions & ExsltFunctionNamespace.GDNDatesAndTimes) > 0) { list.AddExtensionObject(ExsltNamespaces.GDNDatesAndTimes, this.gdnDatesAndTimes); } if((this.SupportedFunctions & ExsltFunctionNamespace.GDNMath) > 0) { list.AddExtensionObject(ExsltNamespaces.GDNMath, this.gdnMath); } if((this.SupportedFunctions & ExsltFunctionNamespace.GDNRegularExpressions) > 0) { list.AddExtensionObject(ExsltNamespaces.GDNRegularExpressions, this.gdnRegularExpressions); } if((this.SupportedFunctions & ExsltFunctionNamespace.GDNSets) > 0) { list.AddExtensionObject(ExsltNamespaces.GDNSets, this.gdnSets); } if((this.SupportedFunctions & ExsltFunctionNamespace.GDNStrings) > 0) { list.AddExtensionObject(ExsltNamespaces.GDNStrings, this.gdnStrings); } if((this.SupportedFunctions & ExsltFunctionNamespace.GDNDynamic) > 0) { list.AddExtensionObject(ExsltNamespaces.GDNDynamic, this.gdnDynamic); } } return list; } #endregion } } --- NEW FILE: GDNMath.cs --- #region using using System; using System.Xml; using System.Xml.XPath; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements addditional functions in the http://gotdotnet.com/exslt/math namespace. /// </summary> public class GDNMath { /// <summary> /// Implements the following function /// number avg(node-set) /// </summary> /// <param name="iterator"></param> /// <returns>The average of all the value of all the nodes in the /// node set</returns> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public double avg(XPathNodeIterator iterator) { double sum = 0; int count = iterator.Count; if(count == 0) { return Double.NaN; } try { while(iterator.MoveNext()) { sum += XmlConvert.ToDouble(iterator.Current.Value); } } catch(FormatException) { return Double.NaN; } return sum / count; } } } --- NEW FILE: ExsltNodeList.cs --- #region using using System; using System.Collections.Generic; using System.Xml.XPath; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// A list that holds XPathNavigator objects /// </summary> internal class ExsltNodeList { #region Private Fields and Properties /// <summary> /// The inner arraylist used by this class. /// </summary> internal IList<XPathNavigator> innerList = new List<XPathNavigator>(); #endregion #region Public Fields and Properties /// <summary> /// Gets or sets the element at the specified index /// </summary> public XPathNavigator this[int index] { get {return (XPathNavigator) this.innerList[index];} set { this.innerList[index] = value; } } /// <summary> /// Gets the number of items in the list /// </summary> public int Count {get { return this.innerList.Count;}} #endregion #region Constructors public ExsltNodeList(){} /// <summary> /// Initializes the ExsltNodeList with the specified XPathNodeIterator. All nodes /// in the iterator are placed in the list. /// </summary> /// <param name="iterator">The iterator to load the nodelist from</param> public ExsltNodeList(XPathNodeIterator iterator): this(iterator, false) {} /// <summary> /// Initializes the ExsltNodeList with the specified XPathNodeIterator. All nodes /// in the iterator are placed in the list. /// </summary> /// <param name="iterator">The iterator to load the nodelist from</param> /// <param name="removeDuplicates">A flag that indicates whether duplicate nodes /// should be loaded into the nodelist or only node with unique identity should /// be added</param> public ExsltNodeList(XPathNodeIterator iterator, bool removeDuplicates){ XPathNodeIterator it = iterator.Clone(); while(it.MoveNext()){ if(removeDuplicates){ if(this.Contains(it.Current)){ continue; } } this.Add(it.Current.Clone()); } } #endregion #region Public Methods /// <summary> /// Returns an enumerator for the entire list. /// </summary> /// <returns>An enumerator for the entire list</returns> public IEnumerator<XPathNavigator> GetEnumerator(){ return this.innerList.GetEnumerator(); } /// <summary> /// Adds an item to the list /// </summary> /// <param name="value">The item to add</param> public void Add( XPathNavigator nav){ this.innerList.Add(nav); } /// <summary> /// Removes all items from the list. /// </summary> public void Clear(){ this.innerList.Clear(); } /// <summary> /// Determines whether the list contains a navigator positioned at the same /// location as the specified XPathNavigator. This /// method relies on the IsSamePositon() method of the XPathNavightor. /// </summary> /// <param name="value">The object to locate in the list.</param> /// <returns>true if the object is found in the list; otherwise, false.</returns> public bool Contains(XPathNavigator value){ foreach(XPathNavigator nav in this.innerList){ if(nav.IsSamePosition(value)){ return true; } } return false; } /// <summary> /// Determines whether the list contains a navigator whose Value property matches /// the target value /// </summary> /// <param name="value">The value to locate in the list.</param> /// <returns>true if the value is found in the list; otherwise, false.</returns> public bool ContainsValue(string value){ foreach(XPathNavigator nav in this.innerList){ if(nav.Value.Equals(value)){ return true; } } return false; } /// <summary> /// Determines the index of a specific item in the list. /// </summary> /// <param name="value">The object to locate in the list</param> /// <returns>The index of value if found in the list; otherwise, -1.</returns> public int IndexOf( object value ){ return this.innerList.IndexOf(value as XPathNavigator); } /// <summary> /// Inserts an item to the list at the specified position. /// </summary> /// <param name="index">The zero-based index at which value should be inserted. </param> /// <param name="value">The object to insert into the list</param> public void Insert(int index,XPathNavigator nav ){ this.innerList.Insert(index, nav); } /// <summary> /// Removes the first occurrence of a specific object from the list. /// </summary> /// <param name="value">The object to remove from the list.</param> public void Remove(XPathNavigator nav){ for(int i = 0; i < this.Count; i++){ if(nav.IsSamePosition((XPathNavigator) this.innerList[i])){ this.innerList.RemoveAt(i); return; } } } /// <summary> /// Removes the list item at the specified index. /// </summary> /// <param name="index">The zero-based index of the item to remove.</param> public void RemoveAt(int index){ this.innerList.RemoveAt(index); } #endregion } } --- NEW FILE: .cvsignore --- bin obj *.user *.suo *.vspscc --- NEW FILE: uninstall.cmd --- gacutil /u Mvp.Xml.Exslt --- NEW FILE: ExsltMath.cs --- #region using using System; using System.Xml; using System.Xml.XPath; using System.Collections.Generic; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements the EXSLT functions in the http://exslt.org/math namespace. /// </summary> public class ExsltMath { /// <summary> /// Implements the following function /// number min(node-set) /// </summary> /// <param name="iterator"></param> /// <returns></returns> public double min(XPathNodeIterator iterator){ double min, t; if(iterator.Count == 0){ return Double.NaN; } try{ iterator.MoveNext(); min = XmlConvert.ToDouble(iterator.Current.Value); while(iterator.MoveNext()){ t = XmlConvert.ToDouble(iterator.Current.Value); min = (t < min)? t : min; } }catch(Exception){ return Double.NaN; } return min; } /// <summary> /// Implements the following function /// number max(node-set) /// </summary> /// <param name="iterator"></param> /// <returns></returns> public double max(XPathNodeIterator iterator){ double max, t; if(iterator.Count == 0){ return Double.NaN; } try{ iterator.MoveNext(); max = XmlConvert.ToDouble(iterator.Current.Value); while(iterator.MoveNext()){ t = XmlConvert.ToDouble(iterator.Current.Value); max = (t > max)? t : max; } }catch(Exception){ return Double.NaN; } return max; } /// <summary> /// Implements the following function /// node-set highest(node-set) /// </summary> /// <param name="iterator">The input nodeset</param> /// <returns>All the nodes that contain the max value in the nodeset</returns> public XPathNodeIterator highest(XPathNodeIterator iterator){ ExsltNodeList newList = new ExsltNodeList(); double max, t; if(iterator.Count == 0){ return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); } try{ iterator.MoveNext(); max = XmlConvert.ToDouble(iterator.Current.Value); newList.Add(iterator.Current.Clone()); while (iterator.MoveNext()){ t = XmlConvert.ToDouble(iterator.Current.Value); if(t > max){ max = t; newList.Clear(); newList.Add(iterator.Current.Clone()); }else if( t == max){ newList.Add(iterator.Current.Clone()); } } }catch(Exception){ //return empty node set newList.Clear(); return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); } return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); } /// <summary> /// Implements the following function /// node-set lowest(node-set) /// </summary> /// <param name="iterator">The input nodeset</param> /// <returns>All the nodes that contain the min value in the nodeset</returns> public XPathNodeIterator lowest(XPathNodeIterator iterator){ IList<XPathNavigator> newList = new List<XPathNavigator>(); double min, t; if(iterator.Count == 0){ return newList; } try{ iterator.MoveNext(); min = XmlConvert.ToDouble(iterator.Current.Value); newList.Add(iterator.Current.Clone()); while (iterator.MoveNext()){ t = XmlConvert.ToDouble(iterator.Current.Value); if(t < min){ min = t; newList.Clear(); newList.Add(iterator.Current.Clone()); }else if( t == min){ newList.Add(iterator.Current.Clone()); } } }catch(Exception){ //return empty node set newList.Clear(); return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); } return ExsltCommon.ExsltNodeListToXPathNodeIterator(newList); } /// <summary> /// Implements the following function /// number abs(number) /// </summary> /// <param name="number"></param> /// <returns></returns> public double abs(double number){ return Math.Abs(number); } /// <summary> /// Implements the following function /// number sqrt(number) /// </summary> /// <param name="number"></param> /// <returns></returns> public double sqrt(double number){ if (number < 0) return 0; return Math.Sqrt(number); } /// <summary> /// Implements the following function /// number power(number, number) /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public double power(double x, double y){ return Math.Pow(x, y); } /// <summary> /// Implements the following function /// number log(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double log(double x){ return Math.Log(x); } /// <summary> /// Implements the following function /// number constant(string, number) /// </summary> /// <param name="number"></param> /// <returns>The specified constant or NaN</returns> /// <remarks>This method only supports the constants /// E and PI. Also the precision parameter is ignored.</remarks> public double constant(string c, double precision){ switch(c.ToUpper()) { case "E": return Math.E; case "PI": return Math.PI; case "SQRRT2" : return Math.Sqrt(2); case "LN2" : return Math.Log(2); case "LN10" : return Math.Log(10); case "LOG2E" : return Math.Log(Math.E, 2); case "SQRT1_2" : return Math.Sqrt(.5); default: return Double.NaN; } } /// <summary> /// Implements the following function /// number random() /// </summary> /// <param name="x"></param> /// <returns></returns> public double random(){ Random rand = new Random((int) DateTime.Now.Ticks); return rand.NextDouble(); } /// <summary> /// Implements the following function /// number sin(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double sin(double x){ return Math.Sin(x); } /// <summary> /// Implements the following function /// number asin(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double asin(double x){ return Math.Asin(x); } /// <summary> /// Implements the following function /// number cos(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double cos(double x){ return Math.Cos(x); } /// <summary> /// Implements the following function /// number acos(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double acos(double x){ return Math.Acos(x); } /// <summary> /// Implements the following function /// number tan(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double tan(double x){ return Math.Tan(x); } /// <summary> /// Implements the following function /// number atan(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double atan(double x){ return Math.Atan(x); } /// <summary> /// Implements the following function /// number atan2(number, number) /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public double atan2(double x, double y){ return Math.Atan2(x,y); } /// <summary> /// Implements the following function /// number exp(number) /// </summary> /// <param name="x"></param> /// <returns></returns> public double exp(double x){ return Math.Exp(x); } } } --- NEW FILE: MethodRenamer.exe.config --- (This appears to be a binary file; contents omitted.) --- NEW FILE: GDNRegularExpressions.cs --- #region using using System; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements additional functions in the http://gotdotnet.com/exslt/regular-expressions namespace. /// </summary> public class GDNRegularExpressions { /// <summary> /// Implements the following function /// node-set tokenize(string, string) /// </summary> /// <param name="str"></param> /// <param name="regexp"></param> /// <returns>This function breaks the input string into a sequence of strings, /// treating any substring that matches the regexp as a separator. /// The separators themselves are not returned. /// The matching strings are returned as a set of 'match' elements.</returns> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public XPathNodeIterator tokenize(string str, string regexp) { RegexOptions options = RegexOptions.ECMAScript; XmlDocument doc = new XmlDocument(); doc.LoadXml("<matches/>"); Regex regex = new Regex(regexp, options); foreach(string match in regex.Split(str)) { XmlElement elem = doc.CreateElement("match"); elem.InnerText = match; doc.DocumentElement.AppendChild(elem); } return doc.CreateNavigator().Select("//match"); } /// <summary> /// Implements the following function /// node-set tokenize(string, string, string) /// </summary> /// <param name="str"></param> /// <param name="regexp"></param> /// <param name="flags"></param> /// <returns>This function breaks the input string into a sequence of strings, /// treating any substring that matches the regexp as a separator. /// The separators themselves are not returned. /// The matching strings are returned as a set of 'match' elements.</returns> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public XPathNodeIterator tokenize(string str, string regexp, string flags) { RegexOptions options = RegexOptions.ECMAScript; if(flags.IndexOf("m")!= -1) { options |= RegexOptions.Multiline; } if(flags.IndexOf("i")!= -1) { options |= RegexOptions.IgnoreCase; } XmlDocument doc = new XmlDocument(); doc.LoadXml("<matches/>"); Regex regex = new Regex(regexp, options); foreach(string match in regex.Split(str)) { XmlElement elem = doc.CreateElement("match"); elem.InnerText = match; doc.DocumentElement.AppendChild(elem); } return doc.CreateNavigator().Select("//match"); } } } --- NEW FILE: AssemblyInfo.cs --- using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("Mvp.Xml.Exslt")] [assembly: AssemblyDescription("MVP XML Library - EXSLT.NET Module")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: CLSCompliant(true)] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("2.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] //Signed in custom build - see Makefile //[assembly: AssemblyKeyFile("exslt.snk")] [assembly: AssemblyKeyName("")] --- NEW FILE: install.cmd --- gacutil /if Mvp.Xml.Exslt.dll --- NEW FILE: GDNSets.cs --- #region using using System; using System.Collections; using System.Xml.XPath; using System.Xml; #endregion namespace Mvp.Xml.Exslt { /// <summary> /// This class implements additional functions in the http://gotdotnet.com/exslt/sets namespace. /// </summary> public class GDNSets { /// <summary> /// Implements the following function /// boolean subset(node-set, node-set) /// </summary> /// <param name="nodeset1">An input nodeset</param> /// <param name="nodeset2">Another input nodeset</param> /// <returns>True if all the nodes in the first nodeset are contained /// in the second nodeset</returns> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public bool subset(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2) { if(nodeset1.Count > 125 || nodeset2.Count > 125) return subset2(nodeset1, nodeset2); //else ExsltNodeList nodelist1 = new ExsltNodeList(nodeset1, true); ExsltNodeList nodelist2 = new ExsltNodeList(nodeset2, true); foreach(XPathNavigator nav in nodelist1) { if(!nodelist2.Contains(nav)) { return false; } } return true; } /// <summary> /// Implements the following function /// boolean subset(node-set, node-set) /// This is an optimized version, using document identification /// and binary search techniques. /// </summary> /// <param name="nodeset1">An input nodeset</param> /// <param name="nodeset2">Another input nodeset</param> /// <returns>True if all the nodes in the first nodeset are contained /// in the second nodeset</returns> /// <author>Dimitre Novatchev</author> /// <remarks>THIS FUNCTION IS NOT PART OF EXSLT!!!</remarks> public bool subset2(XPathNodeIterator nodeset1, XPathNodeIterator nodeset2) { ArrayList arDocs = new ArrayList(); ArrayList arNodes2 = new ArrayList(nodeset2.Count); while(nodeset2.MoveNext()) { arNodes2.Add(nodeset2.Current.Clone()); } auxEXSLT.findDocs(arNodes2, arDocs); while(nodeset1.MoveNext()) { XPathNavigator currNode = nodeset1.Current; if(!auxEXSLT.findNode(arNodes2, arDocs, currNode) ) return... [truncated message content] |
From: Oleg T. <he...@us...> - 2005-10-16 20:06:21
|
Update of /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/MultiOutput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12767/MultiOutput Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/src/Exslt/MultiOutput added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 19:52:49
|
Update of /cvsroot/mvp-xml/EXSLT/v2/src/MethodRenamer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9671/MethodRenamer Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/src/MethodRenamer added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 19:52:49
|
Update of /cvsroot/mvp-xml/EXSLT/v2/src/Exslt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9671/Exslt Log Message: Directory /cvsroot/mvp-xml/EXSLT/v2/src/Exslt added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 16:52:18
|
Update of /cvsroot/mvp-xml/Common/v2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3450/v2 Added Files: Common.sln Log Message: --- NEW FILE: Common.sln --- Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "src\Common.csproj", "{12B8D3E3-4362-4E91-A3D2-37473083B47A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonTest", "test\CommonTest.csproj", "{17955FFF-E5FC-43B8-B390-86E370658CB1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E8818B26-3C1E-4175-BE5B-8BBF1940F55A}" ProjectSection(SolutionItems) = preProject license.txt = license.txt EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {12B8D3E3-4362-4E91-A3D2-37473083B47A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {12B8D3E3-4362-4E91-A3D2-37473083B47A}.Debug|Any CPU.Build.0 = Debug|Any CPU {12B8D3E3-4362-4E91-A3D2-37473083B47A}.Release|Any CPU.ActiveCfg = Release|Any CPU {12B8D3E3-4362-4E91-A3D2-37473083B47A}.Release|Any CPU.Build.0 = Release|Any CPU {17955FFF-E5FC-43B8-B390-86E370658CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {17955FFF-E5FC-43B8-B390-86E370658CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU {17955FFF-E5FC-43B8-B390-86E370658CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {17955FFF-E5FC-43B8-B390-86E370658CB1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal |
From: Oleg T. <he...@us...> - 2005-10-16 16:51:38
|
Update of /cvsroot/mvp-xml/Common/v1/src/XPath In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3371/v2/src/XPath Modified Files: DynamicContext.cs IndexingXPathNavigator.cs SubtreeeXPathNavigator.cs XPathCache.cs XPathIteratorReader.cs Log Message: Index: SubtreeeXPathNavigator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/SubtreeeXPathNavigator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SubtreeeXPathNavigator.cs 28 May 2005 20:14:41 -0000 1.2 +++ SubtreeeXPathNavigator.cs 16 Oct 2005 16:51:24 -0000 1.3 @@ -176,7 +176,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.Value"/>. + /// See <see cref="XPathItem.Value"/>. /// </summary> public override string Value { @@ -276,7 +276,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.MoveToNext"/>. + /// See <see cref="XPathNavigator.MoveToNext()"/>. /// </summary> public override bool MoveToNext() { @@ -401,7 +401,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.MoveToFirstNamespace"/>. + /// See <see cref="XPathNavigator.MoveToFirstNamespace(XPathNamespaceScope)"/>. /// </summary> public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { @@ -409,7 +409,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.MoveToNextNamespace"/>. + /// See <see cref="XPathNavigator.MoveToNextNamespace(XPathNamespaceScope)"/>. /// </summary> public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { Index: XPathCache.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/XPathCache.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XPathCache.cs 28 May 2005 20:14:41 -0000 1.3 +++ XPathCache.cs 16 Oct 2005 16:51:24 -0000 1.4 @@ -319,7 +319,7 @@ /// Selects a node set using the specified XPath expression and sort. /// </summary> /// <remarks> - /// See <see cref="XPathExpression.AddSort"/>. + /// See <see cref="XPathExpression.AddSort(object, IComparer)"/>. /// </remarks> public static XPathNodeIterator SelectSorted(string expression, XPathNavigator source, object sortExpression, IComparer comparer) @@ -333,7 +333,7 @@ /// Selects a node set using the specified XPath expression and sort. /// </summary> /// <remarks> - /// See <see cref="XPathExpression.AddSort"/>. + /// See <see cref="XPathExpression.AddSort(object, IComparer)"/>. /// </remarks> public static XPathNodeIterator SelectSorted(string expression, XPathNavigator source, object sortExpression, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType ) @@ -531,7 +531,7 @@ /// Selects a node set using the specified XPath expression and sort. /// </summary> /// <remarks> - /// See <see cref="XPathExpression.AddSort"/>. + /// See <see cref="XPathExpression.AddSort(object, IComparer)"/>. /// </remarks> public static XmlNodeList SelectNodesSorted(string expression, XmlNode source, object sortExpression, IComparer comparer) @@ -544,7 +544,7 @@ /// Selects a node set using the specified XPath expression and sort. /// </summary> /// <remarks> - /// See <see cref="XPathExpression.AddSort"/>. + /// See <see cref="XPathExpression.AddSort(object, IComparer)"/>. /// </remarks> public static XmlNodeList SelectNodesSorted(string expression, XmlNode source, object sortExpression, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType ) Index: XPathIteratorReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/XPathIteratorReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XPathIteratorReader.cs 28 May 2005 20:14:41 -0000 1.2 +++ XPathIteratorReader.cs 16 Oct 2005 16:51:24 -0000 1.3 @@ -143,19 +143,19 @@ get { return _current.IsEmptyElement; } } - /// <summary>See <see cref="XmlReader.this"/></summary> + /// <summary>See <see cref="XmlReader.this[string, string]"/></summary> public override string this[string name, string ns] { get { return _current[name, ns]; } } - /// <summary>See <see cref="XmlReader.this"/></summary> + /// <summary>See <see cref="XmlReader.this[string]"/></summary> public override string this[string name] { get { return _current[name, String.Empty]; } } - /// <summary>See <see cref="XmlReader.this"/></summary> + /// <summary>See <see cref="XmlReader.this[int]"/></summary> public override string this[int i] { get { return _current[i]; } @@ -238,19 +238,19 @@ _current.Close(); } - /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> + /// <summary>See <see cref="XmlReader.GetAttribute(string, string)"/></summary> public override string GetAttribute(string name, string ns) { return _current.GetAttribute(name, ns); } - /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> + /// <summary>See <see cref="XmlReader.GetAttribute(string)"/></summary> public override string GetAttribute(string name) { return _current.GetAttribute(name); } - /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> + /// <summary>See <see cref="XmlReader.GetAttribute(int)"/></summary> public override string GetAttribute(int i) { return _current.GetAttribute(i); @@ -262,19 +262,19 @@ return _current.LookupNamespace(prefix); } - /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> + /// <summary>See <see cref="XmlReader.MoveToAttribute(string, string)"/></summary> public override bool MoveToAttribute(string name, string ns) { return _current.MoveToAttribute(name, ns); } - /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> + /// <summary>See <see cref="XmlReader.MoveToAttribute(string)"/></summary> public override bool MoveToAttribute(string name) { return _current.MoveToAttribute(name); } - /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> + /// <summary>See <see cref="XmlReader.MoveToAttribute(int)"/></summary> public override void MoveToAttribute(int i) { _current.MoveToAttribute(i); @@ -318,7 +318,7 @@ if (read) { // Just move to the next node and create the reader. - _current = new XPathNavigatorReader(_iterator.Current); + _current = _iterator.Current.ReadSubtree(); return _current.Read(); } else @@ -464,20 +464,20 @@ { get { return false; } } - - /// <summary>See <see cref="XmlReader.this"/></summary> + + /// <summary>See <see cref="XmlReader.this[string, string]"/></summary> public override string this[string name, string ns] { get { return null; } } - /// <summary>See <see cref="XmlReader.this"/></summary> + /// <summary>See <see cref="XmlReader.this[string]"/></summary> public override string this[string name] { get { return null; } } - /// <summary>See <see cref="XmlReader.this"/></summary> + /// <summary>See <see cref="XmlReader.this[string]"/></summary> public override string this[int i] { get { return null; } @@ -559,19 +559,19 @@ _state = ReadState.Closed; } - /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> + /// <summary>See <see cref="XmlReader.GetAttribute(string, string)"/></summary> public override string GetAttribute(string name, string ns) { return null; } - /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> + /// <summary>See <see cref="XmlReader.GetAttribute(string)"/></summary> public override string GetAttribute(string name) { return null; } - /// <summary>See <see cref="XmlReader.GetAttribute"/></summary> + /// <summary>See <see cref="XmlReader.GetAttribute(int)"/></summary> public override string GetAttribute(int i) { return null; @@ -583,19 +583,19 @@ return null; } - /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> + /// <summary>See <see cref="XmlReader.MoveToAttribute(string, string)"/></summary> public override bool MoveToAttribute(string name, string ns) { return false; } - /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> + /// <summary>See <see cref="XmlReader.MoveToAttribute(string)"/></summary> public override bool MoveToAttribute(string name) { return false; } - /// <summary>See <see cref="XmlReader.MoveToAttribute"/></summary> + /// <summary>See <see cref="XmlReader.MoveToAttribute(int)"/></summary> public override void MoveToAttribute(int i) { } Index: IndexingXPathNavigator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/IndexingXPathNavigator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IndexingXPathNavigator.cs 28 May 2005 20:14:41 -0000 1.2 +++ IndexingXPathNavigator.cs 16 Oct 2005 16:51:24 -0000 1.3 @@ -1,7 +1,7 @@ #region using using System; -using System.Collections; +using System.Collections.Generic; using System.Xml; using System.Xml.XPath; using System.Xml.Xsl; @@ -150,7 +150,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.Value"/>. + /// See <see cref="XPathItem.Value"/>. /// </summary> public override string Value { @@ -246,7 +246,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.MoveToFirstNamespace"/>. + /// See <see cref="XPathNavigator.MoveToFirstNamespace(XPathNamespaceScope)"/>. /// </summary> public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { @@ -254,7 +254,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.MoveToNextNamespace"/>. + /// See <see cref="XPathNavigator.MoveToNextNamespace(XPathNamespaceScope)"/>. /// </summary> public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { @@ -262,7 +262,7 @@ } /// <summary> - /// See <see cref="XPathNavigator.MoveToNext"/>. + /// See <see cref="XPathNavigator.MoveToNext()"/>. /// </summary> public override bool MoveToNext() { @@ -585,8 +585,8 @@ /// </summary> private class XPathNavigatorIndex { - private ArrayList keys; - private Hashtable index; + private IList<KeyDef> keys; + private IDictionary<string, List<XPathNavigator>> index; private Type arrayIteratorType; /// <summary> @@ -594,8 +594,8 @@ /// </summary> public XPathNavigatorIndex() { - keys = new ArrayList(); - index = new Hashtable(); + keys = new List<KeyDef>(); + index = new Dictionary<string, List<XPathNavigator>>(); Assembly systemXml = typeof(XPathNodeIterator).Assembly; // TODO: is there another way? arrayIteratorType = systemXml.GetType("System.Xml.XPath.XPathArrayIterator"); @@ -624,27 +624,27 @@ //converted to a string as if by a call to the string function; it //returns a node-set containing the nodes in the same document as //the context node that have a value for the named key equal to this string. - ArrayList indexedNodes = null; + List<XPathNavigator> indexedNodes = null; if (keyValue is XPathNodeIterator) { XPathNodeIterator nodes = keyValue as XPathNodeIterator; while (nodes.MoveNext()) - { - ArrayList chunkOfIndexedNodes = (ArrayList)index[nodes.Current.Value]; + { + IList<XPathNavigator> chunkOfIndexedNodes = index[nodes.Current.Value]; if (chunkOfIndexedNodes != null) { if (indexedNodes == null) - indexedNodes = new ArrayList(); + indexedNodes = new List<XPathNavigator>(); indexedNodes.AddRange(chunkOfIndexedNodes); } } } else { - indexedNodes = (ArrayList)index[keyValue.ToString()]; + indexedNodes = index[keyValue.ToString()]; } if (indexedNodes == null) - indexedNodes = new ArrayList(0); + indexedNodes = new List<XPathNavigator>(0); return (XPathNodeIterator) Activator.CreateInstance( arrayIteratorType, BindingFlags.Instance | BindingFlags.Public | @@ -691,10 +691,10 @@ private void AddNodeToIndex(XPathNavigator node, string key) { //Get slot - ArrayList indexedNodes = (ArrayList)index[key]; + List<XPathNavigator> indexedNodes = index[key]; if (indexedNodes == null) { - indexedNodes = new ArrayList(); + indexedNodes = new List<XPathNavigator>(); index.Add(key, indexedNodes); } indexedNodes.Add(node.Clone()); @@ -710,7 +710,7 @@ /// </summary> private class XPathNavigatorIndexManager { - private Hashtable indexes; + private IDictionary<string, XPathNavigatorIndex> indexes; private XPathNavigator nav; private bool indexed; @@ -726,8 +726,8 @@ this.nav = nav; //Named indexes are stored in a hashtable. if (indexes == null) - indexes = new Hashtable(); - XPathNavigatorIndex index = (XPathNavigatorIndex)indexes[indexName]; + indexes = new Dictionary<string, XPathNavigatorIndex>(); + XPathNavigatorIndex index = indexes[indexName]; if (index == null) { index = new XPathNavigatorIndex(); @@ -790,7 +790,7 @@ { if (!indexed) BuildIndexes(); - XPathNavigatorIndex index = (XPathNavigatorIndex)indexes[indexName]; + XPathNavigatorIndex index = indexes[indexName]; return index == null? null : index.GetNodes(value); } } Index: DynamicContext.cs =================================================================== RCS file: /cvsroot/mvp-xml/Common/v1/src/XPath/DynamicContext.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- DynamicContext.cs 28 May 2005 20:14:41 -0000 1.2 +++ DynamicContext.cs 16 Oct 2005 16:51:24 -0000 1.3 @@ -1,7 +1,7 @@ #region using using System; -using System.Collections; +using System.Collections.Generic; using System.Reflection; using System.Text; using System.Xml; @@ -25,7 +25,7 @@ { #region Private vars - Hashtable _variables = new Hashtable(); + IDictionary<string, DynamicVariable> _variables = new Dictionary<string, DynamicVariable>(); #endregion Private @@ -84,7 +84,7 @@ #region Common Overrides /// <summary> - /// Implementation equal to <see cref="XsltCompileContext"/>. + /// Implementation equal to <see cref="XsltContext.CompareDocument(string, string)"/>. /// </summary> public override int CompareDocument(string baseUri, string nextbaseUri) { @@ -116,7 +116,7 @@ } /// <summary> - /// Same as <see cref="XsltCompileContext"/>. + /// Same as <see cref="XsltContext.PreserveWhitespace(XPathNavigator)"/>. /// </summary> public override bool PreserveWhitespace(XPathNavigator node) { @@ -124,7 +124,7 @@ } /// <summary> - /// Same as <see cref="XsltCompileContext"/>. + /// Same as <see cref="XsltContext.Whitespace"/>. /// </summary> public override bool Whitespace { |
From: Oleg T. <he...@us...> - 2005-10-16 16:51:38
|
Update of /cvsroot/mvp-xml/Common/v2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3371/v2/src Added Files: .cvsignore AssemblyInfo.cs Common.csproj SR.cs SR.resx XmlBaseAwareXmlTextReader.cs XmlFirstLowerWriter.cs XmlFirstUpperReader.cs XmlNamespaces.cs XmlNodeListFactory.cs XmlPrefix.cs changelog.txt Log Message: --- NEW FILE: XmlNodeListFactory.cs --- #region using using System; using System.Collections; using System.Xml; using System.Xml.XPath; #endregion using namespace Mvp.Xml.Common { /// <summary> /// Constructs <see cref="XmlNodeList"/> instances from /// <see cref="XPathNodeIterator"/> objects. /// </summary> /// <remarks>See http://weblogs.asp.net/cazzu/archive/2004/04/14/113479.aspx. /// <para>Author: Daniel Cazzulino, kz...@gm...</para> /// </remarks> public sealed class XmlNodeListFactory { private XmlNodeListFactory() { } #region Public members /// <summary> /// Creates an instance of a <see cref="XmlNodeList"/> that allows /// enumerating <see cref="XmlNode"/> elements in the iterator. /// </summary> /// <param name="iterator">The result of a previous node selection /// through an <see cref="XPathNavigator"/> query.</param> /// <returns>An initialized list ready to be enumerated.</returns> /// <remarks>The underlying XML store used to issue the query must be /// an object inheriting <see cref="XmlNode"/>, such as /// <see cref="XmlDocument"/>.</remarks> public static XmlNodeList CreateNodeList(XPathNodeIterator iterator) { return new XmlNodeListIterator(iterator); } #endregion Public members #region XmlNodeListIterator private class XmlNodeListIterator : XmlNodeList { XPathNodeIterator _iterator; ArrayList _nodes = new ArrayList(); public XmlNodeListIterator(XPathNodeIterator iterator) { _iterator = iterator.Clone(); } public override IEnumerator GetEnumerator() { return new XmlNodeListEnumerator(this); } public override XmlNode Item(int index) { if (index >= _nodes.Count) ReadTo(index); // Compatible behavior with .NET if (index >= _nodes.Count || index < 0) return null; return (XmlNode)_nodes[index]; } public override int Count { get { if (!_done) ReadToEnd(); return _nodes.Count; } } /// <summary> /// Reads the entire iterator. /// </summary> private void ReadToEnd() { while (_iterator.MoveNext()) { IHasXmlNode node = _iterator.Current as IHasXmlNode; // Check IHasXmlNode interface. if (node == null) throw new ArgumentException(SR.XmlNodeListFactory_IHasXmlNodeMissing); _nodes.Add(node.GetNode()); } _done = true; } /// <summary> /// Reads up to the specified index, or until the /// iterator is consumed. /// </summary> private void ReadTo(int to) { while (_nodes.Count <= to) { if (_iterator.MoveNext()) { IHasXmlNode node = _iterator.Current as IHasXmlNode; // Check IHasXmlNode interface. if (node == null) throw new ArgumentException(SR.XmlNodeListFactory_IHasXmlNodeMissing); _nodes.Add(node.GetNode()); } else { _done = true; return; } } } /// <summary> /// Flags that the iterator has been consumed. /// </summary> private bool Done { get { return _done; } } bool _done; /// <summary> /// Current count of nodes in the iterator (read so far). /// </summary> private int CurrentPosition { get { return _nodes.Count; } } #region XmlNodeListEnumerator private class XmlNodeListEnumerator : IEnumerator { XmlNodeListIterator _iterator; int _position = -1; public XmlNodeListEnumerator(XmlNodeListIterator iterator) { _iterator = iterator; } #region IEnumerator Members void System.Collections.IEnumerator.Reset() { _position = -1; } bool System.Collections.IEnumerator.MoveNext() { _position++; _iterator.ReadTo(_position); // If we reached the end and our index is still // bigger, there're no more items. if (_iterator.Done && _position >= _iterator.CurrentPosition) return false; return true; } object System.Collections.IEnumerator.Current { get { return _iterator[_position]; } } #endregion } #endregion XmlNodeListEnumerator } #endregion XmlNodeListIterator } } --- NEW FILE: .cvsignore --- bin obj *.user *.suo --- NEW FILE: changelog.txt --- May 28, 2005 Added ObjectNode to XmlNodeFactory to improve performance of client-side message-based communication with web services through XmlSerializer. See: http://weblogs.asp.net/cazzu/posts/xmlmessageperformance.aspx --------------------------------------------------------- January 04, 2005 Added Serialization folder and classes. --------------------------------------------------------- November 13, 2004 Bug fix in XmlNodeListFactory. Thanks to Raneses, Jason. Bug fixes in XPathNavigatorReader (thanks Oleg!) --------------------------------------------------------- October 8, 2004 Bug fix in XPathCache that caused NullReferenceExceptions if an XmlNamespaceManager is not used when selecting nodes. --------------------------------------------------------- June 30, 2004 Added XPathNavigatorIterator Allows building an iterator by hand, by appending navigators. XPathNavigatorReader.InnerXml fixed. Thanks to Lawrence Oluyede! --------------------------------------------------------- June 24, 2004 Added SubtreeXPathNavigator See: http://weblogs.asp.net/cazzu/archive/2004/06/24/164243.aspx. --------------------------------------------------------- May 31, 2004 Added XmlNodeFactory See: http://weblogs.asp.net/cazzu/archive/2004/05/31/144922.aspx. --------------------------------------------------------- May 27, 2004 Added sort overloads to XPathCache. Thanks to Jason Addie. --------------------------------------------------------- May 15, 2004 Bug fixing in XPathNavigatorReader Thanks to Joost Ploegmakers --------------------------------------------------------- May 10, 2004 Bug fixing in XPathNavigatorReader See: http://weblogs.asp.net/cazzu/archive/2004/05/10/129101.aspx Added XmlFirstUpperReader and XmlFirstLowerWriter See: http://weblogs.asp.net/cazzu/archive/2004/05/10/129106.aspx --------------------------------------------------------- April 26, 2004 Added XPathIteratorReader See: http://weblogs.asp.net/cazzu/archive/2004/04/26/120684.aspx --------------------------------------------------------- April 23, 2004 Added XmlFragmentStream: See: http://weblogs.asp.net/cazzu/archive/2004/04/23/119263.aspx --------------------------------------------------------- April 19, 2004 Fully working production-quality XPathNavigatorReader. See: http://weblogs.asp.net/cazzu/archive/2004/04/19/115966.aspx --------------------------------------------------------- April 11, 2004 Added IndexingXPathNavigator code. See http://www.tkachenko.com/blog/archives/000194.html --------------------------------------------------------- April 02, 2004 XPathCache and DynamicContext added to project. See: http://weblogs.asp.net/cazzu/archive/2004/04/02/106667.aspx --------------------------------------------------------- April 01, 2004 Initial setup. Folder contains main project source files. --- NEW FILE: XmlFirstLowerWriter.cs --- #region using using System; using System.IO; using System.Text; using System.Xml; #endregion using namespace Mvp.Xml.Common { /// <summary> /// Implements an <see cref="XmlWriter"/> that turns the /// first letter of outgoing elements and attributes into lowercase. /// </summary> /// <remarks> /// To be used in conjunction with <see cref="XmlFirstUpperReader"/>. /// <para>Author: Daniel Cazzulino, kz...@gm...</para> /// See http://weblogs.asp.net/cazzu/archive/2004/05/10/129106.aspx. /// </remarks> public class XmlFirstLowerWriter : XmlTextWriter { #region Fields & Ctor /// <summary> /// See <see cref="XmlTextWriter"/> ctors. /// </summary> public XmlFirstLowerWriter(TextWriter w) : base(w) { } /// <summary> /// See <see cref="XmlTextWriter"/> ctors. /// </summary> public XmlFirstLowerWriter(Stream w, Encoding encoding) : base(w, encoding) { } /// <summary> /// See <see cref="XmlTextWriter"/> ctors. /// </summary> public XmlFirstLowerWriter(string filename, Encoding encoding) : base(filename, encoding) { } #endregion Fields & Ctor #region MakeFirstLower internal static string MakeFirstLower(string name) { // Don't process empty strings. if (name.Length == 0) return name; // If the first is already lower, don't process. if (Char.IsLower(name[0])) return name; // If there's just one char, make it lower directly. if (name.Length == 1) return name.ToLower(System.Globalization.CultureInfo.CurrentCulture); // Finally, modify and create a string. Char[] letters = name.ToCharArray(); letters[0] = Char.ToLower(letters[0], System.Globalization.CultureInfo.CurrentCulture); return new string(letters); } #endregion MakeFirstUpper #region Methods /// <summary> /// See <see cref="XmlWriter.WriteQualifiedName"/>. /// </summary> public override void WriteQualifiedName(string localName, string ns) { base.WriteQualifiedName(MakeFirstLower(localName), ns); } /// <summary> /// See <see cref="XmlWriter.WriteStartAttribute(string, string, string)"/>. /// </summary> public override void WriteStartAttribute(string prefix, string localName, string ns) { base.WriteStartAttribute(prefix, MakeFirstLower(localName), ns); } /// <summary> /// See <see cref="XmlWriter.WriteStartElement(string, string, string)"/>. /// </summary> public override void WriteStartElement(string prefix, string localName, string ns) { base.WriteStartElement(prefix, MakeFirstLower(localName), ns); } #endregion Methods } } --- NEW FILE: Common.csproj --- (This appears to be a binary file; contents omitted.) --- NEW FILE: XmlFirstUpperReader.cs --- #region using using System; using System.IO; using System.Xml; #endregion using namespace Mvp.Xml.Common { /// <summary> /// Implements an <see cref="XmlTextReader"/> that turns the /// first letter of incoming elements and attributes into uppercase. /// </summary> /// <remarks> /// To be used in conjunction with <see cref="XmlFirstLowerWriter"/> for /// serialization. /// <para>Author: Daniel Cazzulino, kz...@gm...</para> /// See http://weblogs.asp.net/cazzu/archive/2004/05/10/129106.aspx. /// </remarks> public class XmlFirstUpperReader : XmlTextReader { #region Ctors /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(Stream input) : base(input) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(TextReader input) : base(input) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string url) : base(url) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(Stream input, XmlNameTable nt) : base(input, nt) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(TextReader input, XmlNameTable nt) : base(input, nt) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string url, Stream input) : base(url, input) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string url, TextReader input) : base(url, input) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string url, XmlNameTable nt) : base(url, nt) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context) : base(xmlFragment, fragType, context) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string url, Stream input, XmlNameTable nt) : base(url, input, nt) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string url, TextReader input, XmlNameTable nt) : base(url, input, nt) {} /// <summary> /// See <see cref="XmlTextReader"/> constructor overloads. /// </summary> public XmlFirstUpperReader(string xmlFragment, XmlNodeType fragType, XmlParserContext context) : base(xmlFragment, fragType, context) {} #endregion Ctors #region Private methods private string MakeFirstUpper(string name) { // Don't process empty strings. if (name.Length == 0) return name; // If the first is already upper, don't process. if (Char.IsUpper(name[0])) return name; // If there's just one char, make it lower directly. if (name.Length == 1) return name.ToUpper(System.Globalization.CultureInfo.CurrentCulture); // Finally, modify and create a string. Char[] letters = name.ToCharArray(); letters[0] = Char.ToUpper(letters[0], System.Globalization.CultureInfo.CurrentUICulture); return NameTable.Add(new string(letters)); } #endregion Private methods #region Properties /// <summary>See <see cref="XmlReader.this[string, string]"/></summary> public override string this[string name, string namespaceURI] { get { return base[ NameTable.Add(XmlFirstLowerWriter.MakeFirstLower(name)), namespaceURI]; } } /// <summary>See <see cref="XmlReader.this[string]"/></summary> public override string this[string name] { get { return this[name, String.Empty]; } } /// <summary>See <see cref="XmlReader.LocalName"/></summary> public override string LocalName { get { // Capitalize elements and attributes. if ( base.NodeType == XmlNodeType.Element || base.NodeType == XmlNodeType.EndElement || base.NodeType == XmlNodeType.Attribute ) { return base.NamespaceURI == XmlNamespaces.XmlNs ? // Except if the attribute is a namespace declaration base.LocalName : MakeFirstUpper(base.LocalName); } return base.LocalName; } } /// <summary>See <see cref="XmlReader.Name"/></summary> public override string Name { get { // Again, if this is a NS declaration, pass as-is. if (base.NamespaceURI == XmlNamespaces.XmlNs) return base.Name; // If there's no prefix, capitalize it directly. if (base.Name.IndexOf(":") == -1) return MakeFirstUpper(base.Name); else { // Turn local name into upper, not the prefix. string name = base.Name.Substring(0, base.Name.IndexOf(":") + 1); name += MakeFirstUpper(base.Name.Substring(base.Name.IndexOf(":") + 1)); return NameTable.Add(name); } } } #endregion Properties #region Methods /// <summary>See <see cref="XmlReader.MoveToAttribute(string, string)"/></summary> public override bool MoveToAttribute(string name, string ns) { return base.MoveToAttribute( NameTable.Add(XmlFirstLowerWriter.MakeFirstLower(name)), ns); } #endregion Methods } } --- NEW FILE: AssemblyInfo.cs --- using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Permissions; [assembly: ComVisible(false)] [assembly: CLSCompliant(true)] [assembly: AssemblyTitle("Mvp.Xml.Common")] [assembly: AssemblyDescription("MVP XML Library - Common Module")] [assembly: AssemblyVersion("2.0.*")] #region Security Permissions //[assembly: SecurityPermission(SecurityAction.RequestRefuse, UnmanagedCode=true)] #endregion Security Permissions --- NEW FILE: XmlPrefix.cs --- #region using using System; using System.Xml; #endregion using namespace Mvp.Xml.Common { /// <summary> /// Represents a mapping between a prefix and a namespace. /// </summary> public class XmlPrefix { /// <summary> /// Creates the prefix mapping. /// </summary> /// <param name="prefix">Prefix associated with the namespace.</param> /// <param name="ns">Namespace to associate with the prefix.</param> public XmlPrefix(string prefix, string ns) { _prefix = prefix; _ns = ns; } /// <summary> /// Creates the prefix mapping, using atomized strings from the /// <paramref name="nameTable"/> for faster lookups and comparisons. /// </summary> /// <param name="prefix">Prefix associated with the namespace.</param> /// <param name="ns">Namespace to associate with the prefix.</param> /// <param name="nameTable">The name table to use to atomize strings.</param> /// <remarks> /// This is the recommended way to construct this class, as it uses the /// best approach to handling strings in XML. /// </remarks> public XmlPrefix(string prefix, string ns, XmlNameTable nameTable) { _prefix = nameTable.Add( prefix ); _ns = nameTable.Add( ns ); } /// <summary> /// Gets the prefix associated with the <see cref="NamespaceURI"/>. /// </summary> public string Prefix { get { return _prefix; } } string _prefix; /// <summary> /// Gets the namespace associated with the <see cref="Prefix"/>. /// </summary> public string NamespaceURI { get { return _ns; } } string _ns; } } --- NEW FILE: XmlBaseAwareXmlTextReader.cs --- #region using using System; using System.Xml; using System.IO; using System.Collections.Generic; #endregion namespace Mvp.Xml.Common { /// <summary> /// XmlTextReader supporting <a href="http://www.w3.org/TR/xmlbase/">XML Base</a>. /// </summary> public class XmlBaseAwareXmlTextReader : XmlTextReader { #region private private XmlBaseState _state = new XmlBaseState(); private Stack<XmlBaseState> _states = null; #endregion #region constructors /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given URI. /// </summary> public XmlBaseAwareXmlTextReader(string uri) : base(uri) { _state.BaseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given URI and /// name table. /// </summary> public XmlBaseAwareXmlTextReader(string uri, XmlNameTable nt) : base(uri, nt) { _state.BaseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given TextReader. /// </summary> public XmlBaseAwareXmlTextReader(TextReader reader) : base(reader) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given uri and /// TextReader. /// </summary> public XmlBaseAwareXmlTextReader(string uri, TextReader reader) : base(uri, reader) { _state.BaseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given TextReader /// and name table. /// </summary> public XmlBaseAwareXmlTextReader(TextReader reader, XmlNameTable nt) : base(reader, nt) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given uri, name table /// and TextReader. /// </summary> public XmlBaseAwareXmlTextReader(string uri, TextReader reader, XmlNameTable nt) : base(uri, reader, nt) { _state.BaseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given stream. /// </summary> public XmlBaseAwareXmlTextReader(Stream stream) : base(stream) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given uri and stream. /// </summary> public XmlBaseAwareXmlTextReader(string uri, Stream stream) : base(uri, stream) { _state.BaseUri = new Uri(base.BaseURI); } /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given stream /// and name table. /// </summary> public XmlBaseAwareXmlTextReader(Stream stream, XmlNameTable nt) : base(stream, nt) {} /// <summary> /// Creates XmlBaseAwareXmlTextReader instance for given stream, /// uri and name table. /// </summary> public XmlBaseAwareXmlTextReader(string uri, Stream stream, XmlNameTable nt) : base(uri, stream, nt) { _state.BaseUri = new Uri(base.BaseURI); } #endregion #region XmlTextReader overrides /// <summary> /// See <see cref="XmlTextReader.BaseURI"/>. /// </summary> public override string BaseURI { get { return _state.BaseUri==null? "" : _state.BaseUri.AbsoluteUri; } } /// <summary> /// See <see cref="XmlTextReader.Read"/>. /// </summary> public override bool Read() { bool baseRead = base.Read(); if (baseRead) { if (base.NodeType == XmlNodeType.Element && base.HasAttributes) { string baseAttr = GetAttribute("xml:base"); if (baseAttr == null) return baseRead; Uri newBaseUri = null; if (_state.BaseUri == null) newBaseUri = new Uri(baseAttr); else newBaseUri = new Uri(_state.BaseUri, baseAttr); if (_states == null) _states = new Stack<XmlBaseState>(); //Push current state and allocate new one _states.Push(_state); _state = new XmlBaseState(newBaseUri, base.Depth); } else if (base.NodeType == XmlNodeType.EndElement) { if (base.Depth == _state.Depth && _states != null && _states.Count > 0) { //Pop previous state _state = _states.Pop(); } } } return baseRead; } #endregion } internal class XmlBaseState { public XmlBaseState() {} public XmlBaseState(Uri baseUri, int depth) { this.BaseUri = baseUri; this.Depth = depth; } public Uri BaseUri; public int Depth; } } --- NEW FILE: SR.resx --- <?xml version="1.0" encoding="utf-8" ?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="ResMimeType"> <value>text/microsoft-resx</value> </resheader> <resheader name="Version"> <value>1.0.0.0</value> </resheader> <resheader name="Reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="Writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="XmlNodeListFactory_IHasXmlNodeMissing" type="System.String" mimetype="System.String"> <value>The XPath query was not executed against an XmlNode-based object (such as XmlDocument).</value> <comment>The factory received an XPathNodeIterator that was not obtained from querying an XmlDocument or XmlNode.</comment> </data> <data name="IndexingXPathNavigator_KeyWrongArguments" type="System.String" mimetype="System.String"> <value>Wrong number of arguments of key() function.</value> <comment>The key() function was called with invalid number of args.</comment> </data> <data name="IndexingXPathNavigator_KeyArgumentNotString" type="System.String" mimetype="System.String"> <value>Type of the first argument of key() function must be string.</value> </data> <data name="XmlFragmentStream_EOF" type="System.String" mimetype="System.String"> <value>Attempt to read past EOF.</value> <comment>The read method was called while the class is already in EOF.</comment> </data> <data name="XPathCache_BadSortObject" type="System.String" mimetype="System.String"> <value>Sort expression must be either a string or an XPathExpression.</value> <comment>Sort expression is invalid.</comment> </data> <data name="XmlDocumentFactory_NotImplementedDOM" type="System.String" mimetype="System.String"> <value>The XmlDocument instance can only be used for serialization purposes.</value> <comment>All methods except for WriteTo() are unimplemented.</comment> </data> <data name="XPathNavigatorIterator_CantAddAfterMove" type="System.String" mimetype="System.String"> <value>Can't add new elements after the iterator has moved.</value> <comment>Can't add new elements after the iterator has moved.</comment> </data> </root> --- NEW FILE: SR.cs --- //------------------------------------------------------------------------------ // <autogenerated> // This code was generated by a tool. // Runtime Version: 1.1.4322.573 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </autogenerated> //------------------------------------------------------------------------------ namespace Mvp.Xml.Common { using System; using System.Resources; using System.Threading; /// <summary>Contains resources for the application.</summary> sealed class SR { private static ResourceManager _resourceManager = new ResourceManager(typeof(SR).FullName, typeof(SR).Module.Assembly); private SR() { } /// <summary> /// Gets the specified resource for the <see cref='Thread.CurrentUICulture'/>. /// </summary> /// <param name='key'>The key of the resource to retrieve.</param> /// <returns>The object resource.</returns> internal static object GetObject(string key) { return _resourceManager.GetObject(key); } /// <summary> /// Gets the specified resource for the <see cref='Thread.CurrentUICulture'/>. /// </summary> /// <param name='key'>The key of the resource to retrieve.</param> /// <returns>The string resource.</returns> internal static string GetString(string key) { return _resourceManager.GetString(key); } /// <summary> /// Gets the specified resource for the <see cref='Thread.CurrentUICulture'/> and /// formats it with the arguments received. /// </summary> /// <param name='key'>The key of the resource to retrieve.</param> /// <param name='args'>The arguments to format the resource with.</param> /// <returns>The string resource.</returns> internal static string GetString(string key, params object[] args) { return String.Format(GetString(key), args); } /// <summary>The factory received an XPathNodeIterator that was not obtained from querying an XmlDocument or XmlNode.</summary> public static string XmlNodeListFactory_IHasXmlNodeMissing { get { return SR.GetString("XmlNodeListFactory_IHasXmlNodeMissing"); } } /// <summary>The key() function was called with invalid number of args.</summary> public static string IndexingXPathNavigator_KeyWrongArguments { get { return SR.GetString("IndexingXPathNavigator_KeyWrongArguments"); } } /// <summary></summary> public static string IndexingXPathNavigator_KeyArgumentNotString { get { return SR.GetString("IndexingXPathNavigator_KeyArgumentNotString"); } } /// <summary>The read method was called while the class is already in EOF.</summary> public static string XmlFragmentStream_EOF { get { return SR.GetString("XmlFragmentStream_EOF"); } } /// <summary>Sort expression is invalid.</summary> public static string XPathCache_BadSortObject { get { return SR.GetString("XPathCache_BadSortObject"); } } /// <summary>All methods except for WriteTo() are unimplemented.</summary> public static string XmlDocumentFactory_NotImplementedDOM { get { return SR.GetString("XmlDocumentFactory_NotImplementedDOM"); } } /// <summary>Can't add new elements after the iterator has moved.</summary> public static string XPathNavigatorIterator_CantAddAfterMove { get { return SR.GetString("XPathNavigatorIterator_CantAddAfterMove"); } } } } --- NEW FILE: XmlNamespaces.cs --- #region using using System; #endregion using namespace Mvp.Xml.Common { /// <summary> /// Provides public constants for wellknown XML namespaces. /// </summary> /// <remarks>Author: Daniel Cazzulino, kz...@gm...</remarks> public sealed class XmlNamespaces { #region Ctor private XmlNamespaces() {} #endregion Ctor #region Public Constants /// <summary> /// The public XML 1.0 namespace. /// </summary> /// <remarks>See http://www.w3.org/TR/2004/REC-xml-20040204/</remarks> public const string Xml = "http://www.w3.org/XML/1998/namespace"; /// <summary> /// Public Xml Namespaces specification namespace. /// </summary> /// <remarks>See http://www.w3.org/TR/REC-xml-names/</remarks> public const string XmlNs = "http://www.w3.org/2000/xmlns/"; /// <summary> /// Public Xml Namespaces prefix. /// </summary> /// <remarks>See http://www.w3.org/TR/REC-xml-names/</remarks> public const string XmlNsPrefix = "xmlns"; /// <summary> /// XML Schema instance namespace. /// </summary> /// <remarks>See http://www.w3.org/TR/xmlschema-1/</remarks> public const string Xsi = "http://www.w3.org/2001/XMLSchema-instance"; /// <summary> /// XML 1.0 Schema namespace. /// </summary> /// <remarks>See http://www.w3.org/TR/xmlschema-1/</remarks> public const string Xsd = "http://www.w3.org/2001/XMLSchema"; #endregion Public Constants } } |
From: Oleg T. <he...@us...> - 2005-10-16 16:50:57
|
Update of /cvsroot/mvp-xml/Common/v2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3301/src Log Message: Directory /cvsroot/mvp-xml/Common/v2/src added to the repository |
Update of /cvsroot/mvp-xml/XPointer/v2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25660/v2/src Modified Files: ElementSchemaPointerPart.cs IDAssuredValidatingReader.cs LexUtils.cs Pointer.cs PointerPart.cs SR.cs SchemaBasedPointer.cs ShorthandPointer.cs XPath1SchemaPointerPart.cs XPointer.csproj XPointerException.cs XPointerLexer.cs XPointerParser.cs XPointerReader.cs XPointerSchema.cs XPointerSchemaPointerPart.cs XmlnsSchemaPointerPart.cs Log Message: Index: IDAssuredValidatingReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/IDAssuredValidatingReader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IDAssuredValidatingReader.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ IDAssuredValidatingReader.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -4,92 +4,92 @@ #endregion -namespace Mvp.Xml.XPointer +namespace Mvp.Xml.XPointer { + /// <summary> + /// Auxillary XmlReader that always reports dummy DOCTYPE. This is done + /// to turn on support for id() function in XML Schema defined XML documents. + /// See http://www.tkachenko.com/blog/archives/000060.html. + /// </summary> + internal class IdAssuredValidatingReader : XmlValidatingReader + { + #region private members + + private bool _exposeDummyDoctype; + private bool _isInProlog = true; + + #endregion + + #region constructors + /// <summary> - /// Auxillary XmlReader that always reports dummy DOCTYPE. This is done - /// to turn on support for id() function in XML Schema defined XML documents. - /// See http://www.tkachenko.com/blog/archives/000060.html. + /// Constructs <c>IdAssuredValidatingReader</c> on top of another reader. /// </summary> - internal class IdAssuredValidatingReader : XmlValidatingReader - { - #region private members + /// <param name="r"></param> + public IdAssuredValidatingReader(XmlReader r) : base(r) { } - private bool _exposeDummyDoctype; - private bool _isInProlog = true; + #endregion - #endregion + #region XmlValidatingReader overrides - #region constructors - - /// <summary> - /// Constructs <c>IdAssuredValidatingReader</c> on top of another reader. - /// </summary> - /// <param name="r"></param> - public IdAssuredValidatingReader(XmlReader r) : base (r) {} + /// <summary>See <see cref="XmlValidatingReader.NodeType"/>.</summary> + public override XmlNodeType NodeType + { + get + { + return _exposeDummyDoctype ? + XmlNodeType.DocumentType : + base.NodeType; + } + } - #endregion + /// <summary>See <see cref="XmlValidatingReader.MoveToNextAttribute"/>.</summary> + public override bool MoveToNextAttribute() + { + return _exposeDummyDoctype ? + false : + base.MoveToNextAttribute(); + } - #region XmlValidatingReader overrides - - /// <summary>See <see cref="XmlValidatingReader.NodeType"/>.</summary> - public override XmlNodeType NodeType - { - get - { - return _exposeDummyDoctype ? - XmlNodeType.DocumentType : - base.NodeType; - } - } - - /// <summary>See <see cref="XmlValidatingReader.MoveToNextAttribute"/>.</summary> - public override bool MoveToNextAttribute() + /// <summary>See <see cref="XmlValidatingReader.Read"/>.</summary> + public override bool Read() + { + if (_isInProlog) + { + if (!_exposeDummyDoctype) { - return _exposeDummyDoctype? - false : - base.MoveToNextAttribute(); + //We are looking for the very first element + bool baseRead = base.Read(); + if (base.NodeType == XmlNodeType.Element) + { + _exposeDummyDoctype = true; + return true; + } + else if (base.NodeType == XmlNodeType.DocumentType) + { + //Document has own DOCTYPE, switch back to normal flow + _exposeDummyDoctype = false; + _isInProlog = false; + return true; + } + else + { + return baseRead; + } } - - /// <summary>See <see cref="XmlValidatingReader.Read"/>.</summary> - public override bool Read() + else { - if (_isInProlog) - { - if (!_exposeDummyDoctype) - { - //We are looking for the very first element - bool baseRead = base.Read(); - if (base.NodeType == XmlNodeType.Element) - { - _exposeDummyDoctype = true; - return true; - } - else if (base.NodeType == XmlNodeType.DocumentType) - { - //Document has own DOCTYPE, switch back to normal flow - _exposeDummyDoctype = false; - _isInProlog = false; - return true; - } - else - { - return baseRead; - } - } - else - { - //Done, switch back to normal flow - _exposeDummyDoctype = false; - _isInProlog = false; - return true; - } - } - else - return base.Read(); + //Done, switch back to normal flow + _exposeDummyDoctype = false; + _isInProlog = false; + return true; } - - #endregion + } + else + return base.Read(); } + + #endregion + } } \ No newline at end of file Index: Pointer.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/Pointer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Pointer.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ Pointer.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -6,35 +6,36 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// Abstract XPointer pointer. - /// </summary> - public abstract class Pointer { +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// Abstract XPointer pointer. + /// </summary> + public abstract class Pointer + { - #region public methods + #region public methods - /// <summary> - /// Parses XPointer pointer and compiles it into - /// an instance of <see cref="Pointer"/> class. - /// </summary> - /// <param name="xpointer">XPointer pointer</param> - /// <returns>Parsed and compiled XPointer</returns> - public static Pointer Compile(string xpointer) - { - return XPointerParser.ParseXPointer(xpointer); - } + /// <summary> + /// Parses XPointer pointer and compiles it into + /// an instance of <see cref="Pointer"/> class. + /// </summary> + /// <param name="xpointer">XPointer pointer</param> + /// <returns>Parsed and compiled XPointer</returns> + public static Pointer Compile(string xpointer) + { + return XPointerParser.ParseXPointer(xpointer); + } - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer and returns - /// iterator over pointed nodes. - /// </summary> - /// <param name="nav">Navigator to evaluate the - /// <see cref="XPointer"/> on.</param> - /// <returns><see cref="XPathNodeIterator"/> over pointed nodes. Note - this iterator is moved to the first node already.</returns> - public abstract XPathNodeIterator Evaluate(XPathNavigator nav); + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer and returns + /// iterator over pointed nodes. + /// </summary> + /// <param name="nav">Navigator to evaluate the + /// <see cref="XPointer"/> on.</param> + /// <returns><see cref="XPathNodeIterator"/> over pointed nodes. Note - this iterator is moved to the first node already.</returns> + public abstract XPathNodeIterator Evaluate(XPathNavigator nav); - #endregion - } + #endregion + } } Index: SchemaBasedPointer.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/SchemaBasedPointer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SchemaBasedPointer.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ SchemaBasedPointer.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -7,60 +7,60 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// SchemaBased XPointer pointer. - /// </summary> - internal class SchemaBasedPointer : Pointer - { +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// SchemaBased XPointer pointer. + /// </summary> + internal class SchemaBasedPointer : Pointer + { - #region private members + #region private members - private IList<PointerPart> _parts; - private string _xpointer; + private IList<PointerPart> _parts; + private string _xpointer; - #endregion + #endregion - #region constructors - - /// <summary> - /// Creates scheme based XPointer given list of pointer parts. - /// </summary> - /// <param name="parts">List of pointer parts</param> - /// <param name="xpointer">String representation of the XPointer - /// (for error diagnostics)</param> - public SchemaBasedPointer(IList<PointerPart> parts, string xpointer) - { - _parts = parts; - _xpointer = xpointer; - } + #region constructors - #endregion - - #region Pointer overrides + /// <summary> + /// Creates scheme based XPointer given list of pointer parts. + /// </summary> + /// <param name="parts">List of pointer parts</param> + /// <param name="xpointer">String representation of the XPointer + /// (for error diagnostics)</param> + public SchemaBasedPointer(IList<PointerPart> parts, string xpointer) + { + _parts = parts; + _xpointer = xpointer; + } - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer and returns - /// iterator over pointed nodes. - /// </summary> - /// <param name="nav">XPathNavigator to evaluate the - /// <see cref="XPointer"/> on.</param> - /// <returns><see cref="XPathNodeIterator"/> over pointed nodes</returns> - public override XPathNodeIterator Evaluate(XPathNavigator nav) - { - XPathNodeIterator result; - XmlNamespaceManager nm = new XmlNamespaceManager(nav.NameTable); - for (int i=0; i<_parts.Count; i++) - { - PointerPart part = _parts[i]; - result = part.Evaluate(nav, nm); - if (result != null && result.MoveNext()) - return result; - } - throw new NoSubresourcesIdentifiedException(SR.GetString("NoSubresourcesIdentifiedException", _xpointer)); - } + #endregion - #endregion + #region Pointer overrides + + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer and returns + /// iterator over pointed nodes. + /// </summary> + /// <param name="nav">XPathNavigator to evaluate the + /// <see cref="XPointer"/> on.</param> + /// <returns><see cref="XPathNodeIterator"/> over pointed nodes</returns> + public override XPathNodeIterator Evaluate(XPathNavigator nav) + { + XPathNodeIterator result; + XmlNamespaceManager nm = new XmlNamespaceManager(nav.NameTable); + for (int i = 0; i < _parts.Count; i++) + { + PointerPart part = _parts[i]; + result = part.Evaluate(nav, nm); + if (result != null && result.MoveNext()) + return result; + } + throw new NoSubresourcesIdentifiedException(SR.GetString("NoSubresourcesIdentifiedException", _xpointer)); } + + #endregion + } } Index: XmlnsSchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/XmlnsSchemaPointerPart.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XmlnsSchemaPointerPart.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ XmlnsSchemaPointerPart.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -1,4 +1,4 @@ -#region using +#region using using System; using System.Xml; @@ -6,85 +6,85 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// xmlns() scheme based <see cref="XPointer"/> pointer part. - /// </summary> - internal class XmlnsSchemaPointerPart : PointerPart - { +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// xmlns() scheme based <see cref="XPointer"/> pointer part. + /// </summary> + internal class XmlnsSchemaPointerPart : PointerPart + { - #region private members + #region private members - private string _prefix, _uri; + private string _prefix, _uri; - #endregion + #endregion - #region constructors + #region constructors - /// <summary> - /// Creates xmlns() scheme pointer part with given - /// namespace prefix and namespace URI. - /// </summary> - /// <param name="prefix">Namespace prefix</param> - /// <param name="uri">Namespace URI</param> - public XmlnsSchemaPointerPart(string prefix, string uri) - { - _prefix = prefix; - _uri = uri; - } + /// <summary> + /// Creates xmlns() scheme pointer part with given + /// namespace prefix and namespace URI. + /// </summary> + /// <param name="prefix">Namespace prefix</param> + /// <param name="uri">Namespace URI</param> + public XmlnsSchemaPointerPart(string prefix, string uri) + { + _prefix = prefix; + _uri = uri; + } - #endregion - - #region PointerPart overrides + #endregion - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. - /// </summary> - /// <param name="doc">Document to evaluate pointer part on</param> - /// <param name="nm">Namespace manager</param> - /// <returns>Pointed nodes</returns> - public override XPathNodeIterator Evaluate(XPathNavigator doc, XmlNamespaceManager nm) - { - nm.AddNamespace(_prefix, _uri); - return null; - } + #region PointerPart overrides - #endregion + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. + /// </summary> + /// <param name="doc">Document to evaluate pointer part on</param> + /// <param name="nm">Namespace manager</param> + /// <returns>Pointed nodes</returns> + public override XPathNodeIterator Evaluate(XPathNavigator doc, XmlNamespaceManager nm) + { + nm.AddNamespace(_prefix, _uri); + return null; + } - #region parser - - public static XmlnsSchemaPointerPart ParseSchemaData(XPointerLexer lexer) - { - //[1] XmlnsSchemeData ::= NCName S? '=' S? EscapedNamespaceName - //[2] EscapedNamespaceName ::= EscapedData* - //Read prefix as NCName - lexer.NextLexeme(); - if (lexer.Kind != XPointerLexer.LexKind.NCName) - { - Debug.WriteLine(SR.InvalidTokenInXmlnsSchemeWhileNCNameExpected); - return null; - } - string prefix = lexer.NCName; - lexer.SkipWhiteSpace(); - lexer.NextLexeme(); - if (lexer.Kind != XPointerLexer.LexKind.Eq) - { - Debug.WriteLine(SR.InvalidTokenInXmlnsSchemeWhileEqualsSignExpected); - return null; - } - lexer.SkipWhiteSpace(); - string nsURI; - try - { - nsURI = lexer.ParseEscapedData(); - } - catch (Exception e) - { - throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXmlnsSchemeData", e.Message)); - } - return new XmlnsSchemaPointerPart(prefix, nsURI); - } - #endregion + #endregion + + #region parser + + public static XmlnsSchemaPointerPart ParseSchemaData(XPointerLexer lexer) + { + //[1] XmlnsSchemeData ::= NCName S? '=' S? EscapedNamespaceName + //[2] EscapedNamespaceName ::= EscapedData* + //Read prefix as NCName + lexer.NextLexeme(); + if (lexer.Kind != XPointerLexer.LexKind.NCName) + { + Debug.WriteLine(SR.InvalidTokenInXmlnsSchemeWhileNCNameExpected); + return null; + } + string prefix = lexer.NCName; + lexer.SkipWhiteSpace(); + lexer.NextLexeme(); + if (lexer.Kind != XPointerLexer.LexKind.Eq) + { + Debug.WriteLine(SR.InvalidTokenInXmlnsSchemeWhileEqualsSignExpected); + return null; + } + lexer.SkipWhiteSpace(); + string nsURI; + try + { + nsURI = lexer.ParseEscapedData(); + } + catch (Exception e) + { + throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXmlnsSchemeData", e.Message)); + } + return new XmlnsSchemaPointerPart(prefix, nsURI); } + #endregion + } } Index: ShorthandPointer.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/ShorthandPointer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ShorthandPointer.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ ShorthandPointer.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -8,52 +8,52 @@ #endregion -namespace Mvp.Xml.XPointer -{ +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// Shorthand XPointer pointer. + /// </summary> + internal class ShorthandPointer : Pointer + { + #region private members + + private string _NCName; + + #endregion + + #region constructors + /// <summary> - /// Shorthand XPointer pointer. + /// Creates shorthand XPointer given bare name. /// </summary> - internal class ShorthandPointer : Pointer + /// <param name="n">Shorthand (bare name)</param> + public ShorthandPointer(string n) { - #region private members - - private string _NCName; - - #endregion - - #region constructors + _NCName = n; + } - /// <summary> - /// Creates shorthand XPointer given bare name. - /// </summary> - /// <param name="n">Shorthand (bare name)</param> - public ShorthandPointer(string n) - { - _NCName = n; - } + #endregion - #endregion + #region Pointer overrides - #region Pointer overrides - - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer and returns - /// iterator over pointed nodes. - /// </summary> - /// <remarks>Note, that returned XPathNodeIterator is already moved once.</remarks> - /// <param name="nav">XPathNavigator to evaluate the - /// <see cref="XPointer"/> on.</param> - /// <returns><see cref="XPathNodeIterator"/> over pointed nodes</returns> - public override XPathNodeIterator Evaluate(XPathNavigator nav) - { - XPathNodeIterator result = XPathCache.Select("id('"+ _NCName + "')", nav, (XmlNamespaceManager)null); - if (result != null && result.MoveNext()) - { - return result; - } - else - throw new NoSubresourcesIdentifiedException(SR.GetString("NoSubresourcesIdentifiedException", _NCName)); - } - #endregion + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer and returns + /// iterator over pointed nodes. + /// </summary> + /// <remarks>Note, that returned XPathNodeIterator is already moved once.</remarks> + /// <param name="nav">XPathNavigator to evaluate the + /// <see cref="XPointer"/> on.</param> + /// <returns><see cref="XPathNodeIterator"/> over pointed nodes</returns> + public override XPathNodeIterator Evaluate(XPathNavigator nav) + { + XPathNodeIterator result = XPathCache.Select("id('" + _NCName + "')", nav, (XmlNamespaceManager)null); + if (result != null && result.MoveNext()) + { + return result; + } + else + throw new NoSubresourcesIdentifiedException(SR.GetString("NoSubresourcesIdentifiedException", _NCName)); } + #endregion + } } Index: XPath1SchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/XPath1SchemaPointerPart.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPath1SchemaPointerPart.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ XPath1SchemaPointerPart.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -1,6 +1,6 @@ #region using -using System; +using System; using System.Xml; using System.Xml.XPath; @@ -8,58 +8,58 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// xpath1() scheme based XPointer pointer part. - /// </summary> - internal class XPath1SchemaPointerPart : PointerPart - { - #region private members +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// xpath1() scheme based XPointer pointer part. + /// </summary> + internal class XPath1SchemaPointerPart : PointerPart + { + #region private members - private string _xpath; - - #endregion - - #region PointerPart overrides + private string _xpath; - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. - /// </summary> - /// <param name="doc">Document to evaluate pointer part on</param> - /// <param name="nm">Namespace manager</param> - /// <returns>Pointed nodes</returns> - public override XPathNodeIterator Evaluate(XPathNavigator doc, XmlNamespaceManager nm) - { - try - { - return XPathCache.Select(_xpath, doc, nm); - } - catch - { - return null; - } - } - - #endregion + #endregion - #region parser + #region PointerPart overrides - public static XPath1SchemaPointerPart ParseSchemaData(XPointerLexer lexer) - { - XPath1SchemaPointerPart part = new XPath1SchemaPointerPart(); - try - { - part.XPath = lexer.ParseEscapedData(); - } - catch (Exception e) - { - throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXPath1SchemeData", - e.Message)); - } - return part; - } + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. + /// </summary> + /// <param name="doc">Document to evaluate pointer part on</param> + /// <param name="nm">Namespace manager</param> + /// <returns>Pointed nodes</returns> + public override XPathNodeIterator Evaluate(XPathNavigator doc, XmlNamespaceManager nm) + { + try + { + return XPathCache.Select(_xpath, doc, nm); + } + catch + { + return null; + } + } - #endregion + #endregion + + #region parser + + public static XPath1SchemaPointerPart ParseSchemaData(XPointerLexer lexer) + { + XPath1SchemaPointerPart part = new XPath1SchemaPointerPart(); + try + { + part.XPath = lexer.ParseEscapedData(); + } + catch (Exception e) + { + throw new XPointerSyntaxException(SR.GetString("SyntaxErrorInXPath1SchemeData", + e.Message)); + } + return part; } + + #endregion + } } Index: XPointerSchema.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/XPointerSchema.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPointerSchema.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ XPointerSchema.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -5,37 +5,36 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// XPointer scheme. - /// </summary> - internal class XPointerSchema - { - - #region public members - - public enum SchemaType - { - Element, - Xmlns, - XPath1, - XPointer, - Unknown - } - public static IDictionary<string, SchemaType> Schemas = CreateSchemasTable(); +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// XPointer scheme. + /// </summary> + internal class XPointerSchema + { + #region public members - private static IDictionary<string, SchemaType> CreateSchemasTable() - { - IDictionary<string, SchemaType> table = new Dictionary<string, SchemaType>(4); - //<namespace uri>:<ncname> - table.Add(":element", SchemaType.Element); - table.Add(":xmlns", SchemaType.Xmlns); - table.Add(":xpath1", SchemaType.XPath1); - table.Add(":xpointer", SchemaType.XPointer); - return table; - } + public enum SchemaType + { + Element, + Xmlns, + XPath1, + XPointer, + Unknown + } + public static IDictionary<string, SchemaType> Schemas = CreateSchemasTable(); - #endregion + private static IDictionary<string, SchemaType> CreateSchemasTable() + { + IDictionary<string, SchemaType> table = new Dictionary<string, SchemaType>(4); + //<namespace uri>:<ncname> + table.Add(":element", SchemaType.Element); + table.Add(":xmlns", SchemaType.Xmlns); + table.Add(":xpath1", SchemaType.XPath1); + table.Add(":xpointer", SchemaType.XPointer); + return table; } + + #endregion + } } Index: ElementSchemaPointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/ElementSchemaPointerPart.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ElementSchemaPointerPart.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ ElementSchemaPointerPart.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -9,102 +9,102 @@ #endregion -namespace Mvp.Xml.XPointer -{ +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// element() scheme based <see cref="XPointer"/> pointer part. + /// </summary> + internal class ElementSchemaPointerPart : PointerPart + { + #region private fields + + private string _xpath; + + #endregion + + #region public members + /// <summary> - /// element() scheme based <see cref="XPointer"/> pointer part. + /// Equivalent XPath expression. /// </summary> - internal class ElementSchemaPointerPart : PointerPart + public string XPath { - #region private fields + get { return _xpath; } + set { _xpath = value; } + } - private string _xpath; + #endregion - #endregion - - #region public members - - /// <summary> - /// Equivalent XPath expression. - /// </summary> - public string XPath - { - get { return _xpath; } - set { _xpath = value; } - } - - #endregion + #region PointerPart overrides - #region PointerPart overrides + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. + /// </summary> + /// <param name="doc">Document to evaluate pointer part on</param> + /// <param name="nm">Namespace manager</param> + /// <returns>Pointed nodes</returns> + public override XPathNodeIterator Evaluate(XPathNavigator doc, + XmlNamespaceManager nm) + { + return XPathCache.Select(_xpath, doc, nm); + } - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. - /// </summary> - /// <param name="doc">Document to evaluate pointer part on</param> - /// <param name="nm">Namespace manager</param> - /// <returns>Pointed nodes</returns> - public override XPathNodeIterator Evaluate(XPathNavigator doc, - XmlNamespaceManager nm) - { - return XPathCache.Select(_xpath, doc, nm); - } - - #endregion + #endregion - #region parser + #region parser - /// <summary> - /// Parses element() based pointer part and builds instance of <c>ElementSchemaPointerPart</c> class. - /// </summary> - /// <param name="lexer">Lexical analizer.</param> - /// <returns>Newly created <c>ElementSchemaPointerPart</c> object.</returns> - public static ElementSchemaPointerPart ParseSchemaData(XPointerLexer lexer) + /// <summary> + /// Parses element() based pointer part and builds instance of <c>ElementSchemaPointerPart</c> class. + /// </summary> + /// <param name="lexer">Lexical analizer.</param> + /// <returns>Newly created <c>ElementSchemaPointerPart</c> object.</returns> + public static ElementSchemaPointerPart ParseSchemaData(XPointerLexer lexer) + { + //Productions: + //[1] ElementSchemeData ::= (NCName ChildSequence?) | ChildSequence + //[2] ChildSequence ::= ('/' [1-9] [0-9]*)+ + StringBuilder xpathBuilder = new StringBuilder(); + ElementSchemaPointerPart part = new ElementSchemaPointerPart(); + lexer.NextLexeme(); + if (lexer.Kind == XPointerLexer.LexKind.NCName) + { + xpathBuilder.Append("id('"); + xpathBuilder.Append(lexer.NCName); + xpathBuilder.Append("')"); + lexer.NextLexeme(); + } + int childSequenceLen = 0; + while (lexer.Kind == XPointerLexer.LexKind.Slash) + { + lexer.NextLexeme(); + if (lexer.Kind != XPointerLexer.LexKind.Number) { - //Productions: - //[1] ElementSchemeData ::= (NCName ChildSequence?) | ChildSequence - //[2] ChildSequence ::= ('/' [1-9] [0-9]*)+ - StringBuilder xpathBuilder = new StringBuilder(); - ElementSchemaPointerPart part = new ElementSchemaPointerPart(); - lexer.NextLexeme(); - if (lexer.Kind == XPointerLexer.LexKind.NCName) - { - xpathBuilder.Append("id('"); - xpathBuilder.Append(lexer.NCName); - xpathBuilder.Append("')"); - lexer.NextLexeme(); - } - int childSequenceLen = 0; - while (lexer.Kind == XPointerLexer.LexKind.Slash) - { - lexer.NextLexeme(); - if (lexer.Kind != XPointerLexer.LexKind.Number) - { - Debug.WriteLine(SR.InvalidTokenInElementSchemeWhileNumberExpected); - return null; - } - if (lexer.Number == 0) - { - Debug.WriteLine(SR.ZeroIndexInElementSchemechildSequence); - return null; - } - childSequenceLen++; - xpathBuilder.Append("/*["); - xpathBuilder.Append(lexer.Number); - xpathBuilder.Append("]"); - lexer.NextLexeme(); - } - if (lexer.Kind != XPointerLexer.LexKind.RRBracket) - { - throw new XPointerSyntaxException(SR.InvalidTokenInElementSchemeWhileClosingRoundBracketExpected); - } - if (part.NCName==null && childSequenceLen==0) - { - Debug.WriteLine(SR.EmptyElementSchemeXPointer); - return null; - } - part.XPath = xpathBuilder.ToString(); - return part; - } - #endregion + Debug.WriteLine(SR.InvalidTokenInElementSchemeWhileNumberExpected); + return null; + } + if (lexer.Number == 0) + { + Debug.WriteLine(SR.ZeroIndexInElementSchemechildSequence); + return null; + } + childSequenceLen++; + xpathBuilder.Append("/*["); + xpathBuilder.Append(lexer.Number); + xpathBuilder.Append("]"); + lexer.NextLexeme(); + } + if (lexer.Kind != XPointerLexer.LexKind.RRBracket) + { + throw new XPointerSyntaxException(SR.InvalidTokenInElementSchemeWhileClosingRoundBracketExpected); + } + if (part.NCName == null && childSequenceLen == 0) + { + Debug.WriteLine(SR.EmptyElementSchemeXPointer); + return null; + } + part.XPath = xpathBuilder.ToString(); + return part; } + #endregion + } } Index: XPointerParser.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/XPointerParser.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPointerParser.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ XPointerParser.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -6,121 +6,121 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// XPointer parser. - /// </summary> - internal class XPointerParser - { +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// XPointer parser. + /// </summary> + internal class XPointerParser + { - #region private members + #region private members - private static IDictionary<string, XPointerSchema.SchemaType> _schemas = XPointerSchema.Schemas; + private static IDictionary<string, XPointerSchema.SchemaType> _schemas = XPointerSchema.Schemas; - private static XPointerSchema.SchemaType GetSchema(XPointerLexer lexer, IList<PointerPart> parts) - { - string schemaNSURI; - if (lexer.Prefix != String.Empty) + private static XPointerSchema.SchemaType GetSchema(XPointerLexer lexer, IList<PointerPart> parts) + { + string schemaNSURI; + if (lexer.Prefix != String.Empty) + { + schemaNSURI = null; + //resolve prefix + for (int i = parts.Count - 1; i >= 0; i--) + { + PointerPart part = parts[i]; + if (part is XmlnsSchemaPointerPart) + { + XmlnsSchemaPointerPart xmlnsPart = (XmlnsSchemaPointerPart)part; + if (xmlnsPart.Prefix == lexer.Prefix) { - schemaNSURI = null; - //resolve prefix - for (int i=parts.Count-1; i>=0; i--) - { - PointerPart part = parts[i]; - if (part is XmlnsSchemaPointerPart) - { - XmlnsSchemaPointerPart xmlnsPart = (XmlnsSchemaPointerPart)part; - if (xmlnsPart.Prefix == lexer.Prefix) - { - schemaNSURI = xmlnsPart.Uri; - break; - } - } - } - if (schemaNSURI == null) - //No binding for the prefix - ignore pointer part - return XPointerSchema.SchemaType.Unknown; - } - else - schemaNSURI = String.Empty; - XPointerSchema.SchemaType schemaType = _schemas[schemaNSURI + ':' + lexer.NCName]; - return schemaType != null ? schemaType : XPointerSchema.SchemaType.Unknown; - } + schemaNSURI = xmlnsPart.Uri; + break; + } + } + } + if (schemaNSURI == null) + //No binding for the prefix - ignore pointer part + return XPointerSchema.SchemaType.Unknown; + } + else + schemaNSURI = String.Empty; + XPointerSchema.SchemaType schemaType = _schemas[schemaNSURI + ':' + lexer.NCName]; + return schemaType != null ? schemaType : XPointerSchema.SchemaType.Unknown; + } - #endregion + #endregion - #region public members - - public static Pointer ParseXPointer(string xpointer) - { - IList<PointerPart> parts; - XPointerLexer lexer; - lexer = new XPointerLexer( xpointer); + #region public members + + public static Pointer ParseXPointer(string xpointer) + { + IList<PointerPart> parts; + XPointerLexer lexer; + lexer = new XPointerLexer(xpointer); + lexer.NextLexeme(); + if (lexer.Kind == XPointerLexer.LexKind.NCName && !lexer.CanBeSchemaName) + { + //Shorthand pointer + Pointer ptr = new ShorthandPointer(lexer.NCName); + lexer.NextLexeme(); + if (lexer.Kind != XPointerLexer.LexKind.Eof) + throw new XPointerSyntaxException(SR.InvalidTokenAfterShorthandPointer); + return ptr; + } + else + { + //SchemaBased pointer + parts = new List<PointerPart>(); + while (lexer.Kind != XPointerLexer.LexKind.Eof) + { + if ((lexer.Kind == XPointerLexer.LexKind.NCName || + lexer.Kind == XPointerLexer.LexKind.QName) && + lexer.CanBeSchemaName) + { + XPointerSchema.SchemaType schemaType = GetSchema(lexer, parts); + //Move to '(' lexer.NextLexeme(); - if (lexer.Kind == XPointerLexer.LexKind.NCName && !lexer.CanBeSchemaName) - { - //Shorthand pointer - Pointer ptr = new ShorthandPointer(lexer.NCName); - lexer.NextLexeme(); - if (lexer.Kind != XPointerLexer.LexKind.Eof) - throw new XPointerSyntaxException(SR.InvalidTokenAfterShorthandPointer); - return ptr; - } - else + switch (schemaType) { - //SchemaBased pointer - parts = new List<PointerPart>(); - while (lexer.Kind != XPointerLexer.LexKind.Eof) - { - if ((lexer.Kind == XPointerLexer.LexKind.NCName || - lexer.Kind == XPointerLexer.LexKind.QName) && - lexer.CanBeSchemaName) - { - XPointerSchema.SchemaType schemaType = GetSchema(lexer, parts); - //Move to '(' - lexer.NextLexeme(); - switch (schemaType) - { - case XPointerSchema.SchemaType.Element: - ElementSchemaPointerPart elemPart = ElementSchemaPointerPart.ParseSchemaData(lexer); - if (elemPart != null) - parts.Add(elemPart); - break; - case XPointerSchema.SchemaType.Xmlns: - XmlnsSchemaPointerPart xmlnsPart = XmlnsSchemaPointerPart.ParseSchemaData(lexer); - if (xmlnsPart != null) - parts.Add(xmlnsPart); - break; - case XPointerSchema.SchemaType.XPath1: - XPath1SchemaPointerPart xpath1Part = XPath1SchemaPointerPart.ParseSchemaData(lexer); - if (xpath1Part != null) - parts.Add(xpath1Part); - break; - case XPointerSchema.SchemaType.XPointer: - XPointerSchemaPointerPart xpointerPart = XPointerSchemaPointerPart.ParseSchemaData(lexer); - if (xpointerPart != null) - parts.Add(xpointerPart); - break; - default: - //Unknown scheme - lexer.ParseEscapedData(); - break; - } - //Skip ')' - lexer.NextLexeme(); - //Skip possible whitespace - if (lexer.Kind == XPointerLexer.LexKind.Space) - lexer.NextLexeme(); - } - else - throw new XPointerSyntaxException(SR.InvalidToken); - } - return new SchemaBasedPointer(parts, xpointer); + case XPointerSchema.SchemaType.Element: + ElementSchemaPointerPart elemPart = ElementSchemaPointerPart.ParseSchemaData(lexer); + if (elemPart != null) + parts.Add(elemPart); + break; + case XPointerSchema.SchemaType.Xmlns: + XmlnsSchemaPointerPart xmlnsPart = XmlnsSchemaPointerPart.ParseSchemaData(lexer); + if (xmlnsPart != null) + parts.Add(xmlnsPart); + break; + case XPointerSchema.SchemaType.XPath1: + XPath1SchemaPointerPart xpath1Part = XPath1SchemaPointerPart.ParseSchemaData(lexer); + if (xpath1Part != null) + parts.Add(xpath1Part); + break; + case XPointerSchema.SchemaType.XPointer: + XPointerSchemaPointerPart xpointerPart = XPointerSchemaPointerPart.ParseSchemaData(lexer); + if (xpointerPart != null) + parts.Add(xpointerPart); + break; + default: + //Unknown scheme + lexer.ParseEscapedData(); + break; } + //Skip ')' + lexer.NextLexeme(); + //Skip possible whitespace + if (lexer.Kind == XPointerLexer.LexKind.Space) + lexer.NextLexeme(); + } + else + throw new XPointerSyntaxException(SR.InvalidToken); } + return new SchemaBasedPointer(parts, xpointer); + } + } - #endregion - } + #endregion + } } Index: XPointerLexer.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/XPointerLexer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPointerLexer.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ XPointerLexer.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -6,221 +6,221 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// XPointer lexical analyzer. - /// </summary> - internal class XPointerLexer +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// XPointer lexical analyzer. + /// </summary> + internal class XPointerLexer + { + + #region private members + + private string _ptr; + private int _ptrIndex; + private LexKind _kind; + private char _currChar; + private int _number; + private string _ncname; + private string _prefix; + private bool _canBeSchemaName; + + private string ParseName() { - - #region private members + int start = _ptrIndex - 1; + int len = 0; + while (LexUtils.IsNCNameChar(_currChar)) + { + NextChar(); len++; + } + return _ptr.Substring(start, len); + } - private string _ptr; - private int _ptrIndex; - private LexKind _kind; - private char _currChar; - private int _number; - private string _ncname; - private string _prefix; - private bool _canBeSchemaName; + #endregion - private string ParseName() - { - int start = _ptrIndex - 1; - int len = 0; - while (LexUtils.IsNCNameChar(_currChar)) - { - NextChar(); len ++; - } - return _ptr.Substring(start, len); - } + #region constructors - #endregion + public XPointerLexer(string p) + { + if (p == null) + throw new ArgumentNullException("pointer", SR.NullXPointer); + _ptr = p; + NextChar(); + } - #region constructors - - public XPointerLexer(string p) - { - if (p == null) - throw new ArgumentNullException("pointer", SR.NullXPointer); - _ptr = p; - NextChar(); - } - - #endregion + #endregion - #region public members + #region public members - public bool NextChar() - { - if (_ptrIndex < _ptr.Length) + public bool NextChar() + { + if (_ptrIndex < _ptr.Length) + { + _currChar = _ptr[_ptrIndex++]; + return true; + } + else + { + _currChar = '\0'; + return false; + } + } + + public LexKind Kind + { + get { return _kind; } + } + + public int Number + { + get { return _number; } + } + + public string NCName + { + get { return _ncname; } + } + + public string Prefix + { + get { return _prefix; } + } + + public bool CanBeSchemaName + { + get { return _canBeSchemaName; } + } + + public void SkipWhiteSpace() + { + while (LexUtils.IsWhitespace(_currChar)) + NextChar(); + } + + public bool NextLexeme() + { + switch (_currChar) + { + case '\0': + _kind = LexKind.Eof; + return false; + case '(': + case ')': + case '=': + case '/': + _kind = (LexKind)Convert.ToInt32(_currChar); + NextChar(); + break; + case '^': + NextChar(); + if (_currChar == '^' || _currChar == '(' || _currChar == ')') + { + _kind = LexKind.EscapedData; + NextChar(); + } + else + throw new XPointerSyntaxException(SR.CircumflexCharMustBeEscaped); + break; + default: + if (Char.IsDigit(_currChar)) + { + _kind = LexKind.Number; + int start = _ptrIndex - 1; + int len = 0; + while (Char.IsDigit(_currChar)) { - _currChar = _ptr[_ptrIndex++]; - return true; - } - else + NextChar(); len++; + } + _number = XmlConvert.ToInt32(_ptr.Substring(start, len)); + break; + } + else if (LexUtils.IsStartNameChar(_currChar)) + { + _kind = LexKind.NCName; + _prefix = String.Empty; + _ncname = ParseName(); + if (_currChar == ':') { - _currChar = '\0'; - return false; + //QName? + NextChar(); + _prefix = _ncname; + _kind = LexKind.QName; + if (LexUtils.IsStartNCNameChar(_currChar)) + _ncname = ParseName(); + else + throw new XPointerSyntaxException(SR.GetString("InvalidNameToken", _prefix, _currChar)); } - } - - public LexKind Kind - { - get { return _kind; } - } - - public int Number - { - get { return _number; } - } - - public string NCName - { - get { return _ncname; } - } - - public string Prefix - { - get { return _prefix; } - } - - public bool CanBeSchemaName - { - get { return _canBeSchemaName; } - } - - public void SkipWhiteSpace() - { + _canBeSchemaName = _currChar == '('; + break; + } + else if (LexUtils.IsWhitespace(_currChar)) + { + _kind = LexKind.Space; while (LexUtils.IsWhitespace(_currChar)) - NextChar(); - } - - public bool NextLexeme() + NextChar(); + break; + } + else + { + _kind = LexKind.EscapedData; + break; + } + } + return true; + } + + public string ParseEscapedData() + { + int depth = 0; + StringBuilder sb = new StringBuilder(); + while (true) + { + switch (_currChar) { - switch (_currChar) + case '^': + if (!NextChar()) + throw new XPointerSyntaxException(SR.UnexpectedEndOfSchemeData); + else if (_currChar == '^' || _currChar == '(' || _currChar == ')') + sb.Append(_currChar); + else + throw new XPointerSyntaxException(SR.CircumflexCharMustBeEscaped); + break; + case '(': + depth++; + goto default; + case ')': + if (depth-- == 0) { - case '\0' : - _kind = LexKind.Eof; - return false; - case '(': - case ')': - case '=': - case '/': - _kind = (LexKind)Convert.ToInt32(_currChar); - NextChar(); - break; - case '^': - NextChar(); - if (_currChar=='^' || _currChar=='(' || _currChar==')') - { - _kind = LexKind.EscapedData; - NextChar(); - } - else - throw new XPointerSyntaxException(SR.CircumflexCharMustBeEscaped); - break; - default: - if (Char.IsDigit(_currChar)) - { - _kind = LexKind.Number; - int start = _ptrIndex - 1; - int len = 0; - while (Char.IsDigit(_currChar)) - { - NextChar(); len ++; - } - _number = XmlConvert.ToInt32(_ptr.Substring(start, len)); - break; - } - else if (LexUtils.IsStartNameChar(_currChar)) - { - _kind = LexKind.NCName; - _prefix = String.Empty; - _ncname = ParseName(); - if (_currChar == ':') - { - //QName? - NextChar(); - _prefix = _ncname; - _kind = LexKind.QName; - if (LexUtils.IsStartNCNameChar(_currChar)) - _ncname = ParseName(); - else - throw new XPointerSyntaxException(SR.GetString("InvalidNameToken", _prefix, _currChar)); - } - _canBeSchemaName = _currChar=='('; - break; - } - else if (LexUtils.IsWhitespace(_currChar)) - { - _kind = LexKind.Space; - while (LexUtils.IsWhitespace(_currChar)) - NextChar(); - break; - } - else - { - _kind = LexKind.EscapedData; - break; - } - } - return true; - } - - public string ParseEscapedData() - { - int depth = 0; - StringBuilder sb = new StringBuilder(); - while (true) - { - switch (_currChar) - { - case '^': - if (!NextChar()) - throw new XPointerSyntaxException(SR.UnexpectedEndOfSchemeData); - else if (_currChar=='^' || _currChar=='(' || _currChar==')') - sb.Append(_currChar); - else - throw new XPointerSyntaxException(SR.CircumflexCharMustBeEscaped); - break; - case '(': - depth++; - goto default; - case ')': - if (depth-- == 0) - { - //Skip ')' - NextLexeme(); - return sb.ToString(); - } - else - goto default; - default: - sb.Append(_currChar); - break; - } - if (!NextChar()) - throw new XPointerSyntaxException(SR.UnexpectedEndOfSchemeData); - } - } - - public enum LexKind - { - NCName = 'N', - QName = 'Q', - LRBracket = '(', - RRBracket = ')', - Circumflex = '^', - Number = 'd', - Eq = '=', - Space = 'S', - Slash = '/', - EscapedData = 'D', - Eof = 'E' + //Skip ')' + NextLexeme(); + return sb.ToString(); + } + else + goto default; + default: + sb.Append(_currChar); + break; } - - #endregion + if (!NextChar()) + throw new XPointerSyntaxException(SR.UnexpectedEndOfSchemeData); + } } + + public enum LexKind + { + NCName = 'N', + QName = 'Q', + LRBracket = '(', + RRBracket = ')', + Circumflex = '^', + Number = 'd', + Eq = '=', + Space = 'S', + Slash = '/', + EscapedData = 'D', + Eof = 'E' + } + + #endregion + } } Index: PointerPart.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/PointerPart.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PointerPart.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ PointerPart.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -6,23 +6,24 @@ #endregion -namespace Mvp.Xml.XPointer -{ - /// <summary> - /// Part of SchemaBased <see cref="XPointer"/> pointer. - /// </summary> - internal abstract class PointerPart { +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// Part of SchemaBased <see cref="XPointer"/> pointer. + /// </summary> + internal abstract class PointerPart + { - #region public methods + #region public methods - /// <summary> - /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. - /// </summary> - /// <param name="doc">Document to evaluate pointer part on</param> - /// <param name="nm">Namespace manager</param> - /// <returns>Pointed nodes</returns> - public abstract XPathNodeIterator Evaluate(XPathNavigator doc, XmlNamespaceManager nm); + /// <summary> + /// Evaluates <see cref="XPointer"/> pointer part and returns pointed nodes. + /// </summary> + /// <param name="doc">Document to evaluate pointer part on</param> + /// <param name="nm">Namespace manager</param> + /// <returns>Pointed nodes</returns> + public abstract XPathNodeIterator Evaluate(XPathNavigator doc, XmlNamespaceManager nm); - #endregion - } + #endregion + } } Index: XPointerReader.cs =================================================================== RCS file: /cvsroot/mvp-xml/XPointer/v2/src/XPointerReader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XPointerReader.cs 16 Oct 2005 15:17:03 -0000 1.1 +++ XPointerReader.cs 16 Oct 2005 16:02:15 -0000 1.2 @@ -1,7 +1,7 @@ #region using using System; -using System.Xml; +using System.Xml; using System.Xml.XPath; using System.Xml.Schema; using System.IO; @@ -11,463 +11,463 @@ #endregion -namespace Mvp.Xml.XPointer -{ +namespace Mvp.Xml.XPointer +{ + /// <summary> + /// <c>XPointerReader</c> implements XPointer Framework in + /// a fast, non-caching, forward-only way. <c>XPointerReader</c> + /// supports XPointer Framework, element(), xmlns(), xpath1() and + /// xpointer() (XPath subset only) XPointer schemes. + /// </summary> + /// <remarks>See <a href="http://mvp-xml.sf.net/xpointer">XPointer.NET homepage</a> for more info.</remarks> + /// <author>Oleg Tkachenko, ol...@tk...</author> + public class XPointerReader : XmlReader, IHasXPathNavigator + { + #region private members + + //Underlying reader + private XmlReader _reader; + //Nodes selected by xpointer + private XPathNodeIterator _pointedNodes; + //Document cache + private static IDictionary<string, WeakReference> _cache; + + /// <summary> - /// <c>XPointerReader</c> implements XPointer Framework in - /// a fast, non-caching, forward-only way. <c>XPointerReader</c> - /// supports XPointer Framework, element(), xmlns(), xpath1() and - /// xpointer() (XPath subset only) XPointer schemes. + /// Initializes the <c>XPointerReader</c>. /// </summary> - /// <remarks>See <a href="http://mvp-xml.sf.net/xpointer">XPointer.NET homepage</a> for more info.</remarks> - /// <author>Oleg Tkachenko, ol...@tk...</author> - public class XPointerReader : XmlReader, IHasXPathNavigator - { - #region private members + private void Init(XPathNavigator nav, string xpointer) + { + Pointer pointer = XPointerParser.ParseXPointer(xpointer); + _pointedNodes = pointer.Evaluate(nav); + //There is always at least one identified node + //XPathNodeIterator is already at the first node + _reader = new XPathNavigatorReader(_pointedNodes.Current); + } - //Underlying reader - private XmlReader _reader; - //Nodes... [truncated message content] |
From: Oleg T. <he...@us...> - 2005-10-16 15:23:47
|
Update of /cvsroot/mvp-xml/Common/v2/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19430/v2/doc Added Files: changelog.txt Log Message: --- NEW FILE: changelog.txt --- --------------------------------------------------------- September 23, 2004 Initial setup. Folder contains any documentation related to the module. |
From: Oleg T. <he...@us...> - 2005-10-16 15:23:41
|
Update of /cvsroot/mvp-xml/Common/v2/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19430/v2/lib Added Files: changelog.txt Log Message: --- NEW FILE: changelog.txt --- --------------------------------------------------------- September 23, 2004 Initial setup. Will contain external libraries referenced by the project. |
From: Oleg T. <he...@us...> - 2005-10-16 15:23:41
|
Update of /cvsroot/mvp-xml/Common/v2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19430/v2 Added Files: .cvsignore license.txt Log Message: --- NEW FILE: .cvsignore --- bin obj *.user *.suo --- NEW FILE: license.txt --- 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. 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. 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. 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. |
From: Oleg T. <he...@us...> - 2005-10-16 15:22:49
|
Update of /cvsroot/mvp-xml/Common/v2/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19340/doc Log Message: Directory /cvsroot/mvp-xml/Common/v2/doc added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 15:22:42
|
Update of /cvsroot/mvp-xml/Common/v2/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19283/lib Log Message: Directory /cvsroot/mvp-xml/Common/v2/lib added to the repository |
From: Oleg T. <he...@us...> - 2005-10-16 15:18:49
|
Update of /cvsroot/mvp-xml/XPointer/v2/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18769/v2/doc Added Files: changelog.txt Log Message: --- NEW FILE: changelog.txt --- --------------------------------------------------------- September 28, 2004 Initial setup. Folder contains any documentation related to the module. |
From: Oleg T. <he...@us...> - 2005-10-16 15:18:49
|
Update of /cvsroot/mvp-xml/XPointer/v2/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18769/v2/lib Added Files: changelog.txt Log Message: --- NEW FILE: changelog.txt --- --------------------------------------------------------- September 28, 2004 Initial setup. Will contain external libraries referenced by the project. |