Open david-morris opened 5 years ago
A NodeSet contains a list of Nokogiri::XML::Node objects. Typically a NodeSet is return as a result of searching a Document via Nokogiri::XML::Searchable#css or Nokogiri::XML::Searchable#xpath
Since a NodeSet can contain non-contiguous fragments of a document, it’s somewhat ill-defined what pretty-printing would look like. I’m kind of curious to hear your thoughts on this. It’s easy if the NodeSet contains sibling nodes (under the same parent). But what about (for example):
<em>
tags in an XHTML document having em tags at several different depths and inside different parent tags in the document hierarchy. Do we include all ancestors to the root? That’s certainly more than is contained in the NodeSet and would have to be reconstructed. Or do we print the results flattened as if they were siblings when they are not? Or make this configurable?Whatever the answers to these questions, to continue using the XSLT method this gem currently uses, the NodeSet would need to be transformed into a new XML document that represents what you want to print.
Having chosen answers to these questions, it probably wouldn’t be too hard to implement, if you’re interested in taking this on.
It kind of defeats the point of a library for allowing humans to read XML if you can't partially parse the XML and then show it.