The MSIBPlusPack.Web Namespace contains the classes to transform the HTML rendered into various formats with ease, such as XHTML, Print and Text Only versions of a page.
In order for your site to be affected by the Page Transformer, you need to
<configSections>
<section name="OutputFiltering"
type="MSIBPlusPack.Web.OutputFilteringConfigurationHandler, MSIBPlusPackPageTransformer" />
</configSections>
<httpModules>
<add name="OutputFilteringModule" type="MSIBPlusPack.Web.OutputFilteringModule, MSIBPlusPackPageTransformer"/>
</httpModules>
The Page Transformer takes its settings from sections added to the <OutputFiltering> section of the web.config file for the website. An example section can be seen below.
<add name="TextOnly" activateOn="queryString" activateOnValue="textonly">
<tag name="img" action="replaceWithAttribute">alt</tag>
<tag name="b" action="replace">i</tag>
<tag name="notfortextonly" action="remove" />
</add>
What the above section does it state that when the QueryString passed to the page contains a reference to the text: "textonly=1", replace the <img> tags with the text from the "alt" attribute, change all the bold tags <b> to italic <i> and remove the contents of any tag called <notfortext>.
The <add> element contains any number of tag elements describing the actions to take on HTML tags within the Output.
The attributes for the <add> element are:
| Attribute | Description |
|---|---|
| name |
User Reference to this section (Has no effect on the Page Transformer) |
| activateOn | What is this section triggered by (See Activate On Section Below) |
| activateOnValue | The value to act upon (This would be the text that would appear in a QueryString if activateOn was set to QueryString) |
| xhtml |
Setting this attribute to true instructs the page transformer to convert all the page's output to XHTML) |
Examining this step by step we can see what happens:
<img src="header.jpg" alt="Welcome to My Company" />
<b>Hello Everyone<b>
<notfortextonly>
<a href="greatgraphics.htm">Click here for awesome graphics</a>
</notfortextonly>
Welcome to My Company
<i>Hello Everyone</i>
Note, the element and contents of <notfortextonly> have been removed, bold has become italics, and the image has been removed leaving only the alternate text.
Based on the above example it is clear that any number of combinations can be used to easily create actions for text only sites, print versions of a page etc.
To convert the page output to XHTML, all you have to do it add an attribute to the <add> element stating xhtml to be true
<add name="xhtml" activateOn="always" xhtml=true />
Again, this section can have <tags> so that as well as converting to xhtml you may want to remove certain sections of the output.
The following are the valid settings for the Activate On attribute of the <add> section:
| Type | Description |
|---|---|
| remove | Completely remove the element and contents |
| replace | Replace the element with the one specified |
| removeContents | leave the element intact but remove it's contents |
| removeAttribute | Completely remove the attribute from the element |
| replaceWithAttribute | Replace the contents of the element with the contents of the atttribute specified |
| none | Take no action |