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
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 Summary
ConstructorsConstructorDescriptionRNCNamespaceDecl(int start, int end) Creates a new namespace declaration node spanning the given offsets. -
Method Summary
Modifier and TypeMethodDescriptionReturns the namespace prefix extracted from the source text.intReturns the exclusive end offset of the prefix.intReturns the inclusive start offset of the prefix.getUri()Returns the namespace URI with surrounding quotes stripped.intReturns the exclusive end offset of the URI literal.intReturns the inclusive start offset of the URI literal.booleanReturns whether this is a default namespace declaration.voidsetDefault(boolean isDefault) Sets whether this is a default namespace declaration.voidsetPrefix(int start, int end) Sets the source offsets of the namespace prefix.voidsetUri(int start, int end) Sets the source offsets of the URI literal.Methods inherited from class org.eclipse.lemminx.extensions.relaxng.grammar.rnc.RNCNode
addChild, findNodeAt, getChildren, getEnd, getOwnerDocument, getParent, getStart, getText, hasChildren, isClosed, setClosed, setEnd, setStart
-
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
- Specified by:
getNodeTypein classRNCNode
-
isDefault
public boolean isDefault()Returns whether this is a default namespace declaration.- Returns:
truefordefault namespace = "uri",falsefornamespace prefix = "uri".
-
setDefault
public void setDefault(boolean isDefault) Sets whether this is a default namespace declaration.- Parameters:
isDefault-trueif the declaration is preceded bydefault.
-
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
Returns the namespace prefix extracted from the source text.Example: for
namespace a = "http://...", returns"a".- Returns:
- the prefix string, or
nullfor default namespace declarations.
-
getPrefixStart
public int getPrefixStart()Returns the inclusive start offset of the prefix.- Returns:
- the prefix start offset, or
-1if not set.
-
getPrefixEnd
public int getPrefixEnd()Returns the exclusive end offset of the prefix.- Returns:
- the prefix end offset, or
-1if 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
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
nullif not set.
-
getUriStart
public int getUriStart()Returns the inclusive start offset of the URI literal.- Returns:
- the URI start offset, or
-1if not set.
-
getUriEnd
public int getUriEnd()Returns the exclusive end offset of the URI literal.- Returns:
- the URI end offset, or
-1if not set.
-