Closed (fixed)
Project:
Import HTML
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Apr 2010 at 19:28 UTC
Updated:
30 May 2010 at 17:30 UTC
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
Comment #1
dman commentedThis 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):
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.
Comment #2
dman commented