SETI / rms-pds4indextools

PDS4 index tools Python module
Apache License 2.0
0 stars 0 forks source link

New command line argument to remove numbers for disambiguated XPaths #29

Open rfrenchseti opened 1 month ago

rfrenchseti commented 1 month ago

In pds4_create_xml_index there are currently two options for the headers:

I would like to see a new argument called something like --dont-number-unique-tags that still gives full XPaths, but if there is only a single instance at a given level, it doesn't include the <1> at the end. So instead of:

a<1>/b<1>/c<1>
a<1>/b<1>/c<2>
a<1>/b<2>/c<1>
a<1>/b<2>/c<2>

we would get:

a/b<1>/c<1>
a/b<1>/c<2>
a/b<2>/c<1>
a/b<2>/c<2>

This is a very simple modification to the existing renumbering function, where if the mapping only has one value in it we don't add the <n> at all.

This function could be used in addition to --simplify-xpaths to get the simplest version possible.