npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bungenix-akn-context

v1.0.0

Published

Provides the context of a provided Akoma Ntoso XML element name in terms of allowed elements, attributes and allowed parents

Downloads

1

Readme

BungeniX-AKN-Context

This Javascript library will be useful to you if you are a tool developer working with Akoma Ntoso XML (AKN) documents.

Ever wanted to query the context of an element? Know its possible attributes, and its possible allowed child or parent elements? This will do just that.

bungenix-akn-context is a very fast implementation that is pure native JS, and does not make use of any XPath or XML Schema introspection.

A common use case for such a library is for a AKN markup editor:

The user is in the body of a document, and you want to perhaps pop-up a menu on right-click with possible elements within the main body of the document, then if you chose a preface, and right click within the preface you want to add a new allowed element for the preface, and so on.

You can essentially build a complete document tree or an element tree within a document with this library without invoking XPath or introspecting the schema.

Usable both in-browser (tested on ReactJS and SvelteJS) and on the server side with NodeJS.

API

API: findElements

This returns possible element names for a partial set of starting characters.

For example:

import {findElements} from 'akn-element-context';
...
const elementsStartingWithpa = findElements("pa");

console.log(elementsStartingWithpa);

This returns a list of AKN elements starting with the pattern "pa":

[
  "paragraph",
  "parliamentary",
  "part",
  "party",
  "passiveModifications",
  "passiveRef"
]

API: elementContext

Returns the element context information for an element

For example:

import {elementContext} from 'akn-element-context';
...
const elemPart = elementContext("preface");

Returns the following an object with context specific information about the element in terms of its allowed childElements, attributes and parentElements. The below for example are the allowed child elements, parent elements and attributes for a Akoma Ntoso preface element.

{
    "childElements": [
        {"name": "blockList"},
        {"name": "blockContainer"},
        {"name": "tblock"},
        {"name": "toc"},
        {"name": "ul"},
        {"name": "ol"},
        {"name": "table"},
        {"name": "p"},
        {"name": "foreign"},
        {"name": "block"},
        {"name": "longTitle"},
        {"name": "formula"},
        {"name": "container"}
    ],
    "attributes": [
        {
            "name": "GUID",
            "type": "noWhiteSpace",
            "usage": "optional"
        },
        {
            "name": "alternativeTo",
            "type": "eIdRef",
            "usage": "optional"
        },
        {
            "name": "class",
            "type": "xsd:string",
            "usage": "optional"
        },
        {
            "name": "eId",
            "type": "noWhiteSpace",
            "usage": "optional"
        },
        {
            "name": "period",
            "type": "temporalGroupRef",
            "usage": "optional"
        },
        {
            "name": "refersTo",
            "type": "list of referenceRef",
            "usage": "optional"
        },
        {
            "name": "status",
            "type": "statusType",
            "usage": "optional"
        },
        {
            "name": "style",
            "type": "xsd:string",
            "usage": "optional"
        },
        {
            "name": "title",
            "type": "xsd:string",
            "usage": "optional"
        },
        {
            "name": "wId",
            "type": "noWhiteSpace",
            "usage": "optional"
        },
        {
            "name": "xml:id",
            "type": "xs:ID",
            "usage": "optional"
        },
        {
            "name": "xml:lang",
            "type": "union of(xs:language, restriction of xs:string)",
            "usage": "optional"
        },
        {
            "name": "xml:space",
            "type": "restriction of xs:NCName",
            "usage": "optional"
        }
    ],
    "parentElements": [
        "act",
        "amendment",
        "amendmentList",
        "bill",
        "debate",
        "debateReport",
        "doc",
        "documentCollection",
        "officialGazette",
        "portionBody",
        "statement"
    ]
}

License

GPL-3.0