Class RNCDatatypeLibrary

java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCDatatypeLibrary

public class RNCDatatypeLibrary extends Object
Registry of datatype libraries available in RNC documents.

A datatype library maps a URI (declared via datatypes prefix = "uri") to a set of named data types, each with documentation. This class is used by both completion (to propose types like xsd:integer) and hover (to show documentation when the cursor is on a type reference).

Libraries are loaded from the bundled rnc-datatype-libraries.json resource, which defines three libraries matching Jing's architecture:

  • Built-in (empty URI): string, token
  • Compatibility (http://relaxng.org/ns/compatibility/datatypes/1.0): ID, IDREF, IDREFS
  • XSD (http://www.w3.org/2001/XMLSchema-datatypes): all W3C XML Schema built-in datatypes
  • Method Details

    • getUri

      public String getUri()
      Returns the library URI (e.g. "http://www.w3.org/2001/XMLSchema-datatypes").
      Returns:
      the URI string, or empty string for the built-in library.
    • getDescription

      public String getDescription()
      Returns a human-readable description of this library.
      Returns:
      the description (e.g. "W3C XML Schema datatypes").
    • getDefaultPrefix

      public String getDefaultPrefix()
      Returns the conventional prefix for this library, used to generate datatypes snippets (e.g. "xsd", "compat").
      Returns:
      the default prefix, or null for the built-in library.
    • getEntries

      public Collection<RNCDatatypeLibrary.Entry> getEntries()
      Returns all datatype entries in this library.
      Returns:
      the entries (e.g. string, integer, ID).
    • getEntry

      public RNCDatatypeLibrary.Entry getEntry(String name)
      Returns the entry for the given datatype name, or null if not found.
      Parameters:
      name - the datatype name (e.g. "integer", "ID").
      Returns:
      the matching entry, or null.
    • get

      public static RNCDatatypeLibrary get(String uri)
      Returns the datatype library for the given URI, or null if unknown.
    • getLibraries

      public static Collection<RNCDatatypeLibrary> getLibraries()
      Returns all registered datatype libraries.
    • resolve

      public static RNCDatatypeLibrary resolve(RNCDocument document, String prefix)
      Resolves a datatype prefix to its library by looking up the datatypes declarations in the given RNC document.
      Returns:
      the library, or null if the prefix is not declared or maps to an unknown library.