2 Replies Latest reply on Nov 25, 2011 1:36 AM by Eyal NameToUpdate

    grammar to edit xml attributes

      Hi All,


      I'm looking for a way to edit the attributes in a web.config xml file.


      The grammar "web.config.xml.gm" is working fine when the data is in tags:


            <RequestTimeout>10000</RequestTimeout>      <StatusReportInterval>20000</StatusReportInterval>


      However, some of the files are structured with the data in attributes:


      <cc requestTimeout="10000" statusReportInterval="20000" useSsl="true"/>


      In the second structure, I have to set all the attributes within the tag.

      I would like to change the value of "useSsl", but leave the other values unchanged.

      The "web.config.xml.gm" grammar forces me to overwrites the other values too.


      I found this discussion:


      but it didn't provide an answer, the instruction in "xml.gm" talk about handling duplicate tags - while I need the attributes.


      Did anyone wrote a grammar that can do that?


      Is it possible to modify the xml.gm to go deeper into the attributes of the xml tags?




        • 1. grammar to edit xml attributes
          Bill Robinson

          you can create your own grammar file if you like:



          • 2. Re: grammar to edit xml attributes

            Hi Bill,


            Thanks for the quick answer!


            I looked into the document, but on the last page, under "Limitations and possible enhancements" section, I found this:


            2) The parser is line-oriented, i.e. each rule in grammar is used to parse lines that match the format coded in the rule. So a line which is in the same format as coded in the rule, and if it can be split into two or more lines (without the line continuation marker at the end) can not be parsed. To parse that we again need to write new rules, one for each line. Clearly this is not practical. We can enhance the parser to remove the line-oriented restriction.

            In the configuration files, I have lines that have 3 attributes:


            <cc requestTimeout="10000" statusReportInterval="20000" useSsl="true"/>


            but also lines with 4, 5, and even 51 attributes.


            This means I have to write a different rule for every line with a different number of attributes.

            (and add a new rule to the grammer every time a developer decides to add new attributes - increasing the count to 52)


            The document states: "We can enhance the parser to remove the line-oriented restriction"

            Can I enhance the parser, or does "We" refer to the Blade Logic development team?