urban-json-xml
Français · English
Plugin urban-json : lecture de fichiers XML
dans les templates, via la fonction loadxml. Suit les conventions XML↔JSON du
XmlNodeConverter (.NET/Newtonsoft).
Installation
pip install urban-json-xml # tire urban-json et defusedxml en dépendances
urban-json découvre le plugin automatiquement via les entry points (urban_json.functions) :
loadxml devient utilisable dans les templates.
Utilisation
from urban_json import JsltTemplate
# catalog.xml :
# <catalog>
# <book id="1"><title>A</title></book>
# <book id="2"><title>B</title></book>
# </catalog>
tpl = JsltTemplate.parse('[ { "$source": select(loadxml("catalog.xml"), $.catalog.book), "t": $.title } ]')
tpl.transform({})
# -> [{'t': 'A'}, {'t': 'B'}]
loadxml renvoie un objet ; on navigue dedans avec select/selectmany (fonctions
du cœur) avant d'alimenter une boucle $source, un filtre ?(...), etc.
Conventions de conversion (Newtonsoft)
| XML | JSON |
|---|---|
<a>v</a> |
{"a": "v"} |
<a x="1">v</a> |
{"a": {"@x": "1", "#text": "v"}} |
<a/> |
{"a": null} |
<a><b>1</b><b>2</b></a> |
{"a": {"b": ["1", "2"]}} (frères homonymes → tableau) |
- Attributs → propriétés préfixées par
@. - Texte d'un élément mixte → clé
#text. - Les valeurs restent des chaînes (comme Newtonsoft, pas de coercition).
Signature
loadxml(source_path, attribute_prefix="@", text_key="#text", strip_namespaces=true)
| Paramètre | Rôle |
|---|---|
source_path |
chemin du fichier XML |
attribute_prefix |
préfixe des propriétés issues d'attributs (défaut @) |
text_key |
clé portant le texte d'un élément mixte (défaut #text) |
strip_namespaces |
réduit {uri}local au nom local (défaut true) |
Sécurité
Le XML est analysé avec defusedxml :
entités externes et expansion d'entités désactivées (protection XXE /
« billion laughs »).
Licence
Apache-2.0.
Metadata
Release files for urban-json-xml 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| urban_json_xml-0.1.1.tar.gz | 6.4 kB | With provenance | Details for urban_json_xml-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| urban_json_xml-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for urban_json_xml-0.1.1-py3-none-any.whl |
Total release size: 12.2 kB
Release files / urban_json_xml-0.1.1.tar.gz
| Download URL | urban_json_xml-0.1.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ceca97b383e8079eafc932f4d808a26f0db9f8cc82e06e0145f4ef187824ca19
|
|
BLAKE2b-256 checksum How to use checksums |
f8c2be581e6f274a83d56785fd1403448ee38645c637b894e0ad2e03eea56cae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / urban_json_xml-0.1.1-py3-none-any.whl
| Download URL | urban_json_xml-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcf7aa4176276aaeec4c92be464724c91e0bd109cfaf42e86afe435cfc8abfce
|
|
BLAKE2b-256 checksum How to use checksums |
34ff6234741b00164bf034a939f4b46700142af7b2b2f180368652fce05c67f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for urban-json-xml 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for urban_json_xml-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.