polyxml 0.33.4__tar.gz → 0.33.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {polyxml-0.33.4 → polyxml-0.33.5}/Cargo.lock +6 -6
- {polyxml-0.33.4 → polyxml-0.33.5}/Cargo.toml +1 -1
- {polyxml-0.33.4 → polyxml-0.33.5}/PKG-INFO +1 -1
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/go/mod.rs +8 -5
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/schema_parser/mod.rs +76 -8
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_csharp_codegen.rs +26 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_python_codegen.rs +24 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_schema_ir.rs +49 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/pyproject.toml +1 -1
- {polyxml-0.33.4 → polyxml-0.33.5}/README.md +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/Cargo.toml +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/README.md +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/benches/support/tag_dispatch_fixtures.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/benches/tag_dispatch.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/cpp/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/csharp/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/java/codec.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/java/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/java/models.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/python/aot.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/python/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/rust/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/codegen/typescript/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/converters.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/error.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/ir/chunker.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/ir/mod.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/ir/tarjan.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/json.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/lib.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/parser.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/schema.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/serializer.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/transcoder.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/src/value.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/fixtures/lexical_union.xsd +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/fixtures/mixed_content.xsd +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/fixtures/ts_mixed_content_inheritance.xsd +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_adversarial_identifiers.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_any_attribute.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_any_element.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_conformance.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_core.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_cpp_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_go_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_java_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_json.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_lexical_union_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_mixed_content.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_pattern_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_rust_codecs.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_rust_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_schema_audit.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_security.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_transcoder.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_ts_codegen.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_unbounded_choice.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/tests/test_xsi_type.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/Cargo.toml +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/README.md +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/benches/aot_vs_dataclass.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/src/lib.rs +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/tests/test_conformance.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/tests/test_generated_models.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/tests/test_json.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/tests/test_mixed_content.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/tests/test_polyxml.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-python/tests/test_xsi_type.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/python/polyxml/AGENT_GUIDE.md +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/python/polyxml/__init__.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/python/polyxml/compat/__init__.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/python/polyxml/compat/xsdata.py +0 -0
- {polyxml-0.33.4 → polyxml-0.33.5}/python/polyxml/py.typed +0 -0
|
@@ -608,7 +608,7 @@ dependencies = [
|
|
|
608
608
|
|
|
609
609
|
[[package]]
|
|
610
610
|
name = "polyxml"
|
|
611
|
-
version = "0.33.
|
|
611
|
+
version = "0.33.5"
|
|
612
612
|
dependencies = [
|
|
613
613
|
"criterion",
|
|
614
614
|
"heck",
|
|
@@ -629,14 +629,14 @@ dependencies = [
|
|
|
629
629
|
|
|
630
630
|
[[package]]
|
|
631
631
|
name = "polyxml-c"
|
|
632
|
-
version = "0.33.
|
|
632
|
+
version = "0.33.5"
|
|
633
633
|
dependencies = [
|
|
634
634
|
"polyxml",
|
|
635
635
|
]
|
|
636
636
|
|
|
637
637
|
[[package]]
|
|
638
638
|
name = "polyxml-cli"
|
|
639
|
-
version = "0.33.
|
|
639
|
+
version = "0.33.5"
|
|
640
640
|
dependencies = [
|
|
641
641
|
"clap",
|
|
642
642
|
"glob",
|
|
@@ -650,7 +650,7 @@ dependencies = [
|
|
|
650
650
|
|
|
651
651
|
[[package]]
|
|
652
652
|
name = "polyxml-js"
|
|
653
|
-
version = "0.33.
|
|
653
|
+
version = "0.33.5"
|
|
654
654
|
dependencies = [
|
|
655
655
|
"napi",
|
|
656
656
|
"napi-build",
|
|
@@ -660,7 +660,7 @@ dependencies = [
|
|
|
660
660
|
|
|
661
661
|
[[package]]
|
|
662
662
|
name = "polyxml-python"
|
|
663
|
-
version = "0.33.
|
|
663
|
+
version = "0.33.5"
|
|
664
664
|
dependencies = [
|
|
665
665
|
"lexical-core",
|
|
666
666
|
"polyxml",
|
|
@@ -670,7 +670,7 @@ dependencies = [
|
|
|
670
670
|
|
|
671
671
|
[[package]]
|
|
672
672
|
name = "polyxml-wasm"
|
|
673
|
-
version = "0.33.
|
|
673
|
+
version = "0.33.5"
|
|
674
674
|
dependencies = [
|
|
675
675
|
"polyxml",
|
|
676
676
|
"quick-xml",
|
|
@@ -1162,7 +1162,9 @@ impl GoCodegen {
|
|
|
1162
1162
|
let xml_val = match f.kind {
|
|
1163
1163
|
FieldKind::Attribute => {
|
|
1164
1164
|
let attr_name = match &f.namespace {
|
|
1165
|
-
Some(ns) if !ns.is_empty()
|
|
1165
|
+
Some(ns) if !ns.is_empty() && is_namespaced_ref(f, s, ir) => {
|
|
1166
|
+
format!("{} {}", ns, f.xml_name)
|
|
1167
|
+
}
|
|
1166
1168
|
_ => f.xml_name.clone(),
|
|
1167
1169
|
};
|
|
1168
1170
|
if is_opt {
|
|
@@ -1175,10 +1177,11 @@ impl GoCodegen {
|
|
|
1175
1177
|
FieldKind::Any => ",any".to_string(),
|
|
1176
1178
|
FieldKind::AnyAttribute => ",any,attr".to_string(),
|
|
1177
1179
|
FieldKind::Element => {
|
|
1178
|
-
let elem_name =
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1180
|
+
let elem_name = match &f.namespace {
|
|
1181
|
+
Some(ns) if !ns.is_empty() && is_namespaced_ref(f, s, ir) => {
|
|
1182
|
+
format!("{} {}", ns, f.xml_name)
|
|
1183
|
+
}
|
|
1184
|
+
_ => f.xml_name.clone(),
|
|
1182
1185
|
};
|
|
1183
1186
|
if f.xml_name.is_empty() {
|
|
1184
1187
|
",any".to_string()
|
|
@@ -501,6 +501,8 @@ impl XsdParser {
|
|
|
501
501
|
|
|
502
502
|
let mut is_top_level_choice = false;
|
|
503
503
|
let mut top_level_choice_branches: Vec<UnionBranch> = Vec::new();
|
|
504
|
+
let mut top_level_choice_fields_start = 0;
|
|
505
|
+
let mut top_level_choice_fields_count = 0;
|
|
504
506
|
let mut compositor_stack: Vec<CompositorFrame> = Vec::new();
|
|
505
507
|
let mut depth = 1;
|
|
506
508
|
while depth > 0 {
|
|
@@ -599,9 +601,16 @@ impl XsdParser {
|
|
|
599
601
|
.last()
|
|
600
602
|
.map(|c| c.kind == CompositorKind::Choice)
|
|
601
603
|
.unwrap_or(false);
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
604
|
+
let in_any_choice = compositor_stack
|
|
605
|
+
.iter()
|
|
606
|
+
.any(|c| c.kind == CompositorKind::Choice);
|
|
607
|
+
if let Some(mut field) = parse_element_field(
|
|
608
|
+
e,
|
|
609
|
+
target_ns,
|
|
610
|
+
prefixes,
|
|
611
|
+
in_any_choice,
|
|
612
|
+
in_unbounded,
|
|
613
|
+
) {
|
|
605
614
|
// Consume inline type definitions so nested
|
|
606
615
|
// fields cannot leak into the parent struct;
|
|
607
616
|
// extracted types are registered in `ir`.
|
|
@@ -690,9 +699,16 @@ impl XsdParser {
|
|
|
690
699
|
.last()
|
|
691
700
|
.map(|c| c.kind == CompositorKind::Choice)
|
|
692
701
|
.unwrap_or(false);
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
702
|
+
let in_any_choice = compositor_stack
|
|
703
|
+
.iter()
|
|
704
|
+
.any(|c| c.kind == CompositorKind::Choice);
|
|
705
|
+
if let Some(field) = parse_element_field(
|
|
706
|
+
e,
|
|
707
|
+
target_ns,
|
|
708
|
+
prefixes,
|
|
709
|
+
in_any_choice,
|
|
710
|
+
in_unbounded,
|
|
711
|
+
) {
|
|
696
712
|
if in_choice {
|
|
697
713
|
if let Some(frame) = compositor_stack.last_mut() {
|
|
698
714
|
if frame.kind == CompositorKind::Choice {
|
|
@@ -748,10 +764,58 @@ impl XsdParser {
|
|
|
748
764
|
let local = strip_prefix(e.name().into_inner());
|
|
749
765
|
if local == "sequence" || local == "choice" || local == "all" {
|
|
750
766
|
if let Some(frame) = compositor_stack.pop() {
|
|
751
|
-
if frame.kind == CompositorKind::
|
|
767
|
+
if frame.kind == CompositorKind::Sequence {
|
|
768
|
+
if let Some(parent) = compositor_stack.last_mut() {
|
|
769
|
+
if parent.kind == CompositorKind::Choice {
|
|
770
|
+
let seq_fields = fields[frame.fields_start..].to_vec();
|
|
771
|
+
if !seq_fields.is_empty() {
|
|
772
|
+
let seq_name = unique_type_name(
|
|
773
|
+
ir,
|
|
774
|
+
target_ns,
|
|
775
|
+
&format!("{}Sequence", name),
|
|
776
|
+
);
|
|
777
|
+
let seq_qname = QName::new(target_ns, seq_name);
|
|
778
|
+
ir.add_type(TypeDef::Struct(StructDef {
|
|
779
|
+
qname: seq_qname.clone(),
|
|
780
|
+
base_type: None,
|
|
781
|
+
is_abstract: false,
|
|
782
|
+
is_mixed: false,
|
|
783
|
+
fields: seq_fields,
|
|
784
|
+
documentation: None,
|
|
785
|
+
}));
|
|
786
|
+
let branch_variant = if let Some(first_field) =
|
|
787
|
+
fields.get(frame.fields_start)
|
|
788
|
+
{
|
|
789
|
+
format!(
|
|
790
|
+
"{}Sequence",
|
|
791
|
+
sanitize_field_name(&first_field.name)
|
|
792
|
+
)
|
|
793
|
+
} else {
|
|
794
|
+
"Sequence".to_string()
|
|
795
|
+
};
|
|
796
|
+
let branch_xml = if let Some(first_field) =
|
|
797
|
+
fields.get(frame.fields_start)
|
|
798
|
+
{
|
|
799
|
+
first_field.xml_name.clone()
|
|
800
|
+
} else {
|
|
801
|
+
String::new()
|
|
802
|
+
};
|
|
803
|
+
parent.choice_branches.push(UnionBranch {
|
|
804
|
+
variant_name: branch_variant,
|
|
805
|
+
xml_name: branch_xml,
|
|
806
|
+
namespace: target_ns.map(Into::into),
|
|
807
|
+
type_ref: TypeRef::Named(seq_qname),
|
|
808
|
+
documentation: None,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
} else if frame.kind == CompositorKind::Choice {
|
|
752
814
|
let choice_is_unbounded = frame.is_unbounded
|
|
753
815
|
|| compositor_stack.iter().any(|c| c.is_unbounded);
|
|
816
|
+
let is_nested_choice = !compositor_stack.is_empty();
|
|
754
817
|
if (choice_is_unbounded
|
|
818
|
+
|| is_nested_choice
|
|
755
819
|
|| (compositor_stack.is_empty() && base_type.is_some()))
|
|
756
820
|
&& !frame.choice_branches.is_empty()
|
|
757
821
|
{
|
|
@@ -799,6 +863,9 @@ impl XsdParser {
|
|
|
799
863
|
});
|
|
800
864
|
} else if !choice_is_unbounded && compositor_stack.is_empty() {
|
|
801
865
|
top_level_choice_branches = frame.choice_branches;
|
|
866
|
+
top_level_choice_fields_start = frame.fields_start;
|
|
867
|
+
top_level_choice_fields_count =
|
|
868
|
+
fields.len() - frame.fields_start;
|
|
802
869
|
is_top_level_choice = true;
|
|
803
870
|
}
|
|
804
871
|
}
|
|
@@ -818,7 +885,8 @@ impl XsdParser {
|
|
|
818
885
|
&& is_top_level_choice
|
|
819
886
|
&& !top_level_choice_branches.is_empty()
|
|
820
887
|
&& group_refs.is_empty()
|
|
821
|
-
&&
|
|
888
|
+
&& top_level_choice_fields_start == 0
|
|
889
|
+
&& fields.len() == top_level_choice_fields_count;
|
|
822
890
|
|
|
823
891
|
// Record group refs for post-parse expansion.
|
|
824
892
|
if !is_union {
|
|
@@ -1083,3 +1083,29 @@ fn test_csharp_any_attribute_codegen() {
|
|
|
1083
1083
|
assert!(class_code
|
|
1084
1084
|
.contains("public System.Xml.XmlAttribute[]? AnyAttribute { get; set; } = default!;"));
|
|
1085
1085
|
}
|
|
1086
|
+
|
|
1087
|
+
#[test]
|
|
1088
|
+
fn test_csharp_sequence_nested_inside_choice_codegen() {
|
|
1089
|
+
use polyxml::schema_parser::XsdParser;
|
|
1090
|
+
|
|
1091
|
+
let xsd = r#"<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
1092
|
+
<xs:element name="Root"><xs:complexType><xs:choice>
|
|
1093
|
+
<xs:sequence>
|
|
1094
|
+
<xs:element name="First" type="xs:string"/>
|
|
1095
|
+
<xs:element name="Second" type="xs:string"/>
|
|
1096
|
+
</xs:sequence>
|
|
1097
|
+
<xs:element name="Alternative" type="xs:string"/>
|
|
1098
|
+
</xs:choice></xs:complexType></xs:element>
|
|
1099
|
+
</xs:schema>"#;
|
|
1100
|
+
|
|
1101
|
+
let ir = XsdParser::new()
|
|
1102
|
+
.parse_str(xsd)
|
|
1103
|
+
.expect("schema parse failed");
|
|
1104
|
+
let codegen = CSharpCodegen::new(CSharpOptions::default());
|
|
1105
|
+
let code = codegen.generate_module(&ir);
|
|
1106
|
+
|
|
1107
|
+
assert!(code.contains("public abstract record RootType"));
|
|
1108
|
+
assert!(code.contains("public sealed record FirstSequence([property: XmlElement(\"First\"), JsonPropertyName(\"First\")] RootTypeSequence Value) : RootType"));
|
|
1109
|
+
assert!(code.contains("public sealed record Alternative([property: XmlElement(\"Alternative\"), JsonPropertyName(\"Alternative\")] string Value) : RootType"));
|
|
1110
|
+
assert!(code.contains("public record RootTypeSequence"));
|
|
1111
|
+
}
|
|
@@ -768,3 +768,27 @@ fn test_python_any_element_codegen() {
|
|
|
768
768
|
"Generated Python model must define xs:any field as optional object"
|
|
769
769
|
);
|
|
770
770
|
}
|
|
771
|
+
|
|
772
|
+
#[test]
|
|
773
|
+
fn test_python_sequence_nested_inside_choice_codegen() {
|
|
774
|
+
let xsd = r#"<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
775
|
+
<xs:element name="Root"><xs:complexType><xs:choice>
|
|
776
|
+
<xs:sequence>
|
|
777
|
+
<xs:element name="First" type="xs:string"/>
|
|
778
|
+
<xs:element name="Second" type="xs:string"/>
|
|
779
|
+
</xs:sequence>
|
|
780
|
+
<xs:element name="Alternative" type="xs:string"/>
|
|
781
|
+
</xs:choice></xs:complexType></xs:element>
|
|
782
|
+
</xs:schema>"#;
|
|
783
|
+
|
|
784
|
+
let ir = XsdParser::new()
|
|
785
|
+
.parse_str(xsd)
|
|
786
|
+
.expect("schema parse failed");
|
|
787
|
+
let codegen = PythonCodegen::new(PythonOptions::default());
|
|
788
|
+
let code = codegen.generate_module(&ir);
|
|
789
|
+
|
|
790
|
+
assert!(code.contains("type RootType = RootTypeSequence | str"));
|
|
791
|
+
assert!(code.contains("class RootTypeSequence:"));
|
|
792
|
+
assert!(code.contains("first: str | None = field("));
|
|
793
|
+
assert!(code.contains("second: str | None = field("));
|
|
794
|
+
}
|
|
@@ -602,3 +602,52 @@ fn test_language_context_adapter() {
|
|
|
602
602
|
let list_ref = TypeRef::List(Box::new(TypeRef::Primitive(PrimitiveType::Int)));
|
|
603
603
|
assert_eq!(ctx.map_type_ref(&list_ref), "Vec<i32>");
|
|
604
604
|
}
|
|
605
|
+
|
|
606
|
+
#[test]
|
|
607
|
+
fn test_sequence_nested_inside_choice_preserved_in_ir() {
|
|
608
|
+
let xsd = r#"<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
609
|
+
<xs:element name="Root"><xs:complexType><xs:choice>
|
|
610
|
+
<xs:sequence>
|
|
611
|
+
<xs:element name="First" type="xs:string"/>
|
|
612
|
+
<xs:element name="Second" type="xs:string"/>
|
|
613
|
+
</xs:sequence>
|
|
614
|
+
<xs:element name="Alternative" type="xs:string"/>
|
|
615
|
+
</xs:choice></xs:complexType></xs:element>
|
|
616
|
+
</xs:schema>"#;
|
|
617
|
+
|
|
618
|
+
let ir = XsdParser::new().parse_str(xsd).unwrap();
|
|
619
|
+
let root_type_qname = QName::local("RootType");
|
|
620
|
+
let TypeDef::Union(root_choice) = ir
|
|
621
|
+
.types
|
|
622
|
+
.get(&root_type_qname)
|
|
623
|
+
.expect("RootType must be UnionDef")
|
|
624
|
+
else {
|
|
625
|
+
panic!("RootType must be a UnionDef");
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
assert_eq!(root_choice.branches.len(), 2);
|
|
629
|
+
// Sequence branch
|
|
630
|
+
let seq_branch = &root_choice.branches[0];
|
|
631
|
+
assert!(seq_branch.variant_name.contains("Sequence"));
|
|
632
|
+
let TypeRef::Named(seq_qname) = &seq_branch.type_ref else {
|
|
633
|
+
panic!("Sequence branch must reference a synthetic struct type");
|
|
634
|
+
};
|
|
635
|
+
let TypeDef::Struct(seq_struct) = ir
|
|
636
|
+
.types
|
|
637
|
+
.get(seq_qname)
|
|
638
|
+
.expect("Synthetic sequence struct must exist")
|
|
639
|
+
else {
|
|
640
|
+
panic!("Sequence branch must be a StructDef");
|
|
641
|
+
};
|
|
642
|
+
assert_eq!(seq_struct.fields.len(), 2);
|
|
643
|
+
assert_eq!(seq_struct.fields[0].xml_name, "First");
|
|
644
|
+
assert_eq!(seq_struct.fields[1].xml_name, "Second");
|
|
645
|
+
|
|
646
|
+
// Alternative branch
|
|
647
|
+
let alt_branch = &root_choice.branches[1];
|
|
648
|
+
assert_eq!(alt_branch.xml_name, "Alternative");
|
|
649
|
+
assert_eq!(
|
|
650
|
+
alt_branch.type_ref,
|
|
651
|
+
TypeRef::Primitive(PrimitiveType::String)
|
|
652
|
+
);
|
|
653
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{polyxml-0.33.4 → polyxml-0.33.5}/crates/polyxml-core/benches/support/tag_dispatch_fixtures.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|