vendredi 18 décembre 2020

Is there a basex function to randomly erase parts of an XML file?

I have an XML file with an X number of annotations, and I would like to edit it to have less than X of these, randomly. For practical matters: I have 40 annotations and I would like to end up with only 7, having selected these randomly. Each of my files has a different original number of annotations but I want always to have seven in the end. Each annotation looks like this:

  <ndpviewstate id="1">
    <title>1</title>
    <details/>
    <coordformat>nanometers</coordformat>
    <lens>0.480769</lens>
    <x>21841504</x>
    <y>-2550259</y>
    <z>0</z>
    <showtitle>1</showtitle>
    <showhistogram>0</showhistogram>
    <showlineprofile>0</showlineprofile>
    <annotation type="circle" displayname="AnnotateCircle" color="#000000">
      <x>16893748</x>
      <y>79968</y>
      <radius>545000</radius>
      <measuretype>0</measuretype>
    </annotation>
  </ndpviewstate>

I am an absolute beginner with XML and BaseX (version 9.4.5) so any help will be welcomed.

Thanks in advance, Guido




Aucun commentaire:

Enregistrer un commentaire