movitto / RXSD

XSD / Ruby Translator
http://projects.morsi.org/RXSD
GNU Lesser General Public License v3.0
85 stars 35 forks source link

Namespace Problem? #15

Open mikegee opened 10 years ago

mikegee commented 10 years ago

This sample code raises: undefined method 'new' for "simpletest:testMessage":String (NoMethodError). I would greatly appreciate any help.

require "rxsd"

schema = RXSD::Parser.parse_xsd raw: <<XSD
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
    targetNamespace="http://www.covermymeds.com/cmmtest" version="1.0"
    xmlns:simpletest="http://www.covermymeds.com/cmmtest"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:attribute name="msgType" type="xsd:string"/>
    <xsd:complexType name="testMessage">
        <xsd:sequence>
            <xsd:element name="header" type="simpletest:headerType"/>
            <xsd:element name="body" type="simpletest:bodyType"/>
        </xsd:sequence>
        <xsd:attribute ref="simpletest:msgType"/>
    </xsd:complexType>
    <xsd:element name="Message" type="simpletest:testMessage"/>
    <xsd:simpleType name="headerType">
        <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    <xsd:simpleType name="bodyType">
        <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
</xsd:schema>
XSD

doc = RXSD::Parser.parse_xml raw: <<XML
<?xml version="1.0" encoding="UTF-8"?>
<simpletest:Message xmlns:simpletest="http://www.covermymeds.com/cmmtest">
    <simpletest:header>header goes here</simpletest:header>
    <simpletest:body>body goes here</simpletest:body>
</simpletest:Message>
XML

doc.to :ruby_objects, schema: schema