-
Notifications
You must be signed in to change notification settings - Fork 146
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
Switch to using XMLParser for parsing RDF/XML #352
Conversation
Also had to increase memory limit for PHP while running tests
Its good that you take care of this. |
I have just committed my work in progress on switching to the XMLReader class. Annoying it it nearly works but not quite. Some tests are currently failing and I keep getting a very difficult to interpret error message:
I am not quite sure what still needs changing/fixing from moving over to the new parser. |
I am going to re-factor this code to use the XMLParser added in #357 |
I think I may have worked out why this isn't working. I created this script: And this is the output:
So I think it might relate to the handling of empty XML elements. |
(useful when debugging with default: in switch)
this makes it behave more like the old PHP XML parser
Tests passing and build fixed! 🎉 Sorry that took so long to work out - the inner workings of the RDF/XML parser code is quite hard to understand. Little bit of tidying up and it should be ready to merge. |
Good job so far 👍 |
lib/Parser/RdfXml.php
Outdated
@@ -201,8 +186,28 @@ protected function reify($t, $s, $p, $o, $sType, $oType, $oDatatype = null, $oLa | |||
} | |||
|
|||
/** @ignore */ | |||
protected function startElementHandler($p, $t, $a) | |||
public function startElementHandler($parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we type-hint $parser
here? That might make it more clear what it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good idea.
It is a bit annoying that the callback has to be public.
But at least @ignore should remove it from the API documentation.
} | ||
|
||
foreach ($a as $key => $uri) { | ||
$xmlns = 'http://www.w3.org/2000/xmlns/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should not be in a loop, maybe make it a class property?
Really close to giving up on this 😢
It is possible that if I fix [2], then the performance will improve. But I have moved this to 1.2.0 milestone and will back-port the original PR fix. |
Don't give up! Also, I rather have more readable code than better performance. |
Might pick this branch up in the future but closing this PR - it has been replaced by #370 |
This Pull Request is work in progress for fixing #350
splitURI()
isn't needed anymore, the XML parse can do this