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

XSD with xs:redefine #11

Open
stckcrsh opened this issue Oct 11, 2016 · 2 comments
Open

XSD with xs:redefine #11

stckcrsh opened this issue Oct 11, 2016 · 2 comments

Comments

@stckcrsh
Copy link

Sorry i dont know if this is an issue or I am doing this completely wrong

I have two xsd files that i am trying to parse
The first has some complex types basic stuff, but the second one has xs:redefine to alter the complex types from the first xsd

example
base.xsd

<xs:complexType name="transaction">
    <xs:sequence>
        <xs:element name="id" type="xs:string" minOccurs="0"/>
        <xs:element name="timestamp" type="xs:dateTime" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>

extend.xsd

<xs:redefine schemaLocation="base.xsd">
  <xs:complexType name="transaction">
    <xs:complexContent>
        <xs:extension base="transaction">
            <xs:sequence>
                <xs:element name="partial" type="xs:string" minOccurs="0" />
                <xs:element name="originSrc" type="xs:string" minOccurs="0" />
                <xs:element name="originalPrd" type="xs:string" minOccurs="0" />
                <xs:element name="crn" type="xs:string" minOccurs="0" />
            </xs:sequence>
        </xs:extension>
    </xs:complexContent>
  </xs:complexType> 
</xs:redefine

This is the resulting Typescript i get

interface _transaction extends BaseType {
    id?: string;
    timestamp?: Date;
}
export interface transaction extends _transaction { constructor: { new(): transaction }; }
export var transaction: { new(): transaction };

As I said earlier this might not be an issue, but a problem with how things are done on my side. As some backstory we are upgrading the frontend on an old service that my company has to angular2. They do not want to update any of the server stuff (all the xsds) and i have to generate visualizations off this data that is returned and i do not wish to go through all the xsd files they have and manually try to get this data in.

@jjrv
Copy link
Member

jjrv commented Apr 1, 2017

There's no support yet for redefine or override. Handling them seems complicated if parsing some XML files that (using xsi) refer to the redefined schema and some only refer to the original. That would allow completely different definitions for the namespace, and TypeScript module augmentations don't seem to support that. Parsing XML would still work, but types couldn't be represented properly in a TypeScript IDE. It could be made to work if both .xsd files are always used together.

@stckcrsh
Copy link
Author

stckcrsh commented Apr 1, 2017

In my instance both are always used together.

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

No branches or pull requests

2 participants