5. parse-styles

parse-styles()

This command “interns” the CSS rules found in the html/head/style element of the document being edited, the CSS styles directly set on some elements, the CSS classes set on some elements.

This operation is needed to allow an efficient implementation of the following XPath extension functions: find-rule, font-size, get-class, get-rule, get-style, lookup-length, lookup-style, style-count, and of the following editing commands: add-class, add-rule, remove-class, remove-rule, set-rule, set-style.

More precisely:

  1. Parses the contents of the html/head/style element of the document being edited. Stores the parsed CSS rules into the s:rules property of the document. Removes the style element.

  2. Parses the content of the class attribute found on some elements of the document being edited. Stores the CSS class list into the s:class property of the element. Removes the class attribute.

  3. Parses the content of the style attribute found on some elements of the document being edited. Stores the CSS style properties into the s:style property of the element. Removes the style attribute.

See also unparse-styles.