14. :property() extension pseudo class
Prev | Chapter 4. Other extensions | Next

## 14. :property() extension pseudo class

Application properties are similar to element attributes except that:

- A property is not part of the document content.

- A property cannot be not saved to disk.

- The value of a property is not limited to a string but can be any Java™ object.

- The name of a property is an XML qualified name, just like for attributes.

- A property is not directly editable by the user. A property is added to an XML node by the application (that is, XXE).

Pseudo-function property(`property_name`) can be used to insert the value of the property in generated content.

Pattern | Meaning
--- | ---
E:property(ns|foo) | an E element, having a property named ns|foo
E:property(ns|foo, "bar") or E:property(ns|foo, equals, "bar") | an E element, having a property named ns|foo with a value whose string representation equals "bar"
E:property(ns|foo, starts-with, "f") | an E element, having a property named ns|foo with a value whose string representation starts with string "f".
E:property(ns|foo, ends-with, "oo") | an E element, having a property named ns|foo with a value whose string representation ends with string "oo".
E:property(ns|foo, contains, "o") | an E element, having a property named ns|foo with a value whose string representation contains substring "o".

An example of application property is `{http://www.xmlmind.com/xmleditor/namespace/property}sourceURL`, the location of the file from which an XML node has been loaded. Excerpt of ``XXE_install_dir`/addon/config/common/css/visible_inclusions.imp`:

    @namespace prop "http://www.xmlmind.com/xmleditor/namespace/property";

    *:property(prop|sourceURL):before {
        content: icon(left-half-disc)
                 "sourceURL=" property(prop|sourceURL)
                 icon(right-half-disc);
        display: inherit;
        color: red;
        font-size: small;
        text-align: center;
    }

The above rule inserts above any element having a `{http://www.xmlmind.com/xmleditor/namespace/property}sourceURL` property, a block or an inline displaying the value of this property.

Another example is property `{http://www.xmlmind.com/xmleditor/namespace/property}readOnly`. This property is set on all XML nodes which cannot be modified by the user (e.g. included nodes). Excerpt of the built-in CSS file (automatically included before all the other CSS files):

    @namespace prop "http://www.xmlmind.com/xmleditor/namespace/property";

    *:property(prop|readOnly, "true") {
        background-color: #E0F0F0;
    }

    *:property(prop|readOnly, "false") {
        background-color: normal;
    }

Prev | Up | Next
13. Styling element attributes | Home | 15. url() is XML catalog aware