From emmett.shear at gmail.com Sat Feb 3 23:02:13 2007
From: emmett.shear at gmail.com (Emmett Shear)
Date: Sat, 3 Feb 2007 20:02:13 -0800
Subject: [libxml-devel] Formatting output to nonstandard xml
Message-ID: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
I have a program that I am forced to work with that stores its
settings in a very non-compliant XML format. It's UTF-16, but it lacks
the byte markers, and it uses tags of the form instead of
. Libxml has been awesome - it read the file perfectly.
Unfortunately the program won't read any file that deviates even
slightly from the expected format, and libxml fixes the files when it
outputs my changes.
I can remove the byte order markers myself pretty easily; is there any
way to force libxml to output empty tags in form?
Thanks,
Emmett
From transfire at gmail.com Sun Feb 4 06:32:41 2007
From: transfire at gmail.com (TRANS)
Date: Sun, 4 Feb 2007 06:32:41 -0500
Subject: [libxml-devel] Formatting output to nonstandard xml
In-Reply-To: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
References: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
Message-ID: <4b6f054f0702040332k7ddf9499t81832018b2da8b1b@mail.gmail.com>
On 2/3/07, Emmett Shear wrote:
> I have a program that I am forced to work with that stores its
> settings in a very non-compliant XML format. It's UTF-16, but it lacks
> the byte markers, and it uses tags of the form instead of
> . Libxml has been awesome - it read the file perfectly.
> Unfortunately the program won't read any file that deviates even
> slightly from the expected format, and libxml fixes the files when it
> outputs my changes.
>
> I can remove the byte order markers myself pretty easily; is there any
> way to force libxml to output empty tags in form?
Would your app choke if you put a " " in there? All I could think of
off the top of my head.
T.
From keith at oreilly.com Sun Feb 4 10:52:42 2007
From: keith at oreilly.com (Keith Fahlgren)
Date: Sun, 04 Feb 2007 07:52:42 -0800
Subject: [libxml-devel] Formatting output to nonstandard xml
In-Reply-To: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
References: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
Message-ID: <45C6014A.4010708@oreilly.com>
Emmett Shear wrote:
> I can remove the byte order markers myself pretty easily; is there any
> way to force libxml to output empty tags in form?
Hi Emmett,
I think what you want to manipulate is xmlSaveNoEmptyTags[1] sadly, I don't know
enough C and can't find anything similar to try to copy.
All that said, Trans' hack is a good one:
$ irb --prompt xmp libxml2.irb && cat output.xml
require 'rubygems' # if installed via Gems
# => true
require 'xml/libxml'
# => true
doc = XML::Document.new()
# =>
doc.root = XML::Node.new('root_node')
# =>
root = doc.root
# =>
root << elem1 = XML::Node.new('elem1', "")
# =>
elem1['attr1'] = 'val1'
# => "val1"
elem1['attr2'] = 'val2'
# => "val2"
root << elem2 = XML::Node.new('elem2', "")
# =>
elem2['attr1'] = 'val1'
# => "val1"
elem2['attr2'] = 'val2'
# => "val2"
root << elem3 = XML::Node.new('elem3', "")
# =>
# Namespace hack to reduce the numer of times XML:: is typed
include XML
# => Object
root << elem7 = Node.new('foo')
# =>
1.upto(10) {|i| elem7 << n = Node.new("bar#{i}", "") }
# => 1
format = true
# => true
doc.save('output.xml', format)
# => 352
HTH,
Keith
1. http://xmlsoft.org/html/libxml-globals.html#xmlSaveNoEmptyTags
From emmett.shear at gmail.com Mon Feb 5 15:33:36 2007
From: emmett.shear at gmail.com (Emmett Shear)
Date: Mon, 5 Feb 2007 12:33:36 -0800
Subject: [libxml-devel] Formatting output to nonstandard xml
In-Reply-To: <4b6f054f0702040332k7ddf9499t81832018b2da8b1b@mail.gmail.com>
References: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
<4b6f054f0702040332k7ddf9499t81832018b2da8b1b@mail.gmail.com>
Message-ID: <860712640702051233r46b0a67cn1488b23a18612ec4@mail.gmail.com>
On 2/4/07, TRANS wrote:
> Would your app choke if you put a " " in there? All I could think of
> off the top of my head.
>
> T.
I tried TRANS's hack, and it turns out just setting content = ""
forces libxml to output the matching end tag.
Unfortunately, the program I have is still barfing on the input. The
output generated is now *exactly* the same as the input file, except
for one tiny difference:
input:
baz
libxml output:
baz
And that tiny difference seems to cause the xml parser in the program to die.
Is there some way to tell libxml to add in useless whitespace like that?
Thanks for all the help so far,
Emmett
From sarah at colorfulexpressions.com Tue Feb 6 13:53:55 2007
From: sarah at colorfulexpressions.com (Sarah Mei)
Date: Tue, 06 Feb 2007 10:53:55 -0800
Subject: [libxml-devel] Installing on Debian Sarge
Message-ID: <45C8CEC3.7000605@colorfulexpressions.com>
Hi folks,
I installed the ruby libxml bindings on my OSX dev machine with no
problem, but I'm hitting a brick wall trying to get them onto our Debian
Sarge test server.
I first tried a gem install:
railstest:~# gem install libxml-ruby
Building native extensions. This could take a while...
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
The mkmf.log file indicated that it failed on a call to atan, presumably
checking for libm. I have libm.so and libm.a in /usr/lib, and
/usr/lib/libm.so links to /lib/libm.so.6.
Next, I downloaded the tarball and tried compiling it myself.
railstest:~/libxml-ruby-0.3.8.4/ext/xml# ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... no
checking for atan() in -lm... no
extconf failure: need libm
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Looks like the same problem - can't find libm. I added a few debug
statements to extconf.rb, and $LIBPATH does include /usr/lib.
I've been trying --with-mlib=/usr/lib, --with-mlib=/usr/lib/libm.so, and
so forth, but it doesn't make a dent - same error every time. I'm
running ruby 1.8.4 and gcc 3. Our admin doesn't want to upgrade to
gcc4, though if it's the only way to fix this, I think I can change her
mind. ;-)
Is this a gcc version issue? Any ideas will be most appreciated.
From keith at oreilly.com Tue Feb 6 14:45:35 2007
From: keith at oreilly.com (Keith Fahlgren)
Date: Tue, 06 Feb 2007 11:45:35 -0800
Subject: [libxml-devel] Formatting output to nonstandard xml
In-Reply-To: <45C6014A.4010708@oreilly.com>
References: <860712640702032002x3bdb3522v8e13859c2c5efe45@mail.gmail.com>
<45C6014A.4010708@oreilly.com>
Message-ID: <45C8DADF.5020508@oreilly.com>
Hey Emmett, dunno if you saw this response (below), but here's the relevant bit:
# just make sure you format it on output
> format = true
> # => true
> doc.save('output.xml', format)
> # => 352
>
>
>
>
>
>
>
>
via Document#save http://libxml.rubyforge.org/doc/classes/XML/Document.html#M000287
HTH,
Keith
Keith Fahlgren wrote:
> Emmett Shear wrote:
>> I can remove the byte order markers myself pretty easily; is there any
>> way to force libxml to output empty tags in form?
>
> Hi Emmett,
>
> I think what you want to manipulate is xmlSaveNoEmptyTags[1] sadly, I don't know
> enough C and can't find anything similar to try to copy.
>
> All that said, Trans' hack is a good one:
>
> $ irb --prompt xmp libxml2.irb && cat output.xml
> require 'rubygems' # if installed via Gems
> # => true
> require 'xml/libxml'
> # => true
>
> doc = XML::Document.new()
> # =>
>
> doc.root = XML::Node.new('root_node')
> # =>
> root = doc.root
> # =>
>
> root << elem1 = XML::Node.new('elem1', "")
> # =>
> elem1['attr1'] = 'val1'
> # => "val1"
> elem1['attr2'] = 'val2'
> # => "val2"
>
> root << elem2 = XML::Node.new('elem2', "")
> # =>
> elem2['attr1'] = 'val1'
> # => "val1"
> elem2['attr2'] = 'val2'
> # => "val2"
>
> root << elem3 = XML::Node.new('elem3', "")
> # =>
>
> # Namespace hack to reduce the numer of times XML:: is typed
> include XML
> # => Object
> root << elem7 = Node.new('foo')
> # =>
> 1.upto(10) {|i| elem7 << n = Node.new("bar#{i}", "") }
> # => 1
>
> format = true
> # => true
> doc.save('output.xml', format)
> # => 352
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> HTH,
> Keith
> 1. http://xmlsoft.org/html/libxml-globals.html#xmlSaveNoEmptyTags
> _______________________________________________
> libxml-devel mailing list
> libxml-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/libxml-devel
>
From dracognizer at gmail.com Tue Feb 6 15:35:44 2007
From: dracognizer at gmail.com (Thibault Martin-Lagardette)
Date: Tue, 6 Feb 2007 21:35:44 +0100
Subject: [libxml-devel] problems using libxml on Ubuntu 6.10
Message-ID:
Hello all.
As a PHP developer, I recently decided to get to know ruby, and
wanted, as a beginning, to create a small ruby gmail client, like the
python one.
Working under Ubuntu 6.10, I installed ruby 1.8 via apt-get, and then
RubyGems myself.
After beeing able to retrieve the XML atom feed from Gmail, I wanted
to parse the XML file.
I didn't want to use Rexml when I saw its performances.
Thus I installed libxml-ruby via the command: "gem install -r libxml-ruby".
And now that I want to use it, here's what I get:
-- Snippet --
/usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8.4/lib/xml/libxml.rb:5:
uninitialized constant XML
(NameError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from ./gmail-atom.rb:6
-- End Snippet --
Here's my little bit of code :
-- Snippet --
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'xml/libxml_so' # I tried w/ and w/o it...
require 'xml/libxml'
open("https://mail.google.com/mail/feed/atom",
:http_basic_authentication => ['login', 'passwd']
) do |content|
feed = content.read
xmlfeed = XML::Parser.string(feed).parse
xmlroot = xmlfeed.root
p xmlroot.class
p xmlroot.methods.sort
end
-- End Snippet --
The matter is that xml/libxml doesn't seem to load libxml_so.so which
is where the XML module is defined...
Downloading the gem, or the source and building it myself does the same thing.
And oh, I tried installing libxml via apt-get, buth it's the 3.4
version, and without, for instance, the "each" or "first_child"
methods...
Any idea?
Thanks a lot in advance!
--
Thibault Martin-Lagardette.
From transfire at gmail.com Wed Feb 7 09:09:54 2007
From: transfire at gmail.com (TRANS)
Date: Wed, 7 Feb 2007 09:09:54 -0500
Subject: [libxml-devel] problems using libxml on Ubuntu 6.10
In-Reply-To:
References:
Message-ID: <4b6f054f0702070609h526b7d36k3762a157790a5a34@mail.gmail.com>
On 2/6/07, Thibault Martin-Lagardette wrote:
> Hello all.
>
> As a PHP developer, I recently decided to get to know ruby, and
> wanted, as a beginning, to create a small ruby gmail client, like the
> python one.
>
> Working under Ubuntu 6.10, I installed ruby 1.8 via apt-get, and then
> RubyGems myself.
>
> After beeing able to retrieve the XML atom feed from Gmail, I wanted
> to parse the XML file.
> I didn't want to use Rexml when I saw its performances.
> Thus I installed libxml-ruby via the command: "gem install -r libxml-ruby".
>
> And now that I want to use it, here's what I get:
>
> -- Snippet --
> /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8.4/lib/xml/libxml.rb:5:
> uninitialized constant XML
> (NameError)
> from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
> `require'
> from ./gmail-atom.rb:6
> -- End Snippet --
>
> Here's my little bit of code :
>
> -- Snippet --
> #!/usr/bin/ruby
>
> require 'rubygems'
> require 'open-uri'
> require 'xml/libxml_so' # I tried w/ and w/o it...
> require 'xml/libxml'
>
> open("https://mail.google.com/mail/feed/atom",
> :http_basic_authentication => ['login', 'passwd']
> ) do |content|
> feed = content.read
> xmlfeed = XML::Parser.string(feed).parse
> xmlroot = xmlfeed.root
> p xmlroot.class
> p xmlroot.methods.sort
> end
> -- End Snippet --
>
>
> The matter is that xml/libxml doesn't seem to load libxml_so.so which
> is where the XML module is defined...
> Downloading the gem, or the source and building it myself does the same thing.
> And oh, I tried installing libxml via apt-get, buth it's the 3.4
> version, and without, for instance, the "each" or "first_child"
> methods...
>
> Any idea?
Did you figure this out? I don't think you should need the _so
require. BUt I'm not sure what the issue it.
T.
From tecumtah at gmail.com Wed Feb 7 09:59:21 2007
From: tecumtah at gmail.com (tecumtah at gmail.com)
Date: Wed, 7 Feb 2007 15:59:21 +0100
Subject: [libxml-devel] problems using libxml on Ubuntu 6.10
In-Reply-To: <4b6f054f0702070609h526b7d36k3762a157790a5a34@mail.gmail.com>
References:
<4b6f054f0702070609h526b7d36k3762a157790a5a34@mail.gmail.com>
Message-ID: <995101b90702070659o7b61f93aw8d12ffa40280bfbb@mail.gmail.com>
I am on Ubuntu 6.10 as well, installed libxml as you proposed:
"gem install -r libxml-ruby"
~$ gem list --local | grep xml
libxml-ruby (0.3.8.4)
So version is 0.3.8.4
Your code runs without problems here.
xmlroot.child.each is available here, too
I don't think you need the
require 'xml/libxml_so'
because this line is included in
/usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8.4/lib/xml/libxml.rb
If your ruby does not find libxml_so, you could check if it is available in
/usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8.4/lib/xml/libxml_so.so
But I have several further lixm packages installed:
~$ dpkg -l | grep libxml
ii libxml++2.6c2a 2.14.0-0ubuntu1
A C++ interface to the GNOME XML library (li
ii libxml-grove-perl 0.46alpha-11
Perl module for accessing parsed *ML instanc
ii libxml-parser-perl 2.34-4
Perl module for parsing XML files
ii libxml-perl 0.08-1
Perl modules for working with XML
ii libxml1 1.8.17-13
GNOME XML library
ii libxml2 2.6.27.dfsg-1ubuntu1
GNOME XML library
ii libxml2-dev 2.6.27.dfsg-1ubuntu1
Development files for the GNOME XML library
ii libxml2-utils 2.6.26.dfsg-2ubuntu4
XML utilities
ii libxmlsec1 1.2.9-3ubuntu2
XML security library
ii libxmlsec1-nss 1.2.9-3ubuntu2
Nss engine for the XML security library
ii libxmlsec1-openssl 1.2.9-3ubuntu2
Openssl engine for the XML security library
ii python-libxml2 2.6.26.dfsg-2ubuntu4
Python bindings for the GNOME XML library
Do you have libxml2 installed?
Found any solution already?
Silvan
On 2/7/07, TRANS wrote:
>
> On 2/6/07, Thibault Martin-Lagardette wrote:
> > Hello all.
> >
> > As a PHP developer, I recently decided to get to know ruby, and
> > wanted, as a beginning, to create a small ruby gmail client, like the
> > python one.
> >
> > Working under Ubuntu 6.10, I installed ruby 1.8 via apt-get, and then
> > RubyGems myself.
> >
> > After beeing able to retrieve the XML atom feed from Gmail, I wanted
> > to parse the XML file.
> > I didn't want to use Rexml when I saw its performances.
> > Thus I installed libxml-ruby via the command: "gem install -r
> libxml-ruby".
> >
> > And now that I want to use it, here's what I get:
> >
> > -- Snippet --
> > /usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8.4/lib/xml/libxml.rb:5:
> > uninitialized constant XML
> > (NameError)
> > from
> /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
> > `require'
> > from ./gmail-atom.rb:6
> > -- End Snippet --
> >
> > Here's my little bit of code :
> >
> > -- Snippet --
> > #!/usr/bin/ruby
> >
> > require 'rubygems'
> > require 'open-uri'
> > require 'xml/libxml_so' # I tried w/ and w/o it...
> > require 'xml/libxml'
> >
> > open("https://mail.google.com/mail/feed/atom",
> > :http_basic_authentication => ['login', 'passwd']
> > ) do |content|
> > feed = content.read
> > xmlfeed = XML::Parser.string(feed).parse
> > xmlroot = xmlfeed.root
> > p xmlroot.class
> > p xmlroot.methods.sort
> > end
> > -- End Snippet --
> >
> >
> > The matter is that xml/libxml doesn't seem to load libxml_so.so which
> > is where the XML module is defined...
> > Downloading the gem, or the source and building it myself does the same
> thing.
> > And oh, I tried installing libxml via apt-get, buth it's the 3.4
> > version, and without, for instance, the "each" or "first_child"
> > methods...
> >
> > Any idea?
>
> Did you figure this out? I don't think you should need the _so
> require. BUt I'm not sure what the issue it.
>
> T.
> _______________________________________________
> libxml-devel mailing list
> libxml-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/libxml-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/libxml-devel/attachments/20070207/1086e992/attachment-0001.html