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

Failure with custom namespace elements (PHP lib) #131

Open
GoogleCodeExporter opened this issue Mar 22, 2015 · 4 comments
Open

Failure with custom namespace elements (PHP lib) #131

GoogleCodeExporter opened this issue Mar 22, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Using a custom namespaced element (apart from the hardcoded SVG and MathML 
namespaces) causes a failure with DOMDocument::createElementNS(). For 
instance the following piece of HTML:

<html xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
  <fb:login-button>Facebook Connect</fb:login-button>
</body>
</html>

It causes the following warning (which should be an error, since the 
function returns nothing):

PHP Warning:  DOMDocument::createElementNS(): Namespace Error in 
TreeBuilder.php on line 3055

The problem is that TreeBuilder doesn't care of the XMLNS declarations in 
the HTML tag when creating elements, and it never uses the defined 
namespace URL when building elements. Thus, when calling 
DOMDocument::createElementNS() for 'fb:login_button' it tries to create a 
namespaced element using null as the namespaceURI, which causes a failure.

I attached a patch, which fixes the problem.

Original issue reported on code.google.com by [email protected] on 5 Jan 2010 at 3:26

Attachments:

@GoogleCodeExporter
Copy link
Author

That patch is wrong: per the HTML 5 spec, that should create an element whose 
localname is "fb:login-button" and whose namespaceURI is 
"http://www.w3.org/1999/
xhtml".

What we should be doing is coercing what we get into an XML infoset.

Original comment by geoffers on 5 Jan 2010 at 6:56

  • Changed state: Accepted
  • Added labels: Port-PHP

@GoogleCodeExporter
Copy link
Author

I did some experimentation with XML namespaces and PHP's DOM implementation a 
while
back, and I think I decided that the situation was absolutely hopeless and that 
I
could not get DOM to do precisely what was necessary to make conformance.

Others are invited to try to get the right semantics, but resolution for this 
bug
does not seem hopeful, which is very sad.

Original comment by [email protected] on 5 Jan 2010 at 7:00

@GoogleCodeExporter
Copy link
Author

I heavily simplified the patch, which was wrong as geoffers pointed out.

I changed Treebuilder::insertElement() to create an element with 
"http://www.w3.org/1999/xhtml" as the namespaceURI whenever there is a COLON in 
the 
localname. I also removed what extracted XMLNS declarations (since that's 
useless).

Is it any better, per the HTML 5 spec?

Original comment by [email protected] on 6 Jan 2010 at 10:32

Attachments:

@GoogleCodeExporter
Copy link
Author

This patch really needs to be merged into the main branch as it does indeed fix 
an issue that, according to some googling is biting a whole lot of folks int he 
bottom.

the fb:whatever tags are really quite common.

Original comment by [email protected] on 31 Aug 2012 at 3:37

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

No branches or pull requests

1 participant