I fully agree…and I apologize for misrepresentation. I was thinking
more of usage here. yaml4r is a single file that gives me much of what
I want in managing configuration data. It can be used for more than
that, but that is what I use it for most often. It lacks many things of
XML++ including cross-language libraries. The original question was
one of XML and YAML. I inferred from the initial posts that the
question was w/plain XML vs. YAML. I just think that in common usage,
XML formats are discussed, designed…parsers + emitters are written
and then used. I skip these steps for YAML. I just write Ruby objects
and they can be simply marshall/unmashalled in a readable format. Oh,
and editability by hand of complex YAML is not that bad. Typically you
are changing values and they are easy to find and edit in a YAML file.
Also, I must say that I have recently been doing A LOT of XML and Ruby
work. Its because of Ruby’s ease of use both as a language and an XML
processor (thanks Sean for REXML) that I was able to “win” against both
Java and Python in a current (internal) project.
I am not trying to advocate for YAML to replace XML, but YAML is really
nice to use in many circumstances. Like they say, if you only have a
hammer, everything looks like a nail. That is how many people approach
XML and (like programming languages) its better to have many tools in
the toolbox than just a hammer
-rich
PS. NaHi…your SOAP/WSDL libraries are and I am looking to
do wonderful things with them…so thank you for all your work. I am a
true believer that scripting languages and Web Services are a perfect
match for each other.
···
On Wednesday, March 19, 2003, at 06:38 AM, NAKAMURA, Hiroshi wrote:
It’s to be expected that yamlrb(YAML + Ruby language mapping)
can do more without extentions. As Brian stated, we should
not compare (plain) XML vs YAML.
Typing is an option. Think of typing information as metadata provided to the
loader, indicating how a node should be loaded. As YAML loaders improve and
move forward, you’ll see the ability to change typing on nodes based on YPath
expressions and schemas. Typing “when and where” you want it.
Just different classes. Ruby’s sufficiently flexible to not
really care too much in most circumstances.
Isn’t this a feature, then, of Ruby, not YAML? If I tried this in
say, Java, wouldn’t I have a problem?
I gave a fairly simple example. Ruby might be less forgiving if I
switched from an Array to a Hash.
I don’t want to belabor this; clearly I need to play around more YAML, but
the notion of coupling application logic (“treat this text as a Hash”) with
data bothers me.
Ah…the key is that you do not design the data file…this is an XML
thing. The to_yaml method creates the format off your object model.
So, rather than chose a confg file format that is easiest for my users, I
write an app and just live withever what falls out? That can’t be right.
action: “snip”
it’s an integer. If later I decide that floats are better and want
change
my
code, don’t the older data files have to be rewritten?
Actually, what will happen is a Hash will be created with a key
(“some_key”) and the value(23). If you change to floats, the Hash will
have the key (“some_key”) and the value(23.0). It all depends on your
use of these objects as to whether this will fail. But this is the
same for XML too. If you have a parser that expects a certain format
in the value of an attribute like:
some_num=“23”
and then do:
some_num=“23.0”
you have to update your parser.
Well, no, I update the business logic that uses string values returned
from the XML parser.
If you update it, will it break with
old files? How long does your parser read the old format and convert
to the new?
Oh, and did I say that YAML files are readable?
You did, but I’m not always seeing that when I read the YAML spec.
And XML specs are readable???..I was talking about the YAML content,
So was I. Reading the spec, and looking at the examples, I get the
inmpression
that once you get past foo: bar examples YAML can be a bit gnarly.
But, again, I need to use it more.
not specification. The YAML library deals with the spec. I write Ruby
code and let it emit and parse it.
From: why the lucky stiff
Sent: Wednesday, March 19, 2003 11:57 PM
In most of my use cases, yes. If I want typing info, it’s
easy enough to add when and where I want it. I prefer it
to be an option, not a requirement.
Typing is an option. Think of typing information as metadata
provided to the
loader, indicating how a node should be loaded. As YAML
loaders improve and
move forward, you’ll see the ability to change typing on
nodes based on YPath
expressions and schemas. Typing “when and where” you want it.
Sorry for bothering with XML staff, here is WSDL + WSDL4R
example.
Generate Ruby’s class definition from the WSDL file.
$ wsdl2ruby.rb --wsdl person.wsdl --classDef --force
I, [2003-03-20T09:36:22.387171 #2416] INFO – app: Start of app.
I, [2003-03-20T09:36:22.416171 #2416] INFO – app: Creating class definition.
I, [2003-03-20T09:36:22.419171 #2416] INFO – app: Creates file ‘Person.rb’.
I, [2003-03-20T09:36:22.433171 #2416] INFO – app: End of app. (status: 0)
def dump(obj, io = nil)
ele = Mapping.obj2soap(obj)
# WSDL4R does not support element name based complexType for now
# (type based complexType only.)
ele.elementName = ele.type
Processor.marshal(nil, SOAPBody.new(ele), @opt, io)
end
def load(io)
header, body = Processor.unmarshal(io, @opt)
Mapping.soap2obj(body.rootNode)
end
end
may be enough readable for some purpose (but I agree that
it’s still hard to edit as a configuration file. At least
I don’t adopt it for my product. Go YAML!)
Hmm. In the above example, I found “xmlns:n1=…” and
“env:encodingStyle=…” could be removed. It should be
I am not trying to advocate for YAML to replace XML, but YAML is really
nice to use in many circumstances.
Agreed. Sure it’s good to have many tools in the toolbox and select
the best tool for each circumstance.
PS. NaHi…your SOAP/WSDL libraries are and I am looking to
Thanks.
do wonderful things with them…so thank you for all your work. I am a
true believer that scripting languages and Web Services are a perfect
match for each other.
Me, too.
Now I’m working on XML canonicalization, signature and encryption.
I hope I see it till next summar.