3 Replies Latest reply: Feb 1, 2013 4:00 PM by Aegis Kleais RSS

    Can ColdFusion Do XML Inheritence like IIS?

    Aegis Kleais Community Member

      One feature I like about IIS7 is how it uses XML files for its configuration and then allows inheritance.  For example, the config which sets default values at the SERVER level can be overwritten at the SITE level (and even at folder/files levels below it)

       

      Likewise, I have a FRAMEWORK config files (XML) which sets the defaults, an APPLICATION config XML file below it, and a MODULE config file below it.

       

      Does anyone know if it's possible for ColdFusion to come up with a "final" XML object which respectively does the same thing?

       

      For example, if framework.xml had a node called <apples> and an attribute called quantity="0" and the module.xml config file had the EXACT same node at the same level with an attribute of "4", then the final XML object that is build would say 4 (since Module overrides Application overrides Framework)

       

      In the event keys were specified that didn't exist, they would be maintained, it would just be assumed that no changes were made to these nodes.

        • 1. Re: Can ColdFusion Do XML Inheritence like IIS?
          MisterT

          I think it would be a case of reading each level and creating or updating a structure based on the node values.

          If the node does not exist already create it , if it does exist and you have a new value update it.

          • 2. Re: Can ColdFusion Do XML Inheritence like IIS?
            BKBK Community Member

            I understand what you mean. However, I think the term inheritance is too strong for what you describe. For, a site is not a server. I agree more with the word overwrite.

             

            Another difficulty is that you compare apples with pears. ColdFusion is more or less an application server, whereas IIS is a web server. In any case, in ColdFusion, too, server settings in XML configuration files can be overwritten at page level. However, you often don't need to know anything about the files or even about their existence. The changes happen under the hood.

             

            For example, when you write code that uses adminapi to create a datasource, ColdFusion will modify the system file neo-datasource.xml accordingly. As a second example, consider <cfsetting RequestTimeout = "300">. Running this code on a page will override the global request timeout value set in the ColdFusion Administrator.

            • 3. Re: Can ColdFusion Do XML Inheritence like IIS?
              Aegis Kleais Community Member

              In my mind, I envisioned it that the FRAMEWORK config file provides default settings for all applications.  The APPLICATION config can override those, as well as provide settings for values that really are independent of the framework.  Together, the "merged/overwritten" value here would be stored into the application scope for the duration.

               

              On a request by request basis, the MODULE config would be loaded up and override values that the application-level in-memory structure has, but that would be stored in the REQUEST scope, to die after the user's request.  It would not modify the actual data in the APPLICATION or FRAMEWORK config files, just override them for the request.

               

              I think something like this offers modularity and flexibility to the framework.  Of course, I have to create XSD files to validate the configuration files against to ensure they support the right keys, attributes and values, but it seems like CF should be able to handle this with a UDF function call.