polyxml 0.34.5__tar.gz → 0.34.6__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.
Files changed (84) hide show
  1. {polyxml-0.34.5 → polyxml-0.34.6}/Cargo.lock +6 -6
  2. {polyxml-0.34.5 → polyxml-0.34.6}/Cargo.toml +1 -1
  3. {polyxml-0.34.5 → polyxml-0.34.6}/PKG-INFO +1 -1
  4. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/rust/mod.rs +27 -4
  5. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_rust_codegen.rs +44 -0
  6. {polyxml-0.34.5 → polyxml-0.34.6}/pyproject.toml +1 -1
  7. {polyxml-0.34.5 → polyxml-0.34.6}/README.md +0 -0
  8. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/Cargo.toml +0 -0
  9. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/README.md +0 -0
  10. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
  11. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/support/tag_dispatch_fixtures.rs +0 -0
  12. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/tag_dispatch.rs +0 -0
  13. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/cpp/mod.rs +0 -0
  14. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/csharp/mod.rs +0 -0
  15. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/go/mod.rs +0 -0
  16. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/java/codec.rs +0 -0
  17. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/java/mod.rs +0 -0
  18. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/java/models.rs +0 -0
  19. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/mod.rs +0 -0
  20. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/python/aot.rs +0 -0
  21. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/python/mod.rs +0 -0
  22. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/typescript/mod.rs +0 -0
  23. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/converters.rs +0 -0
  24. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/error.rs +0 -0
  25. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/integer.rs +0 -0
  26. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/chunker.rs +0 -0
  27. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/mod.rs +0 -0
  28. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/particle.rs +0 -0
  29. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/tarjan.rs +0 -0
  30. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/json.rs +0 -0
  31. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/lib.rs +0 -0
  32. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/parser.rs +0 -0
  33. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/schema.rs +0 -0
  34. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/schema_parser/mod.rs +0 -0
  35. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/schema_parser/upa.rs +0 -0
  36. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/serializer.rs +0 -0
  37. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/transcoder.rs +0 -0
  38. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/value.rs +0 -0
  39. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/fixtures/lexical_union.xsd +0 -0
  40. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/fixtures/mixed_content.xsd +0 -0
  41. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/fixtures/ts_mixed_content_inheritance.xsd +0 -0
  42. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_adversarial_identifiers.rs +0 -0
  43. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_any_attribute.rs +0 -0
  44. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_any_element.rs +0 -0
  45. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_conformance.rs +0 -0
  46. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_core.rs +0 -0
  47. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_cpp_codegen.rs +0 -0
  48. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_csharp_codegen.rs +0 -0
  49. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_go_codegen.rs +0 -0
  50. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_java_codegen.rs +0 -0
  51. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_json.rs +0 -0
  52. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_lexical_lists.rs +0 -0
  53. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_lexical_union_codegen.rs +0 -0
  54. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_mixed_content.rs +0 -0
  55. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_pattern_codegen.rs +0 -0
  56. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_python_codegen.rs +0 -0
  57. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_qualified_attributes.rs +0 -0
  58. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_rust_codecs.rs +0 -0
  59. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_schema_audit.rs +0 -0
  60. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_schema_ir.rs +0 -0
  61. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_security.rs +0 -0
  62. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_temporal_union.rs +0 -0
  63. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_transcoder.rs +0 -0
  64. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_ts_codegen.rs +0 -0
  65. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_ubl_csharp.rs +0 -0
  66. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_unbounded_choice.rs +0 -0
  67. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_upa.rs +0 -0
  68. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_value_constraints.rs +0 -0
  69. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_xsi_type.rs +0 -0
  70. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/Cargo.toml +0 -0
  71. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/README.md +0 -0
  72. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/benches/aot_vs_dataclass.py +0 -0
  73. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/src/lib.rs +0 -0
  74. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_conformance.py +0 -0
  75. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_generated_models.py +0 -0
  76. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_json.py +0 -0
  77. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_mixed_content.py +0 -0
  78. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_polyxml.py +0 -0
  79. {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_xsi_type.py +0 -0
  80. {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/AGENT_GUIDE.md +0 -0
  81. {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/__init__.py +0 -0
  82. {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/compat/__init__.py +0 -0
  83. {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/compat/xsdata.py +0 -0
  84. {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/py.typed +0 -0
@@ -608,7 +608,7 @@ dependencies = [
608
608
 
609
609
  [[package]]
610
610
  name = "polyxml"
611
- version = "0.34.5"
611
+ version = "0.34.6"
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.34.5"
632
+ version = "0.34.6"
633
633
  dependencies = [
634
634
  "polyxml",
635
635
  ]
636
636
 
637
637
  [[package]]
638
638
  name = "polyxml-cli"
639
- version = "0.34.5"
639
+ version = "0.34.6"
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.34.5"
653
+ version = "0.34.6"
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.34.5"
663
+ version = "0.34.6"
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.34.5"
673
+ version = "0.34.6"
674
674
  dependencies = [
675
675
  "polyxml",
676
676
  "quick-xml",
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["crates/polyxml-core", "crates/polyxml-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.34.5"
6
+ version = "0.34.6"
7
7
  edition = "2021"
8
8
  rust-version = "1.80"
9
9
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyxml
3
- Version: 0.34.5
3
+ Version: 0.34.6
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -928,9 +928,31 @@ impl RustCodegen {
928
928
  let _ = writeln!(out, "{} {{", struct_decl);
929
929
 
930
930
  let mut seen_fields = HashSet::new();
931
- for field in flatten_fields(s, ir) {
931
+ let mut seen_json_names = HashSet::new();
932
+ let fields = flatten_fields(s, ir);
933
+ let wire_names: HashSet<_> = fields.iter().map(|field| field.xml_name.as_str()).collect();
934
+ for field in fields {
932
935
  let rust_name = self.unique_rust_field_name(&field.name, &mut seen_fields);
933
- self.emit_struct_field(out, field, &rust_name, types_with_lifetime, has_boxed);
936
+ let mut json_name = field.xml_name.clone();
937
+ if !seen_json_names.insert(json_name.clone()) {
938
+ let base = rust_name.strip_prefix("r#").unwrap_or(&rust_name);
939
+ json_name = base.to_string();
940
+ let mut suffix = 2;
941
+ while wire_names.contains(json_name.as_str())
942
+ || !seen_json_names.insert(json_name.clone())
943
+ {
944
+ json_name = format!("{base}_{suffix}");
945
+ suffix += 1;
946
+ }
947
+ }
948
+ self.emit_struct_field(
949
+ out,
950
+ field,
951
+ &rust_name,
952
+ &json_name,
953
+ types_with_lifetime,
954
+ has_boxed,
955
+ );
934
956
  }
935
957
 
936
958
  out.push_str("}\n");
@@ -960,6 +982,7 @@ impl RustCodegen {
960
982
  out: &mut String,
961
983
  field: &FieldDef,
962
984
  rust_name: &str,
985
+ json_name: &str,
963
986
  types_with_lifetime: &HashSet<QName>,
964
987
  has_boxed: bool,
965
988
  ) {
@@ -984,8 +1007,8 @@ impl RustCodegen {
984
1007
  // Serde attribute
985
1008
  if self.options.derive_serde {
986
1009
  let mut serde_parts = Vec::new();
987
- if field.xml_name != rust_name.strip_prefix("r#").unwrap_or(rust_name) {
988
- serde_parts.push(format!("rename = \"{}\"", field.xml_name));
1010
+ if json_name != rust_name.strip_prefix("r#").unwrap_or(rust_name) {
1011
+ serde_parts.push(format!("rename = \"{}\"", json_name));
989
1012
  }
990
1013
  if is_optional {
991
1014
  serde_parts.push("default".to_string());
@@ -1461,3 +1461,47 @@ fn empty_modules_compile_without_unused_reexports() {
1461
1461
  );
1462
1462
  }
1463
1463
  }
1464
+
1465
+ #[test]
1466
+ fn duplicate_wire_names_keep_distinct_json_values() {
1467
+ let schema = r#"<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType name="Payload"><xs:sequence><xs:any namespace="urn:first" minOccurs="0" maxOccurs="unbounded"/><xs:any namespace="urn:second" minOccurs="0" maxOccurs="unbounded"/><xs:element name="any_2" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:schema>"#;
1468
+ let ir = XsdParser::new().parse_str(schema).unwrap();
1469
+ let core = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
1470
+ for zero_copy in [true, false] {
1471
+ let dir = tempfile::tempdir().unwrap();
1472
+ std::fs::create_dir(dir.path().join("src")).unwrap();
1473
+ std::fs::write(
1474
+ dir.path().join("src/models.rs"),
1475
+ RustCodegen::new(RustOptions {
1476
+ zero_copy,
1477
+ emit_codecs: false,
1478
+ ..Default::default()
1479
+ })
1480
+ .generate_module(&ir),
1481
+ )
1482
+ .unwrap();
1483
+ std::fs::write(dir.path().join("Cargo.toml"),format!("[package]\nname=\"duplicate-json-test\"\nversion=\"0.0.0\"\nedition=\"2021\"\n[dependencies]\npolyxml={{path={core:?}}}\nserde={{version=\"1\",features=[\"derive\"]}}\nserde_json=\"1\"\n")).unwrap();
1484
+ std::fs::write(dir.path().join("src/main.rs"),r#"mod models;use models::*;
1485
+ fn main(){
1486
+ let mut value=Payload::default();value.any.push("first".into());value.any_2.push("second".into());value.any_2_2=Some("named".into());
1487
+ let json=serde_json::to_string(&value).unwrap();let parsed:Payload=serde_json::from_str(&json).unwrap();
1488
+ assert_eq!(parsed,value);let object:serde_json::Value=serde_json::from_str(&json).unwrap();assert_eq!(object.as_object().unwrap().len(),3);
1489
+ }
1490
+ "#).unwrap();
1491
+ let output = std::process::Command::new("cargo")
1492
+ .args(["run", "--quiet", "--offline"])
1493
+ .env("RUSTFLAGS", "-D unreachable-patterns")
1494
+ .env(
1495
+ "CARGO_TARGET_DIR",
1496
+ core.join("../../target/binary-lexical-tests"),
1497
+ )
1498
+ .current_dir(dir.path())
1499
+ .output()
1500
+ .unwrap();
1501
+ assert!(
1502
+ output.status.success(),
1503
+ "borrowed={zero_copy}: {}",
1504
+ String::from_utf8_lossy(&output.stderr)
1505
+ );
1506
+ }
1507
+ }
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "polyxml"
7
- version = "0.34.5"
7
+ version = "0.34.6"
8
8
  description = "High-performance, polyglot XML data-binding engine built in Rust"
9
9
  authors = [
10
10
  { name = "Bailey Nguyen", email = "bailey.tan.nguyen@gmail.com" }
File without changes