Skip to content

Undeclaring default namespace in XML 1.0 #8

@Tomtec331

Description

@Tomtec331

I was switching to fast-xml-validator as the integrated validator of fast-xml-parser is marked as deprecated. When validating some of our xml data I came across an issue with namespace validation. A lot of the data we receive use xmlns="" to bring elements into global namespace. This is allowed according the XML 1.0 spec. See: https://www.w3.org/TR/xml-names/#defaulting (especially the last example).

Input (copied from w3 xml examples):

<?xml version='1.0'?>
<Beers>
  <!-- the default namespace inside tables is that of HTML -->
  <table xmlns='http://www.w3.org/1999/xhtml'>
    <th><td>Name</td><td>Origin</td><td>Description</td></th>
    <tr>
      <!-- no default namespace inside table cells -->
      <td><brandName xmlns="">Huntsman</brandName></td>
      <td><origin xmlns="">Bath, UK</origin></td>
      <td>
        <details xmlns=""><class>Bitter</class><hop>Fuggles</hop>
          <pro>Wonderful hop, light alcohol, good summer beer</pro>
          <con>Fragile; excessive variance pub to pub</con>
        </details>
      </td>
    </tr>
  </table>
</Beers>

Output (by using SyntaxValidator.validate(xml)):
ValidationError: Undeclaring the default namespace with xmlns="" is only permitted in XML 1.1 documents.

From my point of view this error should not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions