Namespace Selector

In the CSS 2.1 standard, the element selectors ignore the namespaces of the elements they are matching. Only the local name of the elements are considered in the selector matching process.

Oxygen XML Editor plugin uses a different approach that is similar to the CSS Level 3 specification. If the element name from the CSS selector is not preceded by a namespace prefix it is considered to match an element with the same local name as the selector value and ANY namespace. Otherwise, the element must match both the local name and the namespace.

In CSS up to version 2.1 the name tokens from selectors are matching all elements from ANY namespace that have the same local name. Example:

<x:b xmlns:x="ns_x"/>
<y:b xmlns:y="ns_y"/>

Are both matched by the rule:

b {font-weight:bold}

Starting with CSS Level 3 you can create selectors that are namespace aware.

Defining both prefixed namespaces and the default namespace

Given the namespace declarations:

@namespace sync "http://sync.example.org";
@namespace "http://example.com/foo";

In a context where the default namespace applies:

sync|A

represents the name A in the http://sync.example.org namespace.

|B

represents the name B that belongs to NO NAMESPACE.

*|C

represents the name C in ANY namespace, including NO NAMESPACE.

D

represents the name D in the http://example.com/foo namespace.

Defining only prefixed namespaces

Given the namespace declaration:

@namespace sync "http://sync.example.org";

Then:

sync|A

represents the name A in the http://sync.example.org namespace.

|B

represents the name B that belongs to NO NAMESPACE.

*|C

represents the name C in ANY namespace, including NO NAMESPACE.

D

represents the name D in ANY namespace, including NO NAMESPACE.

Defining prefixed namespaces combined with pseudo-elements

To match the def element its namespace will be declared, bind it to the abs prefix, and then write a CSS rule:

@namespace abs "http://www.oxygenxml.com/sample/documentation/abstracts";

Then:

abs|def

represents the name "def" in the http://www.oxygenxml.com/sample/documentation/abstracts namespace.

abs|def:before

represents the :before pseudo-element of the "def" element from the http://www.oxygenxml.com/sample/documentation/abstracts namespace.

Was this helpful?