OpenXmlSdkTs - v1.0.7
    Preparing search index...

    Class XNamespace

    Represents an XML namespace URI.

    Like XName, namespace instances are cached/interned: two XNamespace objects for the same URI are the same object.

    Three well-known static namespaces are provided: XNamespace.none, XNamespace.xml, and XNamespace.xmlns.

    The toString method returns {uri}, which enables Clark-notation via string concatenation: XNamespace.get(uri) + "localName" evaluates to "{uri}localName".

    const W = XNamespace.get('http://schemas.openxmlformats.org/wordprocessingml/2006/main');
    const wBody = W.getName('body');
    // Clark notation via string concatenation:
    const name = W + 'body'; // '{http://...}body'
    Index

    Constructors

    • Creates (or retrieves from cache) an XNamespace for the given URI.

      Parameters

      • uri: string

        The namespace URI string.

      • OptionalpreferredPrefix: string | null

        Optional preferred prefix for serialization.

      Returns XNamespace

    Properties

    The empty namespace (no namespace).

    The http://www.w3.org/XML/1998/namespace namespace (xml prefix).

    xmlns: XNamespace

    The http://www.w3.org/2000/xmlns/ namespace (xmlns prefix).

    uri: string

    The namespace URI string.

    Accessors

    • get preferredPrefix(): string | null

      Returns the preferred serialization prefix for this namespace, or null if none has been set.

      Returns string | null

    • get namespaceName(): string

      Alias for uri. Returns the namespace URI string.

      Returns string

    Methods

    • Returns a cached XNamespace for the given URI.

      Parameters

      • uri: string

        The namespace URI string.

      Returns XNamespace

      The cached XNamespace instance.

    • Returns the xml namespace (http://www.w3.org/XML/1998/namespace).

      Returns XNamespace

    • Returns the xmlns namespace (http://www.w3.org/2000/xmlns/).

      Returns XNamespace

    • Returns the namespace URI wrapped in braces ({uri}), enabling Clark-notation via string concatenation.

      Returns string

      "{uri}" or "" for the empty namespace.

    • Returns an XName in this namespace with the given local name.

      Parameters

      • localName: string

        The local part of the qualified name.

      Returns XName

      The cached XName instance.

    • Compares this namespace to another by identity (interned reference equality).

      Parameters

      • other: XNamespace

        The namespace to compare against.

      Returns boolean

      true if both are the same interned instance.