Skip to content

Integrate xml5ever

Josh Matthews edited this page Sep 17, 2015 · 1 revision

Integrate xml5ever XML parser

Background information: Servo uses a custom HTML5 parser written in Rust, called html5ever. We currently lack a parser for XML documents, which prevents us from running XHTML tests and implementing a number of APIs that rely on it. xml5ever is an experimental XML5 parser modeled after HTML5, so it should be relatively straightforward to integrate it into Servo and address these needs.

Initial steps:

  • compile Servo and ensure that it runs on tests/html/about-mozilla.html
  • email the mozilla.dev.servo mailing list introducing your group and your progress
  • add xml5ever as a dependency to the script crate using the cargo package manager
  • add an xml.rs to components/script/parse/ with a parse_xml modeled after parse_html from html.rs (be sure to modify parse/mod.rs too)
  • add a ServoXMLParser interface modeled after ServoHTMLParser.webidl and add whatever stubs are necessary to the new components/script/dom/servoxmlparser.rs to let it compile (be sure to update components/script/dom/mod.rs)
  • call the new parse_xml from the branch in DOMParser::ParseFromString that implements XML document support in domparser.rs (this is not expected to do anything except compile successfully, at this point)

Subsequent steps:

  • modify ScriptTask::load in script_task.rs to recognize the text/xml content type and call parse_xml instead of parse_html as appropriate, while passing the appropriate flag to the Document constructor
  • implement a TreeSink for the XML parser that performs appropriate tree modifications for each action (see the implementation in parse/html.rs for an excellent model)
  • implement support in xmlhttprequest.rs for XML document responses (see step 7 in https://xhr.spec.whatwg.org/#document-response)
  • implement XMLDocument API by following the documentation and implementing the steps laid out in the specification for the load method
Clone this wiki locally