Datumaro XPath Filtering vs regular XPath Filtering

97 Views Asked by At

I just created an account because I can't find this answer anywhere else. To what extent does datumaro support XPath filtering? I currently have a working XPath for the information I need, but the datumaro syntax for CVAT is a little different.

For reference this is the working XPath:

//box//*[contains(@name,"Volume")][contains(.,'10')]/ancestor::*[@outside="0" and @keyframe="1"]

I am trying to filter the following .xml for only volumes of 10, hence the filtering for name. I would use a simple contains() which works in datumaro but sometimes the drug concentration and frame number etc. will match that, which I'm not looking for.

<box frame="1970" outside="1" occluded="0" keyframe="1" xtl="405.70" ytl="1732.57" xbr="923.38" ybr="3342.50" z_order="0">
  <attribute name="Event_Type">Syringe_In_Hand</attribute>
  <attribute name="Color">White and Red Border</attribute>
  <attribute name="Drug_Concentration">100</attribute>
  <attribute name="Drug_Name">Sugammadex</attribute>
  <attribute name="Volume">10</attribute>
</box>

My datumaro XPath currently looks like this:

\'/item/annotation/*[contains(name,\"Volume\")][contains(.,\"10\")]/ancestor::*[outside=\"False\" and keyframe=\"True\"]\''

I'm not sure if datumaro supports ancestor and /* right after annotation. Let me know if there is a better way to write this in datumaro, or if there is a way to extract the same data using only one contains().

I'm using Python and datumaro, and this is for CVAT formatted .xml files.

Update: I've gotten it to work with just //box[attribute[@name="Volume"][contains(.,"3")] and @outside="0" and @keyframe="1" and contains(., "Syringe")]. But it still doesn't work in datumaro as /item/annotation[attribute[name=\"Volume\"][contains(.,\"3\")] and outside=\"False\" and keyframe=\"True\" and contains(., \"Syringe\")]\'. Do I have to be using XPath 1.0 for datumaro?

0

There are 0 best solutions below