2 Replies Latest reply on Oct 22, 2007 12:23 PM by Matthew Sacks

    XML Attribute Compliance

      I am trying to check compliance and remediate 100 - 200 .Net web.config files per server in my environment. A web.config is just a XML file with a predefined format.


      The section I want to check looks like this:




      I this case Value2 is the value for the batch attribute. Value4 is actually the one I want to test. I need to be able to handle this type of situation.


      Is there a way to do this using the XML or web.config grammar files? Can I make a custom grammar file to handle it?


      Is there a different way I should be going about this all together? Currently I have NSH script that checks and changes the files. The script is kind of a mess and causing me some problems. I'd prefer to get it out of script somehow.

        • 1. Re: XML Attribute Compliance

          I've messed around with XML grammars before, and I believe you can split up lines into individual fields so that the name becomes an individual item as opposed to a numerated value in the ValueN column. It just takes some playing around. Keep in mind whenever you make a change you're going to have to restart your application server to pick up the new grammar file (or any changes you make to it).


          Here is the content of the xml.gm file that tells how to create your own grammars to go about parsing XML files:


          1. if there are duplicate nodes in the xml, then define a new grammar and

          2. associate the new grammar with that xml configuration file instead of using

          3. xml.gm for every xml file. To define a new grammar file for an xml file with

          4. duplicate nodes, use the example below.



          1. <servlet-name>invoker</servlet-name>

          2. <init-param>

          3. <param-name>debug</param-name>

          4. <param-value>0</param-value

          5. </init-param>

          6. <init-param>

          7. <param-name>logVerbosityLevel</param-name>

          8. <param-value>WARNING</param-value>

          9. </init-param>


          1. <servlet-name>jsp</servlet-name>

          2. <init-param>

          3. <param-name>logVerbosityLevel</param-name>

          4. <param-value>WARNING</param-value>

          5. </init-param>



          1. In the example above, "servlet" and "init-param" are duplicates. Now a

          2. duplcate node can be disambiguated by its attributes, text value or / and

          3. its children. So each duplicate node and each child that helps in

          4. disambiguate a duplicate have to be present with the following syntax:


          1. nodeName D/P;attributName[,attributeName];1/0;childName[,childName]


          1. All the duplicate nodes have "D" in the first column. If the attributes help

          2. in disambiguation then they are listed separated by commas in the second

          3. column. Otherwise this column can be left empty. If the text value is used in

          4. disambiguation, then the third column should contain 1 (otherwise it can left

          5. empty). If the children help in disambiguation then they are listed separated

          6. by commas in the fourth column. Otherwise this column can be left empty. Note

          7. that if a child helps disambiguating a parent, then it has to appear on a

          8. separate line. If the child unique by itself then its second column contains

          9. a "P" (as it is helping the parent) but it itself is a duplicate, it should

          10. contain a "D" in the second column.


          #servlet D;;;servlet-name

          #servlet-name P;;1;

          #init-param D;;;param-name

          #param-name P;;1;

          • 2. Re: XML Attribute Compliance

            Hi Michael,

            I am having a similar problem with the xml grammar. Were you able to get the grammar file to work with your specific xml document?