speedata / publisher

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

extra blank line with `<br/>` and XPath conditional #479

Closed pr-apes closed 1 year ago

pr-apes commented 1 year ago

@pgundlach,

the shorter text suggested in https://github.com/speedata/publisher/discussions/478#discussioncomment-5345430 might have hit a bug (or a rather uncommon behavior).

Given the following data.xml contents:

<data>
  <row>
    <cell>a b</cell>
    <cell>a&lt;br/&gt;b</cell>
    <cell>a b</cell>
  </row>
</data>

And the following layout contents:

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

  <Record element="data">
    <Output>
      <Text>
        <ForAll select="row">
          <Switch>
            <Case test="position() > 0">
              <ForAll select="cell">
                <Paragraph>
                  <Value select="if (position() > 0) then sd:decode-html(.) else" />
                  <Value select="sd:decode-html(.)" />
                </Paragraph>
              </ForAll>
            </Case>
          </Switch>
        </ForAll>
      </Text>
    </Output>
  </Record>

</Layout>

Final output is:

publisher-000001-fs8

It seems that <Value select="if (position() > 0) then sd:decode-html(.) else" /> interprets <br/> as a full blank line (which is wrong) and <Value select="sd:decode-html(.)" /> handles it as a line break inside the same paragraph (which is right).

I have no idea what might be triggering this.

It would be great, if you could take a look at it.

Many thanks for your help.

pgundlach commented 1 year ago

Interesting, this looks strange. Thank you for posting this issue!

pgundlach commented 1 year ago

I believe this should be fixed by rewriting the XPath parser, which will take some time.

pr-apes commented 1 year ago

Many thanks for your reply, @pgundlach.

This doesn't seem to be a minor task.

I'm still making some tests, so it may be wise to close the issue (myself).

If I find something that I cannot avoid, I will reopen the issue.

Many thanks for your help.