speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
296 stars 36 forks source link

`<AttachFile>` as child of `<ForAll>`? #451

Closed pr-apes closed 1 year ago

pr-apes commented 1 year ago

@pgundlach,

would it be possible that <AttachFile> could be placed inside <ForAll>?

With the new option to attach any files, having this is essential to embed files from a CSV files (among other possibilities).

Many thanks for your help.

pr-apes commented 1 year ago

I think that if <Bookmark> is already child of <ForAll>, it should not be a problem to have <AttachFile>.

Or am I missing something?

(I would do it myself, but I don't have the slightest idea on how children are added to any element.)

pgundlach commented 1 year ago

AttachFile can be part of ForAll, it is just the schema that complains (which will be fixed in the next version)

<Layout xmlns="urn:speedata.de:2009/publisher/en"
    xmlns:sd="urn:speedata:2009/publisher/functions/en">

    <Record element="data">
        <ForAll select="f">
            <AttachFile filename="{@src}" description="{@description}" type="application/csv"/>
        </ForAll>
        <PlaceObject>
            <Textblock>
                <Paragraph>
                    <Value>text</Value>
                </Paragraph>
            </Textblock>
        </PlaceObject>
    </Record>
</Layout>

works here.

pr-apes commented 1 year ago

I have just discovered that missing required attribute type caused the error (maybe a more descriptive error message about missing required attributes would help).

BTW, if filename contains a conditional, Publisher is not able to finish compilation:

filename="{if (contains(string(celda_2), '.pdf') then string(celda_2) else concat(string(celda_2), '.pdf')}"

What am I missing here?

pgundlach commented 1 year ago

I'll provide a default type.

You should check your filename condition for correctness :-)

The XPath parser is crappy so it does not complain about errors.

pr-apes commented 1 year ago

@pgundlach,

many thanks for your reply, since it helped me to notice that I hadn't closed one of the parentheses (although it took me a while).

This was my fault, of course. But I wonder whether it would make sense to establish a timeout for XPath evaluation.

If the parser cannot execute the expression after the timeout, it would be of great help to report the user that the given expression (with line number) cannot be executed.

This would be different from a general timeout (which Publisher may have to execute runs).

Many thanks for your help.