Match a keyword in space-separated keyword list (attribute value)

A post in Push Button paradise explains how you can use XSLT functions to test whether a keyword is present in space-separated list of keywords (for example, whether an HTML tag has a specific CSS class).
Notes:
  • The original problem explanation is somewhat misleading; the @class = 'vcard' test will correctly match if the class attribute is set to vcard, but would not match if vcard is just one of several classes applied to an HTML tag.
  • The Microformats wikipedia has code samples solving the same issue in multiple programming languages.
  • The best function I've found so far in JavaScript world is the xGetElementsByClassName from the X library.

No comments:

Post a Comment