This was fun :)
The project that I'm working on it pretty complex and I did talk about couple of things that I'm doing at my current client during KScope, some of might even saw the videos. Hey it is pretty exciting stuff.
I'm fortunate that they are the first client to use the cutting edge (upcoming) feature in PBCS and I'm part of that team.
Now this post is nothing related to that (in some way yes it is related), this one is about stylizing the LCM artifact listing (or understand what is in that file!!!).
I was assigned a task of finding out the objects existing in PBCS (specially forms), now if this was on-prem I could fire an SQL command and easily get the list. Hey hey this is PBCS, we don't allow any backend queries here.
Only option left is to use the Artifact Snapshot listing.xml and go through the list of XML files and generate the list, well you all know that I'm a lazy guy and I don't like doing that. (going through the files if they are under too many folders is a big task)
Now we all know that listing.xml is an XML file and contains the listing information of the current LCM (yeah we all know that, otherwise why would someone name it with an XML extension ;))
How can we look at that file, it's all in one single line?. Well I get it, I use Notepad ++ and with the XML highlighting it is easier to read the file. (well it is still a single line!!!).
So here comes a nice plugin in Notepad++ (I did promise that I'll soon write a post on all the useful plugins that I use in Notepad++, patience dear reader, it is coming :))
I use a plugin called XML Tools in Notepad++ and if you are working with XML files then that is a great plugin to have.
Open listing.xml file in Notepad++
Select XML tools from plugins and select "Pretty print (XML only - with line breaks), oh yes there are lot of options, you can enable the syntax check and it'll let you if you didn't close any headers/ syntax issues in the XML file.
Here comes the magic now
The big one liner became a pretty readable XML file now. Okay I admit that I'm still nowhere near my assigned task, I'm nearing there.
I don't know how many of you've heard about XSLT (if you've not; here is the link), it is a language used for transforming XML files.
Couple of things to keep in mind before starting with XSLT (This is my version of XSLT and XML explanation, you might find differences with the theory world ;))
You need to tell the language where to start the transformation and this is going to be nothing but the root of XML and in our case artifactListing (if you look at listing.xml the entire contents are within this node)
So we got our starting point, now you've two inner nodes inside artifactListing which are folder and resource (oh yeah it's just those two) and their attributes.
Now I see you are getting where I'm going with this, if you don't just be patient.
So all I've to do to get the list of forms is to create an XSLT and ask it to give me the following attributes for resource.
So let's look at the xsl file
The project that I'm working on it pretty complex and I did talk about couple of things that I'm doing at my current client during KScope, some of might even saw the videos. Hey it is pretty exciting stuff.
I'm fortunate that they are the first client to use the cutting edge (upcoming) feature in PBCS and I'm part of that team.
Now this post is nothing related to that (in some way yes it is related), this one is about stylizing the LCM artifact listing (or understand what is in that file!!!).
I was assigned a task of finding out the objects existing in PBCS (specially forms), now if this was on-prem I could fire an SQL command and easily get the list. Hey hey this is PBCS, we don't allow any backend queries here.
Only option left is to use the Artifact Snapshot listing.xml and go through the list of XML files and generate the list, well you all know that I'm a lazy guy and I don't like doing that. (going through the files if they are under too many folders is a big task)
Now we all know that listing.xml is an XML file and contains the listing information of the current LCM (yeah we all know that, otherwise why would someone name it with an XML extension ;))
How can we look at that file, it's all in one single line?. Well I get it, I use Notepad ++ and with the XML highlighting it is easier to read the file. (well it is still a single line!!!).
So here comes a nice plugin in Notepad++ (I did promise that I'll soon write a post on all the useful plugins that I use in Notepad++, patience dear reader, it is coming :))
I use a plugin called XML Tools in Notepad++ and if you are working with XML files then that is a great plugin to have.
Open listing.xml file in Notepad++
Select XML tools from plugins and select "Pretty print (XML only - with line breaks), oh yes there are lot of options, you can enable the syntax check and it'll let you if you didn't close any headers/ syntax issues in the XML file.
Here comes the magic now
The big one liner became a pretty readable XML file now. Okay I admit that I'm still nowhere near my assigned task, I'm nearing there.
I don't know how many of you've heard about XSLT (if you've not; here is the link), it is a language used for transforming XML files.
Couple of things to keep in mind before starting with XSLT (This is my version of XSLT and XML explanation, you might find differences with the theory world ;))
You need to tell the language where to start the transformation and this is going to be nothing but the root of XML and in our case artifactListing (if you look at listing.xml the entire contents are within this node)
So we got our starting point, now you've two inner nodes inside artifactListing which are folder and resource (oh yeah it's just those two) and their attributes.
Now I see you are getting where I'm going with this, if you don't just be patient.
So all I've to do to get the list of forms is to create an XSLT and ask it to give me the following attributes for resource.
- path
- name
- type
So let's look at the xsl file