[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

REXML + DTD example

carp __

4/24/2007 12:42:00 PM

Hello Rubyists,

I'd like to have a custom made XML configuration file parsed with a
custom made DTD file. However, the documentation at
http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXM...
doesn't help me a lot. Is there anybody who could paste a simple 4-liner
example scenario about how this would be done?

Thanks a lot in advance

-carp

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

4 Answers

Robert Klemme

4/24/2007 1:05:00 PM

0

On 24.04.2007 14:42, carp __ wrote:
> I'd like to have a custom made XML configuration file parsed with a
> custom made DTD file. However, the documentation at
> http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXM...
> doesn't help me a lot. Is there anybody who could paste a simple 4-liner
> example scenario about how this would be done?

Did you look at
http://www.germane-software.com/softw...docs/tut...
reachable from http://www.germane-software.com/softw... ?

robert

Clifford Heath

4/24/2007 11:18:00 PM

0

carp __ wrote:
> Hello Rubyists,
>
> I'd like to have a custom made XML configuration file parsed with a
> custom made DTD file. However, the documentation at
> http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXM...
> doesn't help me a lot. Is there anybody who could paste a simple 4-liner
> example scenario about how this would be done?

RexML can't do external DTDs, and the author told me it won't ever,
as he believes that the syntax is too evil to even contemplate.

When I needed to do it, on Windows systems having cygwin installed,
I just opened the XML file using a pipe from xmllint, which was
launched with the right parameters to make it expand the entities
from an external DTD. The main awkwardness comes from the fact that
xmllint looks for unqualified DTD files in the same directory as
the XML file, so you need to extract the directory pathname from
the file's basename and cd to that directory first:

cmd = "sh -c 'cd #{dir}; xmllint --loaddtd --noent - <#{base}'"
infile = popen(cmd)

Best of luck.

Clifford Heath.

carp __

4/25/2007 10:02:00 AM

0

Clifford Heath wrote:

> RexML can't do external DTDs, and the author told me it won't ever,
> as he believes that the syntax is too evil to even contemplate.
>
> When I needed to do it, on Windows systems having cygwin installed,
> I just opened the XML file using a pipe from xmllint, which was
> launched with the right parameters to make it expand the entities
> from an external DTD. The main awkwardness comes from the fact that
> xmllint looks for unqualified DTD files in the same directory as
> the XML file, so you need to extract the directory pathname from
> the file's basename and cd to that directory first:
>
> cmd = "sh -c 'cd #{dir}; xmllint --loaddtd --noent - <#{base}'"
> infile = popen(cmd)
>

Thanks for that hint, Clifford. I did it with xmllint now - a bit ugly
as it makes the script less portable, but well ... better than nothing I
guess. Thanks again!

-carp

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

Clifford Heath

4/25/2007 1:11:00 PM

0

carp __ wrote:
> Thanks for that hint, Clifford.

You're welcome. It took a bit of headscratching before
I convinced myself we had to go that way, but seeing
that we had a type of XML file that needed to be expanded
with two different sets of entities (for code generation
and for documentation generation), it was only pragmatic.

Clifford.