polyxml 0.35.6__tar.gz → 0.36.0__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 (97) hide show
  1. {polyxml-0.35.6 → polyxml-0.36.0}/Cargo.lock +6 -6
  2. {polyxml-0.35.6 → polyxml-0.36.0}/Cargo.toml +1 -1
  3. {polyxml-0.35.6 → polyxml-0.36.0}/PKG-INFO +1 -1
  4. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/go/mod.rs +76 -16
  5. {polyxml-0.35.6 → polyxml-0.36.0}/pyproject.toml +1 -1
  6. {polyxml-0.35.6 → polyxml-0.36.0}/README.md +0 -0
  7. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/Cargo.toml +0 -0
  8. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/README.md +0 -0
  9. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
  10. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/benches/support/tag_dispatch_fixtures.rs +0 -0
  11. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/benches/tag_dispatch.rs +0 -0
  12. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/cpp/mod.rs +0 -0
  13. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/csharp/mod.rs +0 -0
  14. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/java/codec.rs +0 -0
  15. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/java/mod.rs +0 -0
  16. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/java/models.rs +0 -0
  17. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/mod.rs +0 -0
  18. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/python/aot.rs +0 -0
  19. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/python/mod.rs +0 -0
  20. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/rust/mod.rs +0 -0
  21. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/codegen/typescript/mod.rs +0 -0
  22. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/converters.rs +0 -0
  23. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/error.rs +0 -0
  24. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/integer.rs +0 -0
  25. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/ir/chunker.rs +0 -0
  26. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/ir/mod.rs +0 -0
  27. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/ir/particle.rs +0 -0
  28. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/ir/tarjan.rs +0 -0
  29. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/json.rs +0 -0
  30. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/lib.rs +0 -0
  31. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/parser.rs +0 -0
  32. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/pattern.rs +0 -0
  33. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/schema.rs +0 -0
  34. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/schema_parser/mod.rs +0 -0
  35. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/schema_parser/upa.rs +0 -0
  36. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/serializer.rs +0 -0
  37. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/transcoder.rs +0 -0
  38. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/src/value.rs +0 -0
  39. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/fixtures/lexical_union.xsd +0 -0
  40. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/fixtures/mixed_content.xsd +0 -0
  41. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/fixtures/ts_mixed_content_inheritance.xsd +0 -0
  42. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_adversarial_identifiers.rs +0 -0
  43. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_any_attribute.rs +0 -0
  44. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_any_element.rs +0 -0
  45. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_conformance.rs +0 -0
  46. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_core.rs +0 -0
  47. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_corpus_regressions.rs +0 -0
  48. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_cpp_codegen.rs +0 -0
  49. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_csharp_codegen.rs +0 -0
  50. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_default_literal_codegen.rs +0 -0
  51. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_enum_literal_codegen.rs +0 -0
  52. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_go_codegen.rs +0 -0
  53. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_inherited_simple_content.rs +0 -0
  54. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_inherited_text_codegen.rs +0 -0
  55. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_java_codegen.rs +0 -0
  56. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_json.rs +0 -0
  57. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_lexical_lists.rs +0 -0
  58. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_lexical_union_codegen.rs +0 -0
  59. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_mixed_branch_lookup.rs +0 -0
  60. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_mixed_content.rs +0 -0
  61. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_mixed_nil.rs +0 -0
  62. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_namespace_entities.rs +0 -0
  63. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_pattern_codegen.rs +0 -0
  64. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_python_codegen.rs +0 -0
  65. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_qualified_attributes.rs +0 -0
  66. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_runtime_fast_paths.rs +0 -0
  67. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_rust_codecs.rs +0 -0
  68. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_rust_codegen.rs +0 -0
  69. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_schema_attribute_entities.rs +0 -0
  70. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_schema_audit.rs +0 -0
  71. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_schema_ir.rs +0 -0
  72. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_security.rs +0 -0
  73. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_temporal_union.rs +0 -0
  74. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_transcoder.rs +0 -0
  75. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_ts_codegen.rs +0 -0
  76. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_ubl_csharp.rs +0 -0
  77. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_unbounded_choice.rs +0 -0
  78. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_upa.rs +0 -0
  79. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_value_constraints.rs +0 -0
  80. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_variant_registry.rs +0 -0
  81. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-core/tests/test_xsi_type.rs +0 -0
  82. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/Cargo.toml +0 -0
  83. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/README.md +0 -0
  84. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/benches/aot_vs_dataclass.py +0 -0
  85. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/src/lib.rs +0 -0
  86. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_binary_fields.py +0 -0
  87. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_conformance.py +0 -0
  88. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_generated_models.py +0 -0
  89. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_json.py +0 -0
  90. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_mixed_content.py +0 -0
  91. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_polyxml.py +0 -0
  92. {polyxml-0.35.6 → polyxml-0.36.0}/crates/polyxml-python/tests/test_xsi_type.py +0 -0
  93. {polyxml-0.35.6 → polyxml-0.36.0}/python/polyxml/AGENT_GUIDE.md +0 -0
  94. {polyxml-0.35.6 → polyxml-0.36.0}/python/polyxml/__init__.py +0 -0
  95. {polyxml-0.35.6 → polyxml-0.36.0}/python/polyxml/compat/__init__.py +0 -0
  96. {polyxml-0.35.6 → polyxml-0.36.0}/python/polyxml/compat/xsdata.py +0 -0
  97. {polyxml-0.35.6 → polyxml-0.36.0}/python/polyxml/py.typed +0 -0
@@ -610,7 +610,7 @@ dependencies = [
610
610
 
611
611
  [[package]]
612
612
  name = "polyxml"
613
- version = "0.35.6"
613
+ version = "0.36.0"
614
614
  dependencies = [
615
615
  "criterion",
616
616
  "heck",
@@ -631,14 +631,14 @@ dependencies = [
631
631
 
632
632
  [[package]]
633
633
  name = "polyxml-c"
634
- version = "0.35.6"
634
+ version = "0.36.0"
635
635
  dependencies = [
636
636
  "polyxml",
637
637
  ]
638
638
 
639
639
  [[package]]
640
640
  name = "polyxml-cli"
641
- version = "0.35.6"
641
+ version = "0.36.0"
642
642
  dependencies = [
643
643
  "clap",
644
644
  "glob",
@@ -652,7 +652,7 @@ dependencies = [
652
652
 
653
653
  [[package]]
654
654
  name = "polyxml-js"
655
- version = "0.35.6"
655
+ version = "0.36.0"
656
656
  dependencies = [
657
657
  "napi",
658
658
  "napi-build",
@@ -662,7 +662,7 @@ dependencies = [
662
662
 
663
663
  [[package]]
664
664
  name = "polyxml-python"
665
- version = "0.35.6"
665
+ version = "0.36.0"
666
666
  dependencies = [
667
667
  "base64",
668
668
  "hex",
@@ -674,7 +674,7 @@ dependencies = [
674
674
 
675
675
  [[package]]
676
676
  name = "polyxml-wasm"
677
- version = "0.35.6"
677
+ version = "0.36.0"
678
678
  dependencies = [
679
679
  "polyxml",
680
680
  "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.35.6"
6
+ version = "0.36.0"
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.35.6
3
+ Version: 0.36.0
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -242,6 +242,7 @@ pub fn to_go_package_name(raw: &str) -> String {
242
242
  pub struct GoCodegen {
243
243
  options: GoOptions,
244
244
  context: GoLanguageContext,
245
+ shared_utils_import: Option<String>,
245
246
  }
246
247
 
247
248
  /// Emitted Go identifier for a named type, disambiguated across namespaces
@@ -295,9 +296,41 @@ impl GoCodegen {
295
296
  Self {
296
297
  options,
297
298
  context: GoLanguageContext,
299
+ shared_utils_import: None,
298
300
  }
299
301
  }
300
302
 
303
+ /// Share temporal, integer, and wildcard helper types from an external `utils` package.
304
+ pub fn with_shared_utils_import(mut self, import_path: impl Into<String>) -> Self {
305
+ self.shared_utils_import = Some(import_path.into());
306
+ self
307
+ }
308
+
309
+ /// Generate a standalone shared `utils` package containing temporal, integer, and wildcard types.
310
+ pub fn generate_shared_utils(&self, package_name: &str) -> String {
311
+ let mut out = String::new();
312
+ writeln!(
313
+ out,
314
+ "// Code generated by PolyXML Compiler (https://github.com/polyxml/PolyXML). DO NOT EDIT."
315
+ )
316
+ .unwrap();
317
+ writeln!(
318
+ out,
319
+ "// @generated by PolyXML Compiler (https://github.com/polyxml/PolyXML)\n"
320
+ )
321
+ .unwrap();
322
+ writeln!(out, "package {}\n", to_go_package_name(package_name)).unwrap();
323
+ writeln!(
324
+ out,
325
+ "import (\n \"encoding/xml\"\n \"fmt\"\n \"math/big\"\n \"strings\"\n \"time\"\n)\n"
326
+ )
327
+ .unwrap();
328
+ self.emit_temporal_types(&mut out);
329
+ self.emit_integer_types(&mut out);
330
+ out.push_str("// AnyElement represents an unmapped wildcard XML element (xs:any).\ntype AnyElement struct {\n XMLName xml.Name\n Attrs []xml.Attr `xml:\",any,attr\" json:\"attrs,omitempty\"`\n Content string `xml:\",innerxml\" json:\"content,omitempty\"`\n}\n");
331
+ out
332
+ }
333
+
301
334
  /// Generate complete Go module content.
302
335
  pub fn generate_module(&self, ir: &SchemaIR) -> String {
303
336
  set_type_name_map(build_type_name_map(ir, to_go_type_name));
@@ -372,16 +405,16 @@ impl GoCodegen {
372
405
 
373
406
  // Generate types
374
407
  self.emit_types(&mut body, ir);
375
- if has_time {
408
+ if self.shared_utils_import.is_none() && has_time {
376
409
  self.emit_temporal_types(&mut body);
377
410
  }
378
411
  self.emit_root_aliases(&mut body, ir);
379
- if body.contains("PolyxmlInteger")
412
+ let uses_integer_types = body.contains("PolyxmlInteger")
380
413
  || body.contains("PolyxmlPositiveInteger")
381
414
  || body.contains("PolyxmlNegativeInteger")
382
415
  || body.contains("PolyxmlNonPositiveInteger")
383
- || body.contains("PolyxmlNonNegativeInteger")
384
- {
416
+ || body.contains("PolyxmlNonNegativeInteger");
417
+ if self.shared_utils_import.is_none() && uses_integer_types {
385
418
  self.emit_integer_types(&mut body);
386
419
  }
387
420
 
@@ -389,6 +422,28 @@ impl GoCodegen {
389
422
  self.emit_content_helpers(&mut body);
390
423
  }
391
424
 
425
+ let mut shared_aliases = Vec::new();
426
+ if self.shared_utils_import.is_some() {
427
+ for sym in [
428
+ "PolyxmlDate",
429
+ "PolyxmlTime",
430
+ "PolyxmlDateTime",
431
+ "PolyxmlInteger",
432
+ "PolyxmlPositiveInteger",
433
+ "PolyxmlNegativeInteger",
434
+ "PolyxmlNonPositiveInteger",
435
+ "PolyxmlNonNegativeInteger",
436
+ "AnyElement",
437
+ ] {
438
+ if body.contains(sym) {
439
+ shared_aliases.push(sym);
440
+ }
441
+ }
442
+ for sym in &shared_aliases {
443
+ writeln!(body, "type {sym} = polyxmlutils.{sym}").unwrap();
444
+ }
445
+ }
446
+
392
447
  // Assemble final output with package and imports
393
448
  let mut out = String::new();
394
449
  if let Some(ref header) = self.options.custom_header {
@@ -412,24 +467,29 @@ impl GoCodegen {
412
467
  let pkg = to_go_package_name(&self.options.package_name);
413
468
  writeln!(out, "package {}\n", pkg).unwrap();
414
469
 
415
- let mut imports = Vec::new();
470
+ let mut imports: Vec<String> = Vec::new();
471
+ if let Some(ref utils_import) = self.shared_utils_import {
472
+ if !shared_aliases.is_empty() {
473
+ imports.push(format!("polyxmlutils \"{utils_import}\""));
474
+ }
475
+ }
416
476
  if body.contains("big.") {
417
- imports.push("\"math/big\"");
477
+ imports.push("\"math/big\"".to_string());
418
478
  }
419
479
  if body.contains("xml.") {
420
- imports.push("\"encoding/xml\"");
480
+ imports.push("\"encoding/xml\"".to_string());
421
481
  }
422
482
  if body.contains("bytes.") {
423
- imports.push("\"bytes\"");
483
+ imports.push("\"bytes\"".to_string());
424
484
  }
425
485
  if has_fmt || body.contains("fmt.") {
426
- imports.push("\"fmt\"");
486
+ imports.push("\"fmt\"".to_string());
427
487
  }
428
488
  if has_io || body.contains("io.") {
429
- imports.push("\"io\"");
489
+ imports.push("\"io\"".to_string());
430
490
  }
431
491
  if has_patterns || body.contains("regexp.") {
432
- imports.push("\"regexp\"");
492
+ imports.push("\"regexp\"".to_string());
433
493
  }
434
494
  if ir
435
495
  .types
@@ -437,13 +497,13 @@ impl GoCodegen {
437
497
  .any(|def| matches!(def, TypeDef::Union(u) if u.is_lexical()))
438
498
  && body.contains("strconv.")
439
499
  {
440
- imports.push("\"strconv\"");
500
+ imports.push("\"strconv\"".to_string());
441
501
  }
442
502
  if body.contains("strings.") {
443
- imports.push("\"strings\"");
503
+ imports.push("\"strings\"".to_string());
444
504
  }
445
- if has_time {
446
- imports.push("\"time\"");
505
+ if has_time && self.shared_utils_import.is_none() {
506
+ imports.push("\"time\"".to_string());
447
507
  }
448
508
 
449
509
  if !imports.is_empty() {
@@ -519,7 +579,7 @@ impl GoCodegen {
519
579
  TypeDef::Struct(s) => s.fields.iter().any(|f| f.kind == FieldKind::Any),
520
580
  _ => false,
521
581
  });
522
- if has_any_element {
582
+ if has_any_element && self.shared_utils_import.is_none() {
523
583
  out.push_str("// AnyElement represents an unmapped wildcard XML element (xs:any).\ntype AnyElement struct {\n XMLName xml.Name\n Attrs []xml.Attr `xml:\",any,attr\" json:\"attrs,omitempty\"`\n Content string `xml:\",innerxml\" json:\"content,omitempty\"`\n}\n\n");
524
584
  }
525
585
  }
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "polyxml"
7
- version = "0.35.6"
7
+ version = "0.36.0"
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