Skip to content

has-oscal-namespace() function in Metapath #195

@wendellpiez

Description

@wendellpiez

User Story:

Because straight-up XPath seems a little cumbersome and to reflect its special semantics, we proposed wrapping the test for the oscal namespace (@ns flag) in a function has-oscal-namespace() which is indeed called in OSCAL.

https://github.com/usnistgov/OSCAL/blob/534b12dca5da4223615b72677159528022aa344a/src/metaschema/oscal_catalog_metaschema.xml#L52C77-L52C108

Couple of problems with this:

  • OSCAL is not metaschema. Does every user of metaschema get to extend Metapath?
  • Neither is a flag named ns - this is OSCAL semantics
  • It is not clear why this function has an argument or what has-oscal-namespace('some-other-namespace)` should return
  • This is taking a big step for a small gain - to implement it properly means parsing the Metapath expression in which it appears, whereas the rest of Metapath (so far) simply casts into XPath, giving us a robust and well-tested specification of semantics to lean on for free (or: only opportunity costs vis-a-vis other possible approaches - which remain open long-term).

Can we consider rolling this back or improving it?

The question is not urgent except it poses a planning problem for metaschema-xslt or indeed any processor that wants to implement constraints testing -- see below under Goals.

Alternatives:

OSCAL could use pure XPath:

  • literal test: not(@ns != 'http://csrc.nist.gov/ns/oscal') - no @ns is present not equal to the value
  • compound test: empty(@ns) or (@ns = 'http://csrc.nist.gov/ns/oscal') - cumbersome but explicit

or rely on the processor supporting an extended XPath/Metapath:

  • custom function oscal:has-namespace() or m:has-namespace()
  • function bound to variable: $oscal:has-namespace() or $m:has-namespace()

or continue with a homemade function (presumed Metapath-native, so no namespace is given on the function name) but cleaned up semantics

  • has-namespace($ns) instead of has-oscal-namespace($ns) - although this is really doesn't-have-another-namespace() 🤔

possibly other choices I have not thought of.

These are given in order of ease of implementation for the constraints checking, assuming XPath support. (The last option more or less requires implementing Metapath, if not to interpret it, at least to parse its syntax.)

Goals:

More clarity on plans for this function in particular and extensions to XPath in general.

One outcome could be an Issue in the OSCAL repository for making a change to its metaschemas where they use this construct.

Another outcome could be a decision to support or revise the function, with a PR or a spin-off Issue for necessary docs edits.

Irrespective of whether this feature of Metapath can be changed, the metaschema-xslt dev plan for constraints checking will be to build full Metapath support so as not to have this issue again -- with this feature or any other. Shorter term, however, if this feature can be pulled back, something much easier than Metapath can be contemplated for an implementation of Metaschema-based constraints checking.

This is especially true if we could go with a pure XPath approach, and continue to stick better to the rule "All XPath For Now".

Dependencies:

None known. This developer is seeking guidance that bears on implementation strategy.

However, the OSCAL team needs to be consulted. Indeed, they might prefer to use all XPath against a custom function in any case.

(cc @aj-stein-nist @nikitawootten-nist - please circulate as necessary)

Acceptance Criteria

  • All website and readme documentation affected by the changes in this issue have been updated. Changes to the website can be made in the docs/content directory of your branch.
  • A Pull Request (PR) is submitted that fully addresses the goals of this User Story. This issue is referenced in the PR. OR, this Issue reflects and/or links to sufficient discussion to resolve this issue (short/medium term), and
  • The CI-CD build process runs without any reported errors on any PR. This can be confirmed by reviewing that all checks have passed in the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions