The prefix for element is not bound

An element uses a namespace prefix that no xmlns declaration defines.

The message, as Java reports it
The prefix "inv" for element "inv:invoice" is not bound.

Why it happens

  • The xmlns:prefix="…" declaration is missing, misspelt, or on an element that does not enclose this one.
  • A fragment cut out of a larger document, whose namespace declarations were on an ancestor left behind.

How to fix it

Declare the prefix on the element or one of its ancestors, usually the root: xmlns:inv="urn:…" with the namespace the format defines. When extracting a fragment, serialize it with an XML API, which copies the declarations it needs.

Java's schema validation (javax.xml.validation.Validator, and JAXB or Spring on top of it) throws at the first error unless you set an ErrorHandler whose error() records the SAXParseException and carries on; each one has getLineNumber() and getColumnNumber(). A well-formedness error ends parsing whatever the handler does.

The same problem in xmlvalid

xmlvalid validates with libxml2, which reports it as Namespace prefix is not defined. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.

Namespace prefix inv on invoice is not defined

Example

Reports the error
<inv:invoice/>
Fixed
<inv:invoice xmlns:inv="urn:example:invoice"/>