I would like to convert yang to xml format. Please let me know if any tools are available already.
I tried with pyang yin format, which provides xml format but not in desired format.
Generated xml: Ex:
<container name="password">
<leaf name="enc-type">
<type name="enumeration">
<enum name="clear">
Requied format:
<container>
<enc-type>
</en-type>
</container>
pyang you can use, I also have this requirement, and I use the pyang is enough.
pyang -f sample-xml-skeleton --sample-xml-skeleton-defaults -o output.xml input.yang
and the pyang format help:
$ pyang -h
Usage: pyang [options] [<filename>...]
-f FORMAT, --format=FORMAT
Convert to FORMAT. Supported formats are: yang, yin,
dsdl, capability, depend, jsonxsl, jstree, jtox, name,
omni, sample-xml-skeleton, tree, uml
Sample-xml-skeleton output specific options:
--sample-xml-skeleton-doctype=DOCTYPE
Type of sample XML document (data or config).
--sample-xml-skeleton-defaults
Insert leafs with defaults values.
--sample-xml-skeleton-annotations
Add annotations as XML comments.
--sample-xml-skeleton-path=SAMPLE_PATH
Subtree to print
YIN format is the standard XML representation of YANG models defined in the same RFC as the YANG itself. You should probably use it instead of any in-house XML format.
What you want to achieve is a strange mixture of YIN (with the container element) and instance document (enc-type element which corresponds to the leaf name). I doubt that your definition is complete enough to be sure what you really mean and I also doubt that there are any existing tools that you can use out of the box.
I'd recommend to stick to YIN or, if absolutely necessary, create own tool for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With