Add XSL stylesheet using Nokogiri

H

Hagbard Celine

Hi there.

I am generating a XML file using Nokogiri. I would like to add a XSL
stylesheet reference to the document. By XSL stylesheet reference I mean

<?xsl-stylesheet type="text/xsl" href="foo.xsl"?>

I haven't found a way to do this with Nokogiri. Does anyone know a
solution to my problem? Any help is appreciated.
 
H

Hagbard Celine

Thank your very much. For some reason I wasn't able to find any material
about that issue through Google. Quite disappointing answer though.
 
M

Mike Dalessio

[Note: parts of this message were removed to make it a legal post.]

On Thu, Nov 25, 2010 at 3:09 PM, niklas | brueckenschlaeger <


OMG, there is so much fail here, I don't know where to start.

Instead, I will simply submit the correct method without further comment:

require "nokogiri"

doc = Nokogiri::XML "<root>foo</root>"
doc.root.add_previous_sibling Nokogiri::XML::processingInstruction.new(doc,
"xml-stylesheet", 'type="text/xsl" href="foo.xsl"')
puts doc.to_xml
# => <?xml version="1.0"?>
# <?xml-stylesheet type="text/xsl" href="foo.xsl"?>
# <root>foo</root>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top