May 5, 2019

Bootstrap your config.xml

Design on the config.xml






I will start first with the resources I used to create this post:









All of the above products and links are equally important and were used to create the current script.


The story 

The config.xml  is the "kernel" of all the Oracle FMW 11g /12c domains.

This is the  "big-picture" of the Oracle WebLogic Server [WLS] domain and the WLS is the "kernel"  for all the Oracle FMW 11g or 12c products.

Make sure you never play with this file without knowing what you add or remove from it and always do a backup before whatever the future updates.

Config.xml is a an xml  file and it provides a one stop only to understand your   domain-environment.

If your domain is a small one then just by scrolling up and down and "Crtl+F" should be enough to  have all the info you need.

If the parameters have the default values then sometimes you will not find them in the config.xml. Once you update them from the Admin Console  the parameters will also be visible in the config.xml no matter the value you define - even if you later switch back to the default value.

Note: I will not go into the xml vs json story; for now the main file is an xml one so end of story.


The config.xml can be  a very long  file. Especially if you have not only a basic WLS domain but a FMW one.

So let's say you just installed a SOA Suite/BPM Suite/OSB  and  voilà just a number of default ~ 90  apps  and ~ 120 libraries; by default you have not only 90+120 xml elements but (90+120) * 7 different xml tags and all are only about the apps and libraries you have.

You will also end up  with  like ~ 25 xml rows to describe the data sources;  so  add here 25 * 3 more rows - is  multiplied by 3  since there are 3 xml tags used to describe each of the data source.

And, of course, you need to  count the many  xml tags  about the servers from the  domain and... boy it  gets big !  Good luck to   parse this xml  file using only your eyes.

Of course if you have access  to the Admin Console then maybe you will not need to open this config.xml file. Maybe.

But how about a scenario when you end up with only this config.xml file and nothing more ? 


Of course you can use the "Ctrl+F" or even some nice grep or other Notepad++ plugins to help you.  Or you can stop for 1 sec, understand that you have an xml file at the end  and [once you did a backup of this file]  handle it as any xml files.

Hello XSLT ! Yes  you can now  transform this xml file into a nice HTML one.

And since is HTML file why not add some nice design features ?

Hello Bootstrap !

For now I'm very much into the Bootstrap framework:  is easy to add the links from the remote repository [so you don't have to install it on your machine and this will make sense later] , the documentation is full of details so is easy to  find and add what you need and it looks  very nice. 

On top of this, you can also use a tool like Bootstrap Studio to create a pattern of your future files.


In addition to all of this you can add some custom CSS here and there and even the nice and light JS library from the w3school.  Like for example to add a search option.

You can also find a nice JS script that will export all the data to excel... since no matter how much we like to think about the new fancy buzz words we will always end up using the 3 main Office tools.




The XSL script 

You will find the script as xsl here: GitHub: config-xml-xslt.

There is no need to describe it into full details. Is a combination of basic xslt-xpath per each main config.xml components + the Bootstrap design + some extra CSS details + some JS script+ basic HTML.

If you are not into the Oracle WLS-FMW products then this  script will make no sense and will be for no help. If you are into such Oracle WLS-FMW products  then just download the script and use it and there is no need to add more; once you see the output you will understand it.



How to use it


Here you have 2 main options:

option #1

The option #1  is the fastest one and you just need  to open your config.xml file in a Notepad-like tool and to add the next line below the  xml first row. Is like an import pattern.

<?xml-stylesheet  type= "text/xsl" href = "config.xsl"?>

So at the  end your config.xml  file will start with:

<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet  type= "text/xsl" href = "config.xsl"?>


You can then open the config.xml file using the Firefox browser and voilà the new approach: you now have a nice "web-site".

You can also use some other  Chrome-based browsers but for this you need to  add the option "--allow-file-access-from-files".
Check  Google for "How can I make XSLT work in chrome?". 

However I think we should always have al least 2 main browsers: Firefox and a Chrome-based one.


Right-click and check the "View page source" now; yes:  it is still an xml file.

Note: The recommended pattern is to use the below option #2.



option #2

The option #2 is to use the Saxon tool to generate the HTML file using the config.xml  and the config.xsl files. Now, you will end up with an HTML file and  you can use whatever the browsers you want.

Actually, if you want to use the XSLT 2  then you will need  the Saxon tool since browsers now have no support  for  version 2; it only covers the version 1... I'm somehow disappointed by this but whatever.

Make sure you "Download Latest Version" of the Saxon XSLT and XQuery Processor -  The Saxon XSLT and XQuery processor, developed by Saxonica:

 

Place inside a folder that has the config.xml & config.xsl files the 3 new files:
  • saxon9he.jar
  • saxon9-test.jar
  • saxon9-xqj.jar

Note: Never use the DOMAIN_HOME/config location; always copy the config.xml file into a different location and use the Saxon tools.

Now, just run the below:

java -jar saxon9he.jar -s:config.xml -xsl:config.xsl -o:config.html

  • config.xml is the source (-s) config.xml file.
  • config.xsl is the XSLT template used (-xsl).
  • config.html  is the HTML output  (-o).
  • Of course, you can rename your files; but use the same pattern.




>pwd
/home/leo/XSLT_CONFIG-XML

>ls
config.xml  config.xsl  saxon9he.jar  saxon9-test.jar  saxon9-xqj.jar

>java -jar saxon9he.jar -s:config.xml -xsl:config.xsl -o:config.html


Now we can now see the new HTML file:

 




Other details

Do keep in mind that this script  covers the main domain settings- xml elements.  That is if you want more of such elements to be included you will need to manually add them in the script.


In addition, there is also the chance to see many  empty columns-rows  and this is because for those xml elements  there is currently no value found in your  config.xml file. The scripts  only reflects  what the config.xml file has and nothing more.

Is this a problem ? No, because this script has the purpose only to help you with some design and a more friendly look-and feel of the config.xml and that is all. In addition, the focus was to add the main details that are needed for an admin and not the entire config.xml details; for some in deep details you will still need to manually check the config.xml.

If you want to create  a script  that will be more complex and where only the elements having some value should be  printed and whatever more you think you need I'm sorry  but it gets already more complicated and parsing a config.xml file  is not the best idea to start with. If you need something more complex then use the time to create a script that connects to the MBeans and select your data from the MBeans directly.

April 2020 Update: for a more complex alternative check the Well Known Attributes WLST.pλ.

The idea around this demo script was to have something very fast and that looks fancy enough and that could be even updated in the future but again all this to be done -maybe not always elegant- simple and fast.




Note: For the  design I used the Oracle Brand Color -since is about an Oracle product (Oracle WLS- FMW) and I also like the Oracle's color palette- but you can customize it and use your own color palette.


In the near future a new script  that covers the JDBC details [based on all the data sources related xml files] will be shared.


Note: The script was tested mostly on a 12c WLS domain.