Add XSL stylesheet using Nokogiri

Hagbard Celine

Usenet Archive
Joined
Jun 13, 2010
Messages
9
Reaction score
0
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.
 

Hagbard Celine

Usenet Archive
Joined
Jun 13, 2010
Messages
9
Reaction score
0
Thank your very much. For some reason I wasn't able to find any material about that issue through Google. Quite disappointing answer though.
 

Mike Dalessio

Usenet Archive
Joined
May 14, 2009
Messages
64
Reaction score
0
[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>
 

Mike Dalessio

Usenet Archive
Joined
May 14, 2009
Messages
64
Reaction score
0

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
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top