Altova Mailing List Archives


Re: Looking for suggestions (xslt?) on stripping specified elements/attributes from XHTML

From: "Dimitre Novatchev" <dimitren@---.---.-->
To: NULL
Date: 7/26/2006 6:19:00 PM

Search for and read about "XSLT identity rule" or "XSLT identity 
transformation".

It is the most fundamental design pattern in XSLT to override the identity 
rule in order to globally delete/replace ... etc. certain subset of nodes, 
leaving the general structure and other nodes of the document the same.


Cheers,
Dimitre Novatchev

"Foxpointe" <foxpointe@c...> wrote in message 
news:4r6dnX0DdcgVXVrZnZ2dnUVZ_uqdnZ2d@c......
> Given some arbitrary XHTML, I'd like to obtain a 'simplified' XHTML result 
> which strips out a large subset of standard elements and attributes - but 
> not all.  The main things I would like to accomplish:
>
> 1) Provide a list of elements/attributes to be stripped (i.e. everything 
> else should be passed through) or those that should be passed through 
> (i.e. everything else should be stripped) which would be applied 
> recursively.
> 2) If an element is to be stripped, pass through any enclosed text and/or 
> elements (the elements should in turn be processed recursively by step 1.)
> 3) If after stripping the resulting element is empty, eliminate it 
> completely.
>
> For example, this snippet:
>
> <h1>
>   <a href='chap2.htm'>
>     <img src="image.gif" alt="Thumbnail" border=0>
>   </a>
> </h1>
> <table width=515 border=0 cellpadding=0 cellspacing=0>
>   <tr>
>     <td width=172 align=left valign=top>
>       <a href="chap1.htm">
>         <img src="prev.gif" alt="Previous" border=0>
>       </a>
>     </td>
>     <td>
>       <style type="text/css">
>       </style>
>     </td>
>     <td width=171 align=center valign=top>
>       <b>
> <font face="ariel,helvetica,helv,sanserif" size="-1">Chapter 2 Getting 
> Started</font>
>       </b>
>     </td>
>     <td width=172 align=right valign=top>
>       <a href="chap3.htm">
> <img src="next.gif" alt="Next" border=0>
>       </a>
>     </td>
>   </tr>
> </table>
>
> Would become:
>
>   <a href='chap2.htm'>
>     <img src="image.gif">
>   </a>
> <table>
>   <tr>
>     <td>
>       <a href="chap1.htm">
>         <img src="prev.gif" alt="Previous">
>       </a>
>     </td>
>     <td>
> Chapter 2 Getting Started
>     </td>
>     <td>
>       <a href="chap3.htm">
> <img src="next.gif" alt="Next">
>       </a>
>     </td>
>   </tr>
> </table>
>
> Is XSLT the best means to accomplish this?  Suggestions on how to get this 
> done (esp. examples that could be used as a starting point) are 
> appreciated.
>
> Thanks,
> Phil 


Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.