Forum: Ruby Xml Decleration using builder

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
104fcd49d9f843ec98e40883c2fc2a0d?d=identicon&s=25 Dan Webb (danw85)
on 2008-10-15 13:52
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/
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik --- (malesca)
on 2008-10-15 14:26
(Received via mailing list)
On Wed, Oct 15, 2008 at 1:52 PM, Dan Webb <dbw@aber.ac.uk> wrote:
> 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.
104fcd49d9f843ec98e40883c2fc2a0d?d=identicon&s=25 Dan Webb (danw85)
on 2008-10-16 16:15
        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.
851acbab08553d1f7aa3eecad17f6aa9?d=identicon&s=25 Ken Bloom (Guest)
on 2008-10-17 00:10
(Received via mailing list)
On Thu, 16 Oct 2008 09:14:37 -0500, Dan Webb wrote:

>         end
> <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
This topic is locked and can not be replied to.