{"id":10177,"library":"pyxb-x","title":"PyXB-X","description":"PyXB-X (\"pixbix\") is a pure Python package that generates Python source code for classes that correspond to data structures defined by XMLSchema. It is a re-release of PyXB 1.2.6 under a distinct namespace (`pyxb_x`) to avoid dependency conflicts. The project appears to be in maintenance mode, with its last PyPI release in March 2020 and its upstream PyXB project showing limited recent activity.","status":"maintenance","version":"1.2.6.3","language":"python","source_language":"en","source_url":"https://github.com/PyXB/pyxb","tags":["XML","Schema","Code Generation","SOAP","WSDL"],"install":[{"cmd":"pip install pyxb-x","lang":"bash","label":"Install PyXB-X"}],"dependencies":[],"imports":[{"wrong":"from pyxb_x.gen.pyxbgen import PyXBGenerator","symbol":"BIND","correct":"from pyxb import BIND"},{"symbol":"AbstractElementError","correct":"from pyxb import AbstractElementError"},{"symbol":"BindingError","correct":"from pyxb import BindingError"}],"quickstart":{"code":"import os\nimport sys\nimport subprocess\nimport tempfile\nimport shutil\n\n# 1. Define a simple XML Schema (XSD)\nxsd_content = \"\"\"<?xml version=\\\"1.0\\\"?>\n<xs:schema xmlns:xs=\\\"http://www.w3.org/2001/XMLSchema\\\">\n  <xs:element name=\\\"person\\\">\n    <xs:complexType>\n      <xs:sequence>\n        <xs:element name=\\\"name\\\" type=\\\"xs:string\\\"/>\n        <xs:element name=\\\"age\\\" type=\\\"xs:int\\\"/>\n      </xs:sequence>\n    </xs:complexType>\n  </xs:element>\n</xs:schema>\n\"\"\"\n\n# 2. Set up temporary directory for XSD and generated bindings\ntemp_dir = tempfile.mkdtemp()\nxsd_path = os.path.join(temp_dir, 'example.xsd')\nwith open(xsd_path, 'w') as f:\n    f.write(xsd_content)\n\nbinding_module_name = 'my_example_bindings'\noutput_dir = temp_dir\n\n# 3. Use pyxbgen to generate Python bindings\n#    The `pyxbgen` command-line tool is installed with `pyxb-x`.\n#    If `pyxbgen` is not found in PATH, use `python -m pyxb_x.gen.pyxbgen`.\n\n# Determine the correct command for pyxbgen\ntry:\n    subprocess.check_call(['pyxbgen', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n    pyxbgen_cmd = 'pyxbgen'\nexcept (subprocess.CalledProcessError, FileNotFoundError):\n    pyxbgen_cmd = [sys.executable, '-m', 'pyxb_x.gen.pyxbgen']\n\ngenerate_command_args = [\n    f'--schema-location={xsd_path}',\n    '--binding-language=python',\n    f'--module={binding_module_name}',\n    f'--output-directory={output_dir}'\n]\n\nfull_command = [pyxbgen_cmd] + generate_command_args if isinstance(pyxbgen_cmd, list) else [pyxbgen_cmd] + generate_command_args\n\nprint(f\"Running generation command: {' '.join(full_command)}\")\nsubprocess.check_call(full_command)\nprint(f\"Bindings generated to: {output_dir}/{binding_module_name}.py\")\n\n# 4. Add the output directory to sys.path to import the generated module\nsys.path.insert(0, output_dir)\n\n# 5. Import and use the generated bindings\nimport my_example_bindings\n\n# Create an instance of the 'person' element\np = my_example_bindings.person(name=\"Alice\", age=30)\n\n# Serialize to XML\nxml_doc = p.toxml('utf-8', element_name='person')\nprint(\"\\nGenerated XML:\")\nprint(xml_doc.decode('utf-8'))\n\n# Parse XML back into a Python object\nparsed_p = my_example_bindings.CreateFromDocument(xml_doc)\nprint(f\"\\nParsed back: Name={parsed_p.name}, Age={parsed_p.age}\")\n\n# Clean up temporary files\nshutil.rmtree(temp_dir)\nprint(\"\\nCleaned up temporary files.\")","lang":"python","description":"This quickstart demonstrates how to define a simple XML Schema (XSD), use the `pyxbgen` command-line tool to generate Python binding classes, and then use those classes to create Python objects, serialize them to XML, and parse XML back into objects."},"warnings":[{"fix":"Change `import pyxb...` to `import pyxb_x...` for all PyXB-related imports.","message":"PyXB-X installs under the `pyxb_x` namespace, not `pyxb`. All imports must use `pyxb_x` (e.g., `import pyxb_x.binding`). If you have both `pyxb` and `pyxb-x` installed, ensure you are consistently using `pyxb_x` to avoid `ModuleNotFoundError` or conflicts.","severity":"gotcha","affected_versions":"All versions of `pyxb-x`."},{"fix":"Stick to documentation and examples specific to PyXB 1.2.6 when using `pyxb-x`. Do not expect compatibility with features or APIs beyond that version.","message":"PyXB-X specifically mirrors PyXB version 1.2.6. Be aware that any changes, new features, or breaking API modifications introduced in later conceptual versions of the upstream PyXB project are not present or compatible with `pyxb-x`.","severity":"breaking","affected_versions":"All versions of `pyxb-x`."},{"fix":"Simplify schemas where possible. Consult the PyXB 1.2.6 documentation thoroughly for handling advanced schema constructs. Debug generated code and use `toxml()` and `CreateFromDocument()` to test edge cases.","message":"Complex XML Schema features (e.g., multiple namespaces, `xsi:type`, `anyURI` types, deeply nested hierarchies, wildcards) can sometimes result in unexpected Python bindings, generation errors, or runtime issues during serialization/deserialization.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"search_vec":"'1.2.6':36 '2020':62 'activ':71 'appear':49 'avoid':44 'class':19 'code':17,74 'conflict':46 'correspond':21 'data':23 'defin':25 'depend':45 'distinct':39 'generat':14,75 'last':57 'limit':69 'mainten':53 'march':61 'mode':54 'namespac':40 'packag':12 'pixbix':7 'project':48,67 'pure':10 'pypi':58 'python':11,15 'pyxb':2,5,35,41,66 'pyxb-x':1,4 're':32 're-releas':31 'recent':70 'releas':33,59 'schema':73 'show':68 'soap':76 'sourc':16 'structur':24 'upstream':65 'wsdl':77 'x':3,6,42 'xml':72 'xmlschema':27","created_at":"2026-04-17T01:22:47.486719+00:00","updated_at":"2026-04-17T01:22:47.486719+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2.6.3","cli_name":"pyxbgen","cli_version":"pyxbgen from PyXB 1.2.6","type":"library","homepage":"http://pyxb.sourceforge.net","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/pyxb-x/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}