Class RNCNamespaceDecl

java.lang.Object
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCNode
org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCNamespaceDecl
All Implemented Interfaces:
RNCRange

public class RNCNamespaceDecl extends RNCNode
Represents a namespace declaration in an RNC document.

A namespace declaration binds a prefix to a namespace URI, or sets the default namespace. The prefix can then be used to qualify element and attribute names in the grammar.

Use case: the parser creates an RNCNamespaceDecl node for each namespace or default namespace declaration. Semantic tokens use it to classify the prefix as a namespace token.

Example RNC:

 default namespace = "http://www.w3.org/1999/xhtml"   ← isDefault=true, prefix=null
 namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"  ← isDefault=false, prefix="a"
 
  • Constructor Details

    • RNCNamespaceDecl

      public RNCNamespaceDecl(int start, int end)
      Creates a new namespace declaration node spanning the given offsets.
      Parameters:
      start - the inclusive start offset.
      end - the exclusive end offset.
  • Method Details

    • getNodeType

      public RNCNodeType getNodeType()
      Specified by:
      getNodeType in class RNCNode
    • isDefault

      public boolean isDefault()
      Returns whether this is a default namespace declaration.
      Returns:
      true for default namespace = "uri", false for namespace prefix = "uri".
    • setDefault

      public void setDefault(boolean isDefault)
      Sets whether this is a default namespace declaration.
      Parameters:
      isDefault - true if the declaration is preceded by default.
    • setPrefix

      public void setPrefix(int start, int end)
      Sets the source offsets of the namespace prefix.
      Parameters:
      start - the inclusive start offset of the prefix.
      end - the exclusive end offset of the prefix.
    • getPrefix

      public String getPrefix()
      Returns the namespace prefix extracted from the source text.

      Example: for namespace a = "http://...", returns "a".

      Returns:
      the prefix string, or null for default namespace declarations.
    • getPrefixStart

      public int getPrefixStart()
      Returns the inclusive start offset of the prefix.
      Returns:
      the prefix start offset, or -1 if not set.
    • getPrefixEnd

      public int getPrefixEnd()
      Returns the exclusive end offset of the prefix.
      Returns:
      the prefix end offset, or -1 if not set.
    • setUri

      public void setUri(int start, int end)
      Sets the source offsets of the URI literal.
      Parameters:
      start - the inclusive start offset (including the opening quote).
      end - the exclusive end offset (after the closing quote).
    • getUri

      public String getUri()
      Returns the namespace URI with surrounding quotes stripped.

      Example: for namespace a = "http://example.com", returns "http://example.com" (without the surrounding double quotes).

      Returns:
      the URI string without quotes, or null if not set.
    • getUriStart

      public int getUriStart()
      Returns the inclusive start offset of the URI literal.
      Returns:
      the URI start offset, or -1 if not set.
    • getUriEnd

      public int getUriEnd()
      Returns the exclusive end offset of the URI literal.
      Returns:
      the URI end offset, or -1 if not set.