Subject: [netmod] more XPath fun

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 28 Jul 2009 11:30:25 +0200

Hi,

yang-usage draft says this: "..., the 'preceding', 'preceding-sibling',
'following', and 'following-sibling' axis SHOULD NOT be used.  These
constructs rely on XML document order within a NETCONF agent
configuration database, which may not be supported consistently or
produce reliable results across implementations."

I don't agree with this, here are two examples where these axes are
useful and maybe indispensable:

1. Global uniqueness:

grouping id {
    leaf id {
        type string;
        must "not(.=preceding::id)";
    }
}

This grouping can be used to place an id anywhere in the schema and the
'must' constraint guarantees their uniqueness.

2. Lists ordered-by user: 'must' statement may be used to specify some
constraints on the order. For example, this guarantees that IPv4 clients
appear before IPv6 ones:

list client {
    must "not(preceding-sibling::client/version > version)";
    leaf version {
        type inet:ip-version;
    }
}

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C