Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefined xmlns in output XHTML #1128

Open
mikeshaw opened this issue Oct 26, 2024 · 0 comments
Open

Redefined xmlns in output XHTML #1128

mikeshaw opened this issue Oct 26, 2024 · 0 comments

Comments

@mikeshaw
Copy link

Not sure if this is a bug and unable to find prior references.

Source HTML - note the duplicated xmlns:link in the use elements:

<!DOCTYPE html>
<html>
    <head>
        <title>title</title>
    </head>
    <body>
        <svg>
            <use xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#gel-icon-search" href="#gel-icon-search" role="presentation"/>
        </svg>
        <svg>
            <use xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#gel-icon-no" href="#gel-icon-no" role="presentation"/>
        </svg>
    </body>
</html>

When passed into:
tidy --output-xhtml 1
the output is:

No warnings or errors were found.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for Apple macOS version 5.8.0" />
<title>title</title>
</head>
<body>
<svg>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink=
"http://www.w3.org/1999/xlink" xlink:href="#gel-icon-search" href=
"#gel-icon-search" role="presentation"></use>
</svg> <svg>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink=
"http://www.w3.org/1999/xlink" xlink:href="#gel-icon-no" href=
"#gel-icon-no" role="presentation"></use>
</svg>
</body>
</html>

The duplicated namespaces go unremarked and are reproduced. Are duplicated xmlns legal in XHTML?
Piping that same output through xmllint:
tidy --output-xhtml 1 | xmllint -
Creates fatal errors:

"http://www.w3.org/1999/xlink" xlink:href="#gel-icon-search" href=
                              ^
-:15: parser error : Attribute xmlns:xlink redefined
"http://www.w3.org/1999/xlink" xlink:href="#gel-icon-no" href=
                              ^

I would expect Tidy to drop excess duplicate xmlns:* attributes from the output, as it does when the HTML example above is passed into
tidy --input-xml 1
which outputs:

line 8 column 13 - Warning: <use> dropping value "http://www.w3.org/1999/xlink" for repeated attribute "xmlns:xlink"
line 11 column 13 - Warning: <use> dropping value "http://www.w3.org/1999/xlink" for repeated attribute "xmlns:xlink"
Tidy found 2 warnings and 0 errors!

<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
<svg>
<use xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="#gel-icon-search" href="#gel-icon-search"
role="presentation" />
</svg>
<svg>
<use xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="#gel-icon-no" href="#gel-icon-no"
role="presentation" />
</svg>
</body>
</html>

The duplicated xmlns are noted and dealt-with.

Tidy version: "HTML Tidy for Apple macOS version 5.8.0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant