[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Xml Decleration using builder

Dan Webb

10/15/2008 11:52:00 AM

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.ruby...
--
Posted via http://www.ruby-....

3 Answers

Henrik Nyh

10/15/2008 12:26:00 PM

0

On Wed, Oct 15, 2008 at 1:52 PM, Dan Webb <dbw@aber.ac.uk> wrote:
> 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.

Dan Webb

10/16/2008 2:15:00 PM

0

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.



--
Posted via http://www.ruby-....

Ken Bloom

10/16/2008 9:51:00 PM

0

On Thu, 16 Oct 2008 09:14:37 -0500, Dan Webb wrote:

> 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



--
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...