Monday, 19 August 2013

Nokogiri XSLT tagging document as XML type when using JSON

Nokogiri XSLT tagging document as XML type when using JSON

I am using Nokogiri to transform an XML document to JSON. The code is
straight forward:
@document = Nokogiri::XML(entry.data)
xslt =
Nokogiri::XSLT(File.read("#{File.dirname(__FILE__)}/../../xslt/my.xslt"))
transform = xslt.transform(@document)
entry in this case is a Mongoid based model and data is an XML blob
attribute stored as a string on MongoDB.
When I dump the contents of transform, the JSON is there. The problem is,
Nokogiri is tagging the top of the document with:
<?xml version="1.0"?>
What's the correct way of addressing that?

No comments:

Post a Comment