-
-
Save andreivasiliu/cde0a669d75bb2d80ae1f6acd92d5263 to your computer and use it in GitHub Desktop.
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
use xml_schema_derive::XmlSchema; | |
#[derive(Debug, XmlSchema)] | |
#[xml_schema(source = "test.xsd", target_prefix = "my_prefix")] | |
struct MySchema; | |
fn main() { | |
println!("Hello, world!"); | |
} |
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
[package] | |
name = "zxsd" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
xml-schema-derive = { git = "https://github.com/media-io/xml-schema" } | |
yaserde = { git = "https://github.com/media-io/yaserde" } | |
yaserde_derive = { git = "https://github.com/media-io/yaserde" } |
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"?> | |
<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="More" type="tns:MoreDetails"/> | |
</xs:sequence> | |
</xs:complexType> | |
<xs:complexType name="MoreDetails"> | |
<xs:sequence> | |
<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 --> | |
<!-- New! with the new code, it now says: | |
use of undeclared crate or module `xml_schema_types` | |
consider importing this module through its public re-export: crate::xml_schema_types --> | |
<xs:element name="Book2"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element name="details" type="tns:BookDetails"/> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
</xs:schema> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment