NAnt Wordfile - XML Syntax

NAnt Wordfile - XML Syntax

15
Basic UserBasic User
15

    Dec 01, 2006#1

    Hi,

    I'm trying to set up a word file for the NAnt build file xml format.

    I want to have it behave as XML in ultraedit, but, to also be different to XML in it's highlighting and keywords etc.

    Now, IIRC, the recent changes to syntax highlighting in Ultraedit prevent you having more than one XML_LANG or HTML_LANG, so I can't do this?

    I'm afraid I haven't (Yet) had time to do any experimenting with this, can anyone offer any advice as to a generic approach, or provide a full latest nant build file that recognises all the nant tasks?
    I'm not the anti-christ, I just do his work.

    6,682583
    Grand MasterGrand Master
    6,682583

      Re: Different wordfiles for different XML files

      Dec 01, 2006#2

      First more than 1 XML_LANG should be possible with a File Names = definition.

      But better is to use a project/workspace where you can add your XML files which need a different XML highlighting definition and use a project specific wordfile - a second wordfile which contains a different XML highlighting definition. Whenever you load this project/workspace, the XML files are highlighted with this alternate wordfile. When you close the project/workspace the main wordfile becomes active again.
      Best regards from an UC/UE/UES for Windows user from Austria

      15
      Basic UserBasic User
      15

        Dec 05, 2006#3

        Ok here is a clip of word file:

        Code: Select all

        /L12"NAnt" XML_LANG Noquote Block Comment On = <!-- Block Comment Off = --> File Extensions = build
        /Delimiters = ~@$%^&*()+=|\{};"'<> ,
        /Function String = "name=*">"
        /Open Brace Strings =  "{" "(" "[" "<"
        /Close Brace Strings = "}" ")" "]" ">"
        /C1"Elements" STYLE_ELEMENT
        <code </code
        
        However, the element <code> does not highlight (but <code name="fish">blah</code> does highlight the first code but not the closing code...

        Suggestions?
        I'm not the anti-christ, I just do his work.

        6,682583
        Grand MasterGrand Master
        6,682583

          Dec 06, 2006#4

          Look at the default wordfile.txt at language HTML (for example LI). There you will see that you have to specify all possible variants of an element which are according to your example:

          <code> <code </code>
          Best regards from an UC/UE/UES for Windows user from Austria

          15
          Basic UserBasic User
          15

            Dec 06, 2006#5

            hmm that is somewhat unfortunate.

            Thanks for the help, I now have a NAnt buildfile that builds an ultraedit wordfile for NAnt buildfiles based on your specific NAnt configuration.

            Recursively lovely.
            I'm not the anti-christ, I just do his work.

            112
            Power UserPower User
            112

              Dec 06, 2006#6

              That should be interesting.

              If it's not too long, can you post it here or provide a link/

              TIA,
              Paolo
              There is no such thing as an inconsistently correct system...
              Therefore, aim for consistency; in the expectation of reaching correctness!

              15
              Basic UserBasic User
              15

                Mar 16, 2007#7

                Sorry, meant to post this some time back, I've tried to attach but I get:

                Code: Select all

                Upload Error: Could not upload Attachment to ./uploads/forums/wordfile.rar.
                
                So here is the code itself (128 lines, not too big)

                Code: Select all

                <?xml version="1.0"?>
                <project name="Ultraedit Wordfile Builder" default="buildwordfile">
                    <property name="wordfile.txt" value="wordfile.nant.txt" overwrite="false" />
                
                    <target name="buildwordfile">
                      <script language="C#" prefix="ue">
                        <imports>
                          <import namespace="System.Collections.Generic"/>
                          <import namespace="System.IO"/>
                          <import namespace="System.Text"/>
                          <import namespace="System.Xml" />
                        </imports>
                        <code>
                            <![CDATA[
                              [TaskName("wordfile")]
                              public class WordfileTask : Task {
                                #region Private Instance Fields
                                    private string _wordfile="wordfile.txt";
                                    private string _xsd="nant.xsd";
                                    private string _message;
                
                                    private SortedDictionary<String, String> elements = new SortedDictionary<String, String>();
                                    private SortedDictionary<String, String> attributes = new SortedDictionary<String, String>();
                                #endregion Private Instance Fields
                
                                #region Private methods
                                private void parseXSD()
                                {
                                  XmlDocument d = new XmlDocument();
                                  d.Load(_xsd);
                                  XmlNamespaceManager ns = new XmlNamespaceManager(d.NameTable);
                                  ns.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
                                  Console.WriteLine("boo");
                                  XmlNodeList l = d.DocumentElement.SelectNodes("//xs:element", ns);
                                  foreach(XmlNode n in l)
                                  {
                                      if (!elements.ContainsKey(n.Attributes["name"].Value.ToString()))
                                      {
                                          elements.Add(n.Attributes["name"].Value.ToString(), n.Attributes["name"].Value.ToString());
                                      }
                                  }
                                  l = d.DocumentElement.SelectNodes("//xs:attribute", ns);
                                  foreach (XmlNode n in l)
                                  {
                                      if (!attributes.ContainsKey(n.Attributes["name"].Value.ToString()))
                                      {
                                          attributes.Add(n.Attributes["name"].Value.ToString(), n.Attributes["name"].Value.ToString());
                                      }
                                  }
                                }
                
                                private void writeWordfile()
                                {
                                  StreamWriter s = new StreamWriter("wordfile.txt");
                                  s.WriteLine("/L13\"NAnt\" XML_LANG Noquote Block Comment On = <!-- Block Comment Off = --> File Extensions = build");
                                  s.WriteLine("/Delimiters = ~@$%^&*()+=|\\{};\"'<> ,");
                                  s.WriteLine("/Function String = \"name=*\">\"");
                                  s.WriteLine("/Open Brace Strings =  \"{\" \"(\" \"[\" \"<\"");
                                  s.WriteLine("/Close Brace Strings = \"}\" \")\" \"]\" \">\"");
                                  s.Write("/C1\"Elements\" STYLE_ELEMENT");
                                  char c = '\0';
                                  foreach(KeyValuePair<String,String> st in elements)
                                  {
                                      if (st.Value.IndexOf(c) != 0)
                                      {
                                          c = st.Value.ToCharArray()[0];
                                          s.WriteLine("");
                                      }
                                      s.Write("<" + st.Value + " </" + st.Value + " <" + st.Value + "> </" + st.Value + "> ");
                                  }
                                  s.WriteLine("\n// />");
                                  s.WriteLine(">");
                                  s.WriteLine("<");
                                  s.WriteLine("<%");
                                  s.WriteLine("%>");
                                  s.WriteLine("?>");
                                  s.WriteLine("<? <?xml");
                                  s.WriteLine("]]>");
                                  s.WriteLine("<![CDATA[");
                                  s.Write("/C2\"Attributes\" STYLE_ATTRIBUTE");
                                  s.Flush();
                                  foreach (KeyValuePair<String, String> st in attributes)
                                  {
                                      if (st.Value.IndexOf(c) != 0)
                                      {
                                          c = st.Value.ToCharArray()[0];
                                          s.WriteLine("");
                                          s.Flush();
                                      }
                                      s.Write(st.Value + "= ");
                                  }
                                  s.Close();
                
                                }
                
                                #endregion Private methods
                
                                #region Public Instance Properties
                
                                [TaskAttribute("wordfilePath", Required=true)]
                                public string FileName {
                                  get { return _wordfile; }
                                  set { _wordfile = value; }
                                }
                
                                [TaskAttribute("xsdPath", Required=true)]
                                public string XsdPath {
                                  get { return _xsd; }
                                  set { _xsd = value; }
                                }
                
                                #endregion Public Instance Properties
                
                                #region Override implementation of Task
                
                                protected override void ExecuteTask() {
                                  parseXSD();
                                  writeWordfile();
                                }
                                #endregion Override implementation of Task
                              }
                            ]]>
                        </code>
                      </script>
                      <nantschema output="NAnt.xsd"/>
                      <wordfile wordfilePath="wordfile.txt" xsdPath="NAnt.xsd" />
                    </target>
                </project>
                
                I'm not the anti-christ, I just do his work.

                112
                Power UserPower User
                112

                  Mar 17, 2007#8

                  Thanx, (forgotten I'd asked for it :) )

                  Lookz Kool!

                  Paolo
                  There is no such thing as an inconsistently correct system...
                  Therefore, aim for consistency; in the expectation of reaching correctness!