metafacture / metafacture-core

Core package of the Metafacture tool suite for metadata processing.
https://metafacture.org
Apache License 2.0
71 stars 34 forks source link

Error in using recursion inside an entity #398

Closed hagbeck closed 3 years ago

hagbeck commented 3 years ago

Hi,

i have the following problem: I build an entity and use a recursion in it for a source to use it later in other rules. But instead of using it as "variable" it is used as normal "name".

If I use this without the surrounding entity it works as expected.

    <entity name="header" flushWith="record">
        <concat name="@setSpecOrigin" delimiter="|">
            <if>
                <any>
                    <data source="pubtype.value" />
                    <data source="resourceType.value" />
                    <data source="formSubject.value" />
                </any>
            </if>
            <data source="pubtype.value" />
            <data source="resourceType.value" />
            <data source="formSubject.value" />
        </concat>

        <data name="setSpecPubtype" source="@setSpecOrigin">
            <lookup in="publication_types" />
        </data>
        <data name="setSpecDoctype" source="@setSpecOrigin">
            <lookup in="document_types" />
        </data>

    </entity>

results in

<header>
    <@setSpecOrigin>article_journal</@setSpecOrigin>
</header>
blackwinter commented 3 years ago

Recursion only works at the top level. I don't think it's documented anywhere, but only the Metamorph class itself is actually prepared to deal with @-variables.

Is there any reason that would preclude you from moving the concat out of the entity?

hagbeck commented 3 years ago

Yes, because it doesn't work yesterday. Now I found the reason. It was late ;-)

Your suggestion works fine. Thanks!