In xyPerl you can easily check for the presence or get the value of an attribute from a specific ancestor using the rather elegant syntax provided (@name, ../@name, ../../@name, ancestor::element/@name, etc...)
But checking if you are in a certain context is quite cumbersome. You need to do a get_mlh or get_path and then write your own function to detect if you are currently in a certain context.
This could be done a lot easier if we could use similar syntax like for the attributes inside a new xyPerl function (get_context?)
Things could look like this:
if ($X->get_context('ancestor::chapter') ) {
doSomething();
} else {
doSomethingElse();
}
Remark: one might argue that the context checking might be done inside the CSS, but sometimes you just want to avoid writing 2 similar xyPerl functions and just to the context checking inside your xyPerl function.