Thank you so much!!!

- Is the following addition to also keep the border-style and border-width 
correct?
- Should I also add „or self::th“ tot he for-each?


namespace "http://www.w3.org/1999/xhtml";;
namespace html = "http://www.w3.org/1999/xhtml";;

for-each /html/body//*[self::td or self::tr or self::table] {

    set-variable("bg", lookup-style("background-color"));
    if $bg {
        set-attribute("style", concat("background-color: ", $bg, ";"));

    set-variable("bs", lookup-style("border-style"));
    if $bs {
        set-attribute("style", concat("border-style: ", $bs, ";"));
    }

   set-variable("bw", lookup-style("border-width"));
    if $bw {
        set-attribute("style", concat("border-width: ", $bw, ";"));
    }


    }
}


On 09/06/16 19:18, "Hussein Shafie" <huss...@xmlmind.com> wrote:

>On 06/09/2016 09:34 AM, Thomas Dumm wrote:
>>
>> Is there a way to generate sematic XHTML but retain the ruling and
>> shading of tables either via added styles or classes?
>
>Yes.
>
>
>
>>
>> I naively tried with edit.prune.preserve "background-color" which did
>> not show any consequence.
>>
>
>It's slightly more complicated than this.
>
>Here's the XED script:
>
>---
>namespace "http://www.w3.org/1999/xhtml";;
>namespace html = "http://www.w3.org/1999/xhtml";;
>
>for-each /html/body//*[self::td or self::tr or self::table] {
>     set-variable("bg", lookup-style("background-color"));
>     if $bg {
>         set-attribute("style", concat("background-color: ", $bg, ";"));
>     }
>}
>---
>
>I stored it in a file called "before-remove-styles.xed", but the file 
>name does not matter. Could be foobar.xed.
>
>You must pass it to w2x (or w2x-app in an option file) as follows:
>
>-pu edit.before.remove-styles "before-remove-styles.xed"
>
>Now a few explanations:
>
>* The semantic XHTML is created using "w2x_install_dir/xed/main.xed".
>
>* One of the steps of "main.xed" is "remove-styles.xed" which removes 
>all *interned* styles and classes from the XHTML input file.
>
>(Interning styles and classes allows a fast lookup of CSS styles. More 
>info in http://www.xmlmind.com/w2x/_distrib/doc/xedscript/parse-styles.html)
>
>* for-each /html/body//*[self::td or self::tr or self::table]
>iterates over cells, rows and tables.
>
>* lookup-style("background-color") returns the value of CSS property 
>background-color not matter how this property has been specified.
>
>See 
>http://www.xmlmind.com/w2x/_distrib/doc/xedscript/w2xfuncs.html#lookup-style
>
>* If a cell, row and table has a background color, then give it an 
>actual style attribute (not an interned style) with this property.
>
>See http://www.xmlmind.com/w2x/_distrib/doc/xedscript/set-attribute.html
>
>* In "main.xed", after "remove-styles.xed", you'll find 
>"finish-styles.xed" which discards all interned styles and classes. 
>However "finish-styles.xed" does *not* discard actual style and class 
>attributes.



--
XMLmind Word To XML Support List
w2x-support@xmlmind.com
http://www.xmlmind.com/mailman/listinfo/w2x-support

Reply via email to