Nokorigi HappyMapper Qualified/Unqualified Namespace Parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Auto-generated by jaxb2ruby v0.0.1 on 2014-07-05 13:57:07 -0400 | |
# https://github.com/sshaw/jaxb2ruby | |
# | |
require "happymapper" | |
module Com module Example module Person | |
class Person | |
include HappyMapper | |
register_namespace "ns2", "http://example.com/person" | |
tag "Person" | |
element :name, String, :tag => "name", :namespace => "ns2" | |
end | |
end end end | |
module Com module Example module Company | |
class Company | |
include HappyMapper | |
register_namespace "ns1", "http://example.com/company" | |
namespace "ns1" | |
tag "Company" | |
element :name, String, :tag => "name", :namespace => "ns1" | |
end | |
end end end | |
module Com module Example module Person | |
class Info | |
include HappyMapper | |
register_namespace "ns2", "http://example.com/person" | |
register_namespace "ns1", "http://example.com/company" | |
namespace "ns2" | |
tag "Info" | |
has_one :person, Com::Example::Person::Person, :tag => "person", :namespace => "ns2" | |
has_one :company, Com::Example::Company::Company, :tag => "Company", :namespace => "ns1" | |
end | |
end end end | |
puts Com::Example::Person::Info.parse(File.read("qualified.xml")).to_xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<q:Info xmlns:q="http://example.com/person" xmlns:c="http://example.com/company"> | |
<q:person> | |
<q:name>sshaw</q:name> | |
</q:person> | |
<c:Company> | |
<c:name>Crap LLC</c:name> | |
</c:Company> | |
</q:Info> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Auto-generated by jaxb2ruby v0.0.1 on 2014-07-05 13:29:10 -0400 | |
# https://github.com/sshaw/jaxb2ruby | |
# | |
require "happymapper" | |
module Com module Example module Person | |
class Person | |
include HappyMapper | |
register_namespace "ns2", "http://example.com/person" | |
tag "Person" | |
element :name, String, :tag => "name", :namespace => nil | |
end | |
end end end | |
module Com module Example module Company | |
class Company | |
include HappyMapper | |
register_namespace "ns1", "http://example.com/company" | |
namespace "ns1" | |
tag "Company" | |
element :name, String, :tag => "name", :namespace => nil | |
end | |
end end end | |
module Com module Example module Person | |
class Info | |
include HappyMapper | |
register_namespace "ns2", "http://example.com/person" | |
register_namespace "ns1", "http://example.com/company" | |
namespace "ns2" | |
tag "Info" | |
has_one :person, Com::Example::Person::Person, :tag => "person", :namespace => nil | |
has_one :company, Com::Example::Company::Company, :tag => "Company", :namespace => "ns1" | |
end | |
end end end | |
puts Com::Example::Person::Info.parse(File.read("unqualified.xml")).to_xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<q:Info xmlns:q="http://example.com/person" xmlns:c="http://example.com/company"> | |
<person> | |
<name>sshaw</name> | |
</person> | |
<c:Company> | |
<name>Crap LLC</name> | |
</c:Company> | |
</q:Info> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment