Unfortunately, this isn't possible with the current templating implementation. The implementation relies up being able to uniquely identify an element in the xml file to add to or remove. As there are many <servlet> entries with no attributes to differentiate them this isn't currently possible. If there is sufficient demand for this capability we could look at improving this by using the elements within a element to help to uniquely identify it.
Originally Posted by bosakm
This is possible. A web-fragment.xml in a template with the following contents will change the default session timeout to 15 minutes:
2) I want to configure the session timeout to be 15 minutes instead of 30 minutes.
We haven't formally documented the syntax yet. We wanted to give it time to bed down and get a feel for what users wanted to do with it before we were limited in the refinements we could make.
Is there somewhere the documentation on the syntax of coding the fragments so I can accomplish this?
The syntax is pretty straightforward. You can prefix an element with add: to add it to the file, and you can prefix an element with remove: to remove it from the file.
When you're using add, the ancestors of the element that you're adding are used to uniquely identify its location in the document. So in the session timeout case above we're looking to add a <session-timeout> element to a <session-config> element that's within a <web-app> element. You're essentially using the snippet of XML to define a path from the root of the document to the location at which you want to add a new element. In fact, the implementation turns the fragment into an XPath to identify the location.
When you're using remove, the ancestors of the element, and the element itself are used to uniquely identify its location in the document. The fact that the element itself is also used means that you can use attributes of the element to uniquely identify it.
Hope this helps.