Skip to content

Compilation error for type references inside a complex type #28

@andreivasiliu

Description

@andreivasiliu

The following schema fails to compile:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://www.example.com/books"
           targetNamespace="http://www.example.com/books">

    <xs:complexType name="BookDetails">
        <xs:sequence>
            <xs:element name="Title" type="xs:string"/>
            <xs:element name="Author" type="xs:string"/>
            <xs:element name="Year" type="xs:int"/>
        </xs:sequence>
    </xs:complexType>

    <!-- Works! -->
    <xs:element name="Book1" type="tns:BookDetails"/>

    <!-- Crashes with:
      cannot find type `BookDetails` in this scope
      help: consider importing this struct: crate::types::BookDetails -->
    <xs:element name="Book2">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="details" type="tns:BookDetails"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

The error is:

error[E0412]: cannot find type `BookDetails` in this scope
 --> src/main.rs:3:17
  |
3 | #[derive(Debug, XmlSchema)]
  |                 ^^^^^^^^^ not found in this scope
  |
  = help: consider importing this struct:
          crate::types::BookDetails

Most likely the code generator for complex types is creating a new scope/module but it doesn't use super::* or something similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions