Hi,
Patrick Chanezon wrote:
> Hi Hiroshi and others,
> I'd like to generate class files from an xsd schema and it seems to me that
> xsd4r looks like a good candidate.
> Is it true?
> Is it part of soap4r?
> Where can I find more docs about that?
xsd4r is a module name which is located in lib/xsd and
lib/wsdl/xmlSchema. It's for XML Schema handling so it might help you.
But it's for WSDL for now (different from JAXB) so all you can do is
generating classdef file from XML Schema definition with bin/xsd2ruby.rb
To say the truth,
xsd2ruby.rb --xsd
is just the same as
wsdl2ruby.rb --classdef
There's no document, as ever. Sorry about that.
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRUScVR9L2jg5EEGlAQJhKgf+MaqGLlixlM3NdV78GdPJOeTfn9hoBzuO
pxkAqUMp9ZOJJIqZVpUG1U1NVZXwsE/CGymVu8udUTwKeukBVYIRo2Cy75SqjLlE
EaBzsz5Z1kUCECoipx1hVMyTJPqtfeMqVLZg+Hk13nPPtW1AsB/JpckXBt4uJlUc
3g/pQajLhpSf3DWwL4EAamXS/rhvfI6jMECMIDMHDMlLDPSOysGxoUHvW11YIvOl
Ci26DTzZgt/PJlqOaCY049xKGuV/p7LpOf4lY/1Ig56BjRVFK1pGcQvaeljp4bIq
hlakxoFPN6KbbpHOJ3rvvM18nSk8wZXG30NMH+ZwR7hFtcyYc6h+EA==
=gquX
-----END PGP SIGNATURE-----
Patrick Chanezon, Google API Evangelist
http://wordpress.chanezon.com/
http://code.google.com/apis/checkout/
Hi,
Patrick Chanezon wrote:
> OK I was able to generate the classes, but how do I serialize/deserialize
> them?
> The Mapping module seems to be at the heart of that, but I don't understand
> how it works.
1. xsd2ruby.rb is just for generating classdef file in Ruby.
2. XSD::Mapping.obj2xml and XSD::Mapping.xml2obj are for XML <-> Ruby
object mapping using class definition, such as a one generated by
xsd2ruby.rb
XML <-> Ruby object mapping based on MappingRegistry is only works for
WSDL. (I should not write it clearly in the previous mail. Sorry.)
Can you prepare WSDL file which only contains your XML Schema definition
in <schema/> tag? Then you can get custom MappingRegistry with
% wsdl2ruby.rb --classdef --mapping_registry
Then, replacing MappingRegistry in
lib/xsd/mapping.rb(XSD::Mapping::MappingRegistry) may work. Do you have
a sample XSD file? I'll try it.
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRUvbFR9L2jg5EEGlAQLk8ggAlY35988YgCH+jRWybZiyyzk9z0RxQRq1
oQJfHoqlzAqyznjM1ZNNKdVP8nFswYdv2RVNyStHRqMXSFuKq/p2PgZa2lgy+Wc0
ClZ/MpmAiQO2vPiu5uzsENm9I/Xi/P8iR8ntBGbCXC+hzftEyBinZmw4OLkII0/F
JbkxQhrnkPuEUDbb1/Aczq3Vym9IP6lw4menXETvoEq5wBI8osq8dUq+N0Zo2omz
WjHQo/vYDLl7Yuc49bVL0AsrLaYOZ8gsFWWCxckmc3xSoNbVlg6U/vmp0dsPySS4
5bLPCiamMWvAnbj3ssfxhwc4YAavbRAHgxK4aBiiQSirvS6IPDjtjQ==
=1Fak
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Patrick Chanezon wrote:
> OK I was able to generate the classes, but how do I serialize/deserialize
> them?
> The Mapping module seems to be at the heart of that, but I don't understand
> how it works.
1. xsd2ruby.rb is just for generating classdef file in Ruby.
2. XSD::Mapping.obj2xml and XSD::Mapping.xml2obj are for XML <-> Ruby
object mapping using class definition, such as a one generated by
xsd2ruby.rb
XML <-> Ruby object mapping based on MappingRegistry is only works for
WSDL. (I should not write it clearly in the previous mail. Sorry.)
Can you prepare WSDL file which only contains your XML Schema definition
in <schema/> tag? Then you can get custom MappingRegistry with
% wsdl2ruby.rb --classdef --mapping_registry
Then, replacing MappingRegistry in
lib/xsd/mapping.rb(XSD::Mapping::MappingRegistry)
may work. Do you have
a sample XSD file? I'll try it.
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRUvbFR9L2jg5EEGlAQLk8ggAlY35988YgCH+jRWybZiyyzk9z0RxQRq1
oQJfHoqlzAqyznjM1ZNNKdVP8nFswYdv2RVNyStHRqMXSFuKq/p2PgZa2lgy+Wc0
ClZ/MpmAiQO2vPiu5uzsENm9I/Xi/P8iR8ntBGbCXC+hzftEyBinZmw4OLkII0/F
JbkxQhrnkPuEUDbb1/Aczq3Vym9IP6lw4menXETvoEq5wBI8osq8dUq+N0Zo2omz
WjHQo/vYDLl7Yuc49bVL0AsrLaYOZ8gsFWWCxckmc3xSoNbVlg6U/vmp0dsPySS4
5bLPCiamMWvAnbj3ssfxhwc4YAavbRAHgxK4aBiiQSirvS6IPDjtjQ==
=1Fak
-----END PGP SIGNATURE-----
Your reply has helped me out too. One more question. I want the
specified classname to become the generated file name. Looking at the
code I don't think it does that. Correct?
I would like to be able to extend the bin/xsd2ruby.rb to codegen all
xsd files in a directory, but if defaults to naming the generated file
default.rb this won't work.
Any ideas?
Thanks.
Kit
Hi P@,
Sorry for the late response.
Patrick Chanezon wrote:
> http://code.google.com/apis/checkout/apiv2.xsd
I've just added a feature to xsd2ruby.rb, the feature is for generating
mapping registry from XML Schema. Now it works like the following;
0% xsd2ruby.rb --xsd http://code.google.com/apis/checkout/apiv2.xsd
- --classdef --mapping_registry --mapper --force
ignored attr: {http://www.w3.org/2001/XMLSchema-instance}schemaLocation
ignored element: {http://www.w3.org/2001/XMLSchema}minInclusive of
WSDL::XMLSchema::SimpleRestriction
I, [2007-06-19T23:24:38.513272 #24943] INFO -- app: Creating class
definition.
I, [2007-06-19T23:24:38.514529 #24943] INFO -- app: Creates file 'v_2.rb'.
created definition re-opens an existing toplevel class: Address
I, [2007-06-19T23:24:38.701531 #24943] INFO -- app: Creating mapping
registry definition.
I, [2007-06-19T23:24:38.702477 #24943] INFO -- app: Creates file
'v_2_mapping_registry.rb'.
I, [2007-06-19T23:24:38.805989 #24943] INFO -- app: Creating mapper
definition.
I, [2007-06-19T23:24:38.807465 #24943] INFO -- app: Creates file
'v_2_mapper.rb'.
I, [2007-06-19T23:24:38.809401 #24943] INFO -- app: End of app. (status: 0)
0% cat marshal.rb
require 'v_2_mapper'
mapper = V_2Mapper.new
obj = CheckoutShoppingCart.new
obj.shopping_cart = ShoppingCart.new
puts mapper.obj2xml(obj)
p mapper.xml2obj(mapper.obj2xml(obj))
0% ruby marshal.rb
<?xml version="1.0" encoding="utf-8" ?>
<CheckoutShoppingCart xmlns:n1="http://www.w3.org/2001/XMLSchema-instance"
xmlns:n2="http://checkout.google.com/schema/2"
n1:type="n2:CheckoutShoppingCart">
<n2:shopping-cart n1:type="n2:ShoppingCart">
<n2:items n1:nil="true"></n2:items>
</n2:shopping-cart>
<n2:checkout-flow-support n1:nil="true"></n2:checkout-flow-support>
</CheckoutShoppingCart>
#<CheckoutShoppingCart:0xb7e519f8
@shopping_cart=#<ShoppingCart:0xb7e518f4 @items=nil>,
@checkout_flow_support=nil>
I don't think that this empty example demonstrates this feature enough.
And it must be too late for you... Writing this for the person who
will be interested in Ruby XML mapping based on XML Schema.
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRnfqAB9L2jg5EEGlAQLrgQgAvF7+fUAC4bEbCwrAR/AsOTZzXFYjSCxE
ZWK9yQgf188A22+mCeXicM/iRg4LYhE2gKZKNyUoqZ01KZ/O8iVjxj1hg8hCdzjd
M3xLvd13451E+ANT6ZrMa5GnyMIWQfIO+dryEtO8nOyJ8BXivHRBxgOOdDfg/Av4
HYHjngQqdeeex2V77hhqpcxH0D/MWzkWMosUEObpHNlHfKfOHcbxYMe58qFeHmuN
hPyS8yjOcwdyV+PmwyfES/wNR/Qc/tJY3EAW5X1QC2h+rlYhFmc2bGXkAT0s85/I
lTziiZs4+ULoXBZ85Bax6K116u3EyByJBLxGN8PWFMkv9ikQC/W9dQ==
=AN9b
-----END PGP SIGNATURE-----
Hi,
Sorry for the late response.
kitpl...@gmail.com wrote:
> Your reply has helped me out too. One more question. I want the
> specified classname to become the generated file name. Looking at the
> code I don't think it does that. Correct?
Yes, it was two minutes ago. Now xsd2ruby.rb accepts the option:
- --classdef [basename]
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRnfqkx9L2jg5EEGlAQJpwQgAlwyzlErkVGZ8+lu+pL9URyvUbrYIRffM
jmd5THFB5a+DU7Mf+1bAOw7vOGXNBFIxJGu9DlOqsFdVII+VRpTUOML7D5C/p6L4
TAmzMrXQcQ1PwrU9oi6mfpDss0m2qMR3M9vKZnCByOuF2Pxgx8pCJjso551XWAcP
ojM5o2lFtoYJu65hQXNoeGoLVeVR3EecExW0QpCT40AGnvme1oM0ADh/RjV+bTJD
pNtFqCWtA64UdYCPEvgRpsHwXCM2e/i5BlWoSyU5e3wF5T63HNVyaMCRSLi4v4U4
BdG2kM8QlPyJY+r7e6bNjrrQVgZ2UAQ3vOYBnRt7z5MNk2LmbmiIBQ==
=SgMd
-----END PGP SIGNATURE-----
I'd like to use xsd2ruby like XMLToSQL in java. (It is used to insert,
update, or delete rows in a database table using an XML document).
At least to generate a SQL-databas. Is it possible?
Thanks in advance.
oezkanp
On Jun 19, 4:39 pm, "NAKAMURA, Hiroshi" <nakah...@sarion.co.jp> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> Sorry for the late response.
>
Hi,
oez...@googlemail.com wrote:
> I'd like to use xsd2ruby like XMLToSQL in java. (It is used to insert,
> update, or delete rows in a database table using an XML document).
> At least to generate a SQL-databas. Is it possible?
I don't know XMLToSQL well but from your explanation above, it's hardly
doable I think. xsd2ruby.rb is for generating stub files from XML
Schema for mapping Ruby object and XML.
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRpY1Px9L2jg5EEGlAQKQoAf/eI8BEdA8q8JkdF0nnzHfu7LD1msbesAU
eYZSZldwMzbfiS904nUg3PgCbKrCdpkdnKWVYh/rxo0r7nDeT6hJY6Nb2YBoqF/9
hz7m/K2Y7BZXXcuL0ZVwMqEeBhXfD1jsc25lNOhZKqDD/92wHCyZEhLhSubPT1+x
uZAV2l0mi+AZTXyzjadReoJ9Dr8H8pKJCPa9FfhkKQwP0jm5gmtfnc2Hm5VHA6mM
iv97Ys2Qmw6Ifn+SOK+5aEP65NPgGxUIScH9FMBC0ChCGSKdYNE5/rOSPK3Izm76
HclyOZlG+Alhdx2XAFA+TiHgDam2Km3brYN2POH125vM6X2Z4vNkLg==
=+R/W
-----END PGP SIGNATURE-----