REXML -- Parsing doctypes (and some some bugs)

Discussion in 'Ruby' started by Daniel Harple, Dec 23, 2005.

  1. (1) How does one parse a doctype in REXML?

    Hack solution --
    #+++++++
    require 'rexml/document'
    data =<<EOF
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE Resource SYSTEM "foo.dtd">
    <Resource>
    <bar>baz</bar>
    </Resource>
    EOF
    p REXML::Document.new(data).doctype.instance_variable_get
    ("@long_name")[1..-2] # => "foo.dtd"
    #+++++++

    There must be a simple solution I am missing, what is it?

    (2) In rexml/dtd/elementdecl, PATTERN_RE is defined twice, issuing a
    warning (see http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/
    REXML/DTD/ElementDecl.html)

    (3)
    #+++++++
    require 'rexml/dtd/dtd'
    data =<<EOF
    <!ELEMENT foo (bar,baz)>
    <!ELEMENT bar (#PCDATA)>
    <!ELEMENT baz (#PCDATA)>
    EOF

    p REXML::DTD::parser.parse(data)
    # => /opt/local/lib/ruby/1.8/rexml/dtd/elementdecl.rb:8: warning:
    already initialized constant PATTERN_RE
    # => /opt/local/lib/ruby/1.8/rexml/dtd/dtd.rb:25:in `parse_helper':
    undefined method `PATTERN_RE' for REXML::DTD::ElementDecl:Class
    (NoMethodError)
    # => from /opt/local/lib/ruby/1.8/rexml/dtd/dtd.rb:14:in `parse'
    #+++++++

    -- Daniel
    Daniel Harple, Dec 23, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wendy Shuya

    Comments and DOCTYPES

    Wendy Shuya, Apr 1, 2004, in forum: XML
    Replies:
    2
    Views:
    381
    Richard Tobin
    Apr 2, 2004
  2. JWL

    Mixing doctypes

    JWL, Oct 13, 2006, in forum: HTML
    Replies:
    5
    Views:
    1,194
    David Dorward
    Oct 16, 2006
  3. UKuser
    Replies:
    2
    Views:
    349
    C A Upsdell
    Feb 4, 2009
  4. the.computational biologist

    including xml entities with their own doctypes

    the.computational biologist, Jul 21, 2011, in forum: XML
    Replies:
    5
    Views:
    1,277
    Joe Kesselman
    Jul 23, 2011
  5. Josef 'Jupp' Schugt

    Still use 'ruby-bugs' for Ruby bugs?

    Josef 'Jupp' Schugt, Nov 4, 2004, in forum: Ruby
    Replies:
    2
    Views:
    161
    Tom Copeland
    Nov 4, 2004
Loading...

Share This Page