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

More compatibility with standard XmlDocument. #12

Closed
wants to merge 1 commit into from
Closed

More compatibility with standard XmlDocument. #12

wants to merge 1 commit into from

Conversation

denis-ivanov
Copy link

Types of Changes

Use XmlElement.Prefix empty string instead null.

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

I'm trying to solve AngleSharp/AngleSharp.XPath/issues/18 issue. I found that AngleSharp.Xml uses null prefix for XmlElement, but standard XmlDocument uses empty string. I consider we need more compatibility with standard XmlDocument.

Below the same test for XmlDocument

[Test]
public void ParseValidXmlPrefixShouldBeEmpty()
{
    var source = "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" />";
    var document = new XmlDocument();
    document.LoadXml(source);
    Assert.AreEqual("", document.DocumentElement.Prefix);
}

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Denis Ivanov seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@FlorianRappl
Copy link
Contributor

The problem with this approach is that this is unfortunately not the standard, i.e., if no prefix is given it should be null. If we would just change it to an empty string then things will automatically break that respect the W3C DOM specification.

See, e.g., MDN how prefix on Element (note, this not HTMLElement, i.e., it also applies to XMLElement) should behave. Also the official spec mentions null explicitly a couple of times for determining behavior based on prefix.

Is there another way around it? Maybe by using a normalized version of prefix?

@denis-ivanov
Copy link
Author

@FlorianRappl thank you, I will try to find another solution.

@denis-ivanov denis-ivanov deleted the feature/use-empty-prefix branch November 27, 2019 04:07
@FlorianRappl
Copy link
Contributor

Thanks for understanding @denis-ivanov .

Maybe let's chat (via skype?) later today. I have a feeling you understand the problem already quite well. If we discuss various ways maybe a viable solution comes up.

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

Successfully merging this pull request may close these issues.

3 participants