NamespaceManager

How to get NamespaceManager

ES2015+:

import NamespaceManager from 'fontoxml-dom-namespaces/namespaceManager'

ES5:

define([
	'fontoxml-dom-namespaces/namespaceManager'
], function (
	NamespaceManager
) {
});

Type: Class

The namespace manager controls which namespace uri should be used for which prefix. The mapping is used by various components to create elements and attributes or to read from the DOM

Currently, Fonto uses a global one-to-one mapping between uris and prefixes. One prefix may only point to one uri, and one uri may only be referred to one prefix.

Methods

Name Description
addNamespace

Register a namespace / prefix combination


  Arguments
# Name Type Description
1. prefix String | Null
2. namespaceUri String | Null
createElement

Convenience function to create an element in the correct namespace by specifying only its qualified name (including the prefix, where appropriate)


  Arguments
# Name Type Description
1. contextNode Node
2. qualifiedName String
  Returns

Type: Element

createElementNS

Convenience function to create an element in the specified namespace by specifying only its local name (without the prefix, that will be added automatically)


  Arguments
# Name Type Description
1. contextNode Node
2. namespaceUri String | Null
3. localName String
  Returns

Type: Element

getNamespaceUri

Get the registered namespace associated with the given prefix, given the contextNode for extra information on namespaces used elsewhere in the document


  Arguments
# Name Type Description
1. contextNode Node | Null
2. prefix String | Null
  Returns

Type: String | Null

getPrefix

Get the registered prefix associated with the given uri, given the contextNode for extra information on namespaces used elsewhere in the document


  Arguments
# Name Type Description
1. contextNode Node | Null
2. namespaceUri String | Null
  Returns

Type: String | Null

getQualifiedNameForAttribute

Get the qualified name associated with the given uri, for the local name if, given the contextNode for extra information on namespaces used elsewhere in the document.

This method can resolve a qualified name for attributes; The null namespace uri will always be bound to no prefix.


  Arguments
# Name Type Description
1. contextNode Node | Null
2. namespaceUri String | Null
3. localName String
  Returns

Type: String

getQualifiedNameForElement

Get the registered prefix associated with the given uri, given the contextNode for extra information on namespaces used elsewhere in the document


  Arguments
# Name Type Description
1. contextNode Node | Null
2. namespaceUri String | Null
3. localName String
  Returns

Type: String

resolveQualifiedNameForAttribute

Get the registered prefix associated with the given uri, given the contextNode for extra information on namespaces used elsewhere in the document.

This method can resolve a qualified name for attributes; The null namespace uri will always be bound to no prefix.


  Arguments
# Name Type Description
1. contextNode Node | Null
2. qualifiedName String
  Returns

Type: QName

object consisting of qualifiedName, namespaceURI, localName and prefix

resolveQualifiedNameForElement

Get the QName, including parts making up such a QName associated with the given qualified name, given the contextNode for extra information on namespaces used elsewhere in the document.


  Arguments
# Name Type Description
1. contextNode Node | Null
2. qualifiedName String
  Returns

Type: QName

object consisting of qualifiedName, namespaceURI, localName and prefix