Oh, sorry my bad. lib/dtds/product.dtd is:
<!ELEMENT product (primary_key|name|definition_id)* >
<!ATTLIST product target_entity CDATA #REQUIRED>
<!ELEMENT primary_key (#PCDATA)>
<!ATTLIST primary_key name CDATA #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT definition_id (#PCDATA)>
For the test case I created a directory libxmltest with the path lib/
dtds/ containing product.dtd and definition.dtd
My script looks like:
##test_libxml.rb
require 'rubygems'
require 'xml'
xml = '<?xml version="1.0"?>
<definition target_entity="Definition">
<primary_key name="id">1</primary_key>
<reasoning>new def reasoning</reasoning>
<body>new def body</body>
<products>
<product target_entity="Product">
<primary_key name="id">2</primary_key>
<definition_id>1</definition_id>
</product>
</products>
</definition>'
begin
doc = XML::Parser.string(xml).parse
rescue LibXML::XML::Error => e
raise LibXML::XML::Error.new, "#{e.message}\nXML dump: #{xml}"
end
dtd = XML::Dtd.new(File.read("lib/dtds/definition.dtd"))
puts doc.validate(dtd) ? "Success!" : "Failure!"
##Output:
ruby test_libxml.rb
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
Aborted
On Feb 8, 4:01 pm, Charlie Savage <[email protected]> wrote:
> Hi Michael,
>
> > <!ENTITY % product SYSTEM "lib/dtds/product.dtd">
> > %product;
>
> >>From that I get:
> > ./app/models/queue_item.rb:44: [BUG] Segmentation fault
> > Line 44 is: dtd = XML::Dtd.new(File.read(Rails.root + "/lib/dtds/"
> > + dtd_filename))
> > where dtd_filename is definition.dtd
>
> Works fine here, but you didn't post lib/dtds/product.dtd, so the test I
> have is different than yours.
>
> > So my question is, does anyone know if [BUG] is indicating a bug in
> > libxml-ruby or something that I'm doing wrong?
>
> It sounds like a libxml bug - can you post a test case that shows it
> happening? If so, it should be easy to fix.
>
> Charlie
>
> smime.p7s
> 4KViewDownload
>
> _______________________________________________
> libxml-devel mailing list
> [email protected]http://rubyforge.org/mailman/listinfo/libxml-devel
_______________________________________________
libxml-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/libxml-devel