All of our web pages have some toolbar and menu links tucked inside three different div classes. I do not want to import this info. How do we adjust the XSL template html2simplehtml so that it will ignore anything inside a div class="nomargins" (or noprint, or nodisplay.) I know nothing about XSL so assume my complete ignorance of the subject when you answer.

Thanks,

Bill Teschek

Comments

dman’s picture

This is a common enough task. Yeah XSL can do it just fine, but yeah, XSL has a heck of a learning curve and is downright unintuative at times.

Depending on what you've done so far, you should COPY either html2simplehtml.xsl (the generic catch-all handler) or simplehtml2simplehtml.xsl (A much simpler foundation for building your own imports) to your own version, eg mypage2simplehtml.xsl

Without going too far into the workings, when the template finds the 'body content', it processes the contents of that area as individual elements also. What we need to do is say "if you find a div with class="nodisplay" during this process, just don't print it. The default is of course to pass it through unchanged.

Add this to your template (at a depth alongside the other xsl:template elements):

<!-- This element should NOT show up in the body of the page. Nullify it if found as part of text parsing --> 
  <xsl:template match="*[@class='nodisplay']|*[@class='noprint']"> 
  </xsl:template> 

Note that xsl parsing here looks for the class EQUAL TO "nodisplay", not containing, as CSS would allow with multiple classes.

There are examples already in the code where 'sidebar' or 'h1' is removed if found in the body, although those are special cases that extract the values specially and do something else with them too.

dman’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.