Xml Decleration using builder

D

Dan Webb

I'm trying to create an XML file and I don't see any way with the
builder methods to write the doc type down.

<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>
<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2.dtd">

I can sucessfully using
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8", :standalone
=> "no"

to create the first line. But the DOCTYPE line is a mystery. Any ideas?

http://builder.rubyforge.org/
 
H

Henrik Nyh

I'm trying to create an XML file and I don't see any way with the
builder methods to write the doc type down.

<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>
<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2.dtd">

I can sucessfully using
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8", :standalone
=> "no"

to create the first line. But the DOCTYPE line is a mystery. Any ideas?

xml.declare! :DOCTYPE, :questestinterop, :SYSTEM, 'ims_qtiasiv1p2.dtd'

Got this from the README that ships with the gem.
 
D

Dan Webb

xml.render_choice do
xml.render_choice:)ident => item_ident, :rcardinality =>
rcardinality, :rtiming => rtiming)
(1..qammount).each do
xml.response_label do
xml.material do
xml.mattext(response_mattext)
end
end
end
end

thanks for that. Should have kept on looking, I blame the man flu I had.
I'm having issues with trying to give the parent class the tags. It's
straight forward giving tags that close on the same line extra items.
e.g.

xml.render_choice:)ident => item_ident, :rcardinality => rcardinality,
:rtiming => rtiming)

gives
<render_choice ident="NSFB_electronics_01_v1p2" rcardinality="single"
rtiming="No"/>

But I need to place other tags between this. Any ideas? I can't see
anything in the help file to suggest that it's possible.
 
K

Ken Bloom

xml.render_choice do
xml.render_choice:)ident => item_ident, :rcardinality =>
rcardinality, :rtiming => rtiming)
(1..qammount).each do
xml.response_label do
xml.material do
xml.mattext(response_mattext)
end
end
end
end

thanks for that. Should have kept on looking, I blame the man flu I had.
I'm having issues with trying to give the parent class the tags. It's
straight forward giving tags that close on the same line extra items.
e.g.

xml.render_choice:)ident => item_ident, :rcardinality => rcardinality,
:rtiming => rtiming)

gives
<render_choice ident="NSFB_electronics_01_v1p2" rcardinality="single"
rtiming="No"/>

But I need to place other tags between this. Any ideas? I can't see
anything in the help file to suggest that it's possible.

Just add a block on the call to render_choice

xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8", :standalone
xml.render_choice do
xml.render_choice:)ident => item_ident, :rcardinality =>
rcardinality, :rtiming => rtiming) do #here
(1..qammount).each do
xml.response_label do
xml.material do
xml.mattext(response_mattext)
end
end
end #and here
end
end
 

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

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top