isl / x3ml

X3ML Engine supports the data transformation which is part of the data provisioning and aggregation process.
Apache License 2.0
20 stars 7 forks source link

XPATH 2.0 (or how to join strings) #145

Closed ncarboni closed 2 years ago

ncarboni commented 3 years ago

Hello, i am trying to join multiple strings present in the attributes of the childs of an xml element. I do not have any fixed number of child elements, so in order to retrieve and combine them I would use string-join:

string-join(TextLine/String/@CONTENT, ',')

which, however, does not work. String-join is only available in XPATH 2.0, hence the question: is XPATH 2 supported by X3ML?

Alternatively, do you see any other methods to achieve such result?

Sample of the xml input

<TextLine ID="tl_2"
                    TAGREFS="LT47"
                    BASELINE="1074 710 1891 714 2311 720 2551 717 3011 736 3367 733 3798 720" 
                    HPOS="1074"
                    VPOS="509"
                    WIDTH="2725"
                    HEIGHT="291">
            <Shape><Polygon POINTS="1074 509 3799 509 3799 800 1074 800"/></Shape>
        <String CONTENT="ſon puis que ce ſont des feli¬"
                    HPOS="1074"
                    VPOS="509"
                    WIDTH="2725"
                    HEIGHT="291"></String>
        <String CONTENT="ſçeu l&#39;heureux ſuccés du"
                    HPOS="1083"
                    VPOS="1065"
                    WIDTH="2701"
                    HEIGHT="315"></String>
          </TextLine>

          <TextLine ID="tl_3"
                  TAGREFS="LT47"
                    BASELINE="1089 1006 1533 1004 2629 1014 3245 1013 3777 1028" 
                    HPOS="1088"
                    VPOS="797"
                    WIDTH="2690"
                    HEIGHT="295">
            <Shape><Polygon POINTS="1088 797 3778 797 3778 1092 1088 1092"/></Shape>
        <String CONTENT="cités publiques. Nous auõs"
                    HPOS="1088"
                    VPOS="797"
                    WIDTH="2690"
                    HEIGHT="295"></String>
          </TextLine>

Current result

<https://segmonto.unige.ch/example/page/eSc_dummypage_/r_1_1/tl_2>
        a                               crm:E25_Human-Made_Feature , 
        crm:P190_has_symbolic_contents  "ſçeu l'heureux ſuccés du" , "ſon puis que ce ſont des feli¬" .

expected results:

<https://segmonto.unige.ch/example/page/eSc_dummypage_/r_1_1/tl_2>
        a                               crm:E25_Human-Made_Feature , 
        crm:P190_has_symbolic_contents  "ſçeu l'heureux ſuccés du ſon puis que ce ſont des feli¬" .
ymark commented 3 years ago

string-join is supported by X3ML-Engine. I haven't seen your mapping however I suspect that the reason for not producing a single (under P190), is because your link uses as source the String element (and not one of its parent elements).

In case you cannot debug it, paste here the corresponding part of your X3ML mappings to have a look.

ncarboni commented 3 years ago

I haven't seen your mapping however I suspect that the reason for not producing a single (under P190), is because your link uses as source the String element (and not one of its parent elements).

Indeed that was the reason, now it works greatly! Thanks :-)