Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible naming error in codegen #36

Closed
ghost opened this issue Apr 18, 2011 · 1 comment
Closed

Possible naming error in codegen #36

ghost opened this issue Apr 18, 2011 · 1 comment
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Apr 18, 2011

Once again using the vCloud API 1.0 XSDs, generating the code, compiling it (successfully!) and attempting to use it with:

import scalaxb._
import com.vmware.vcloud._
...

results in:

[info] == test-compile ==
[info]   Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling test sources...
[error] class file needed by XMLProtocol is missing.
[error] reference type Network of package com.vmware.vcloud refers to nonexisting symbol.
[error] one error found
[info] == test-compile ==
[error] Error running test-compile: Compilation failed

There is a network.scala file, but it declares NetworkType, among other things, rather than Network.

@ghost ghost assigned eed3si9n Apr 19, 2011
@eed3si9n
Copy link
Owner

could you specify the reproduction steps, problems, and expectations for the naming error?

Network

network.scala does not includes NetworkType because that's what network.xsd defines:

<xs:complexType name="NetworkType" abstract="true">
    <xs:annotation>
        <xs:documentation xml:lang="en">
            Represents a Network in the vCloud model.
        </xs:documentation>
    </xs:annotation>
    ...

what's Network? let's grep it:

$ grep "Network(" `find . -name "*.scala"`
./out/dmtf/dsp8023_1.1.0.scala:case class Network(Description: Option[dmtf.Msg_Type],

so it's actually a xs:element in dsp8023_1.1.0.xsd:

<xs:complexType name="NetworkSection_Type">
    <xs:annotation>
        <xs:documentation>Descriptions of logical networks used within the
        package</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
        <xs:extension base="ovf:Section_Type">
            <xs:sequence>
                <xs:element name="Network" minOccurs="0" maxOccurs="unbounded">

package names for dmtf stuff

the following creates dmtf-defined types into dmtf package, which makes it more organized:

$ mkdir dmtf
$ cd dmtf
$ wget http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://schemas.dmtf.org/wbem/wscim/1/common.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd
$ mv common.xsd dmtf_common.xsd
$ cd ..
$ scalaxb `find . -name '*.xsd'` --wrap-contents "{http://www.vmware.com/vcloud/v1}EntityType" --wrap-contents "{http://www.vmware.com/vcloud/v1}UserType" -p vcloud -p:http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData=dmtf -p:http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData=dmtf -p:http://schemas.dmtf.org/wbem/wscim/1/common=dmtf -p:http://schemas.dmtf.org/ovf/envelope/1=dmtf -d out --package-dir

sample usage

in out directory, place the following sample file:

object Main extends Application {
  import vcloud._

  println(scalaxb.toXML[NetworkType](OrgNetworkType(Nil, Nil, 
    EntityTypableSequence1(None, None), None, None, None, None, None, "foo", Map()),
    "networkType", vcloud.defaultScope))
  println(scalaxb.toXML(dmtf.Network(None, "foo", Map()), "network", vcloud.defaultScope))
}

you can compile it with the rest of the scala files and run it.

$ cd out
$ scalac `find . -name "*.scala"`
$ scala Main

it should produce the following:

<networkType xsi:type="OrgNetworkType" name="foo" xmlns="http://www.vmware.com/vcloud/versions" xmlns:vmw="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"></networkType>
<network ovf:name="foo" xmlns="http://www.vmware.com/vcloud/versions" xmlns:vmw="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"></network>

XMLFormat type classes

one thing to note is that scalaxb generates XMLFormat type classes as the package object of the default package, in this case vcloud, so import vcloud._ is necessary even when you're using dmtf.Network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant