Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace recursive xslt templates to add breaklines and hyperlinks in metadata detail page (full view), to use pattern matching to avoid stack overflow for texts with many breaklines #5446

Conversation

josegar74
Copy link
Member

The original template caused a stack overflow error with elements containing many breaklines, also was nesting p for each breakline. For example:

 <div class="gn-abstract">
    <p>Aan het NNB (Natuur Netwerk Brabant) in het Natuurbeheerplan dat is vastgesteld op: zie veld Revisiedatum,  is extra informatie toegevoegd. Het betreft een onderverdeling in NNB Rijksdeel en NNB Provinciaal deel.</p>
    <p>
        <p />
        <p>
            <p />
            <p>
                <p />
...
                            <p />
                            <p>
                                <p />
                                <p>
                                    <p>NNB Rijksdeel zijn gebieden in het NNB waar een rijksopgave  ligt. Het rijksdeel bestaat uit de gronden die nodig zijn om aan de internationale  verplichtingen van het Rijk te  kunnen voldoen. Dit zijn de Natura-2000 gebieden en de gebieden die zijn aangewezen op grond van  de Kader Richtlijn Water, zoals de  Natte  Natuurparels en het Beek en kreekherstel.</p>
                                    <p>
...

Note that with this change, the approach is a bit different than in the previous implementation, the text not matching a breakline is surrounded with a p element. This implicates that the number of breaklines are not preserved in the full view, for example in the xml contains:

<gmd:abstract>
  <gco:CharacterString>This is parragraph 1.




This is parragraph 2.
  </gco:CharacterString>
</gmd:abstract>

It will render a 2 p elements, not preserving all the breaklines:

<p>This is parragraph 1.</p>

<p>This is parragraph 2.</p>

This should be fine in most cases and avoids the error related to the stack overflow due to the recursive processing in the previous template.


Done also some cleanup of unused templates in the xsl file https://github.com/geonetwork/core-geonetwork/blob/master/web/src/main/webapp/xslt/common/utility-tpl.xsl
, that seem copied from https://github.com/geonetwork/core-geonetwork/blob/master/web/src/main/webapp/xsl/text-utilities.xsl, but no longer used. The previous file seem only used in the editor files used in old versions also, not used anymore afaik.

@josegar74 josegar74 changed the title Replace recursive xslt templates to add breaklines and hyperlinks in metadata detail page (full view), to use pattern matching to avoid stack overflow for long texts Replace recursive xslt templates to add breaklines and hyperlinks in metadata detail page (full view), to use pattern matching to avoid stack overflow for texts with many breaklines Feb 23, 2021
…metadata detail page (full view), to use pattern matching to avoid stack overflow for texts with many breaklines
@josegar74 josegar74 force-pushed the replace-breaklines-hyperlink-templates-regex branch from bae1c06 to 6f8314a Compare February 23, 2021 13:32
@josegar74 josegar74 added this to the 3.12.0 milestone Feb 23, 2021
@fxprunayre
Copy link
Member

Main issue is double line break are ignored and it make all the same - paragraph / list

image

@fxprunayre
Copy link
Member

Even better now. We also add <br/> on multiple line breaks

image

Thanks Jose.

@fxprunayre fxprunayre merged commit a9d6494 into geonetwork:master Feb 24, 2021
fxprunayre added a commit that referenced this pull request May 10, 2021
* Replace recursive xslt templates to add breaklines and hyperlinks in metadata detail page (full view), to use pattern matching to avoid stack overflow for texts with many breaklines

* Update templates to manage breaklines to preserve all the breaklines

#5446

Co-authored-by: Jose García <[email protected]>

Co-authored-by: Francois Prunayre <[email protected]>
fxprunayre added a commit that referenced this pull request May 10, 2021
* Replace recursive xslt templates to add breaklines and hyperlinks in metadata detail page (full view), to use pattern matching to avoid stack overflow for texts with many breaklines

* Update templates to manage breaklines to preserve all the breaklines

#5446

Co-authored-by: Jose García <[email protected]>

Co-authored-by: Francois Prunayre <[email protected]>
fxprunayre added a commit that referenced this pull request May 10, 2021
* Replace recursive xslt templates to add breaklines and hyperlinks in metadata detail page (full view), to use pattern matching to avoid stack overflow for texts with many breaklines

* Update templates to manage breaklines to preserve all the breaklines

#5446

Co-authored-by: Jose García <[email protected]>

Co-authored-by: Francois Prunayre <[email protected]>
fxprunayre added a commit that referenced this pull request Jun 15, 2021
Issue introduced in #5446

An XSL formatter applied to a multilingual record always display all languages.

eg. 
http://localhost:8080/geonetwork/srv/api/records/b07a4589-159b-4c3a-b1e7-dbdad11f7e62/formatters/xsl-view?view=advanced&language=fre MUST display French and fallback to main language
fxprunayre added a commit that referenced this pull request Jun 18, 2021
Issue introduced in #5446

An XSL formatter applied to a multilingual record always display all languages.

eg. 
http://localhost:8080/geonetwork/srv/api/records/b07a4589-159b-4c3a-b1e7-dbdad11f7e62/formatters/xsl-view?view=advanced&language=fre MUST display French and fallback to main language
cmangeat pushed a commit to geoadmin/geocat that referenced this pull request Jul 5, 2021
Issue introduced in geonetwork/core-geonetwork#5446

An XSL formatter applied to a multilingual record always display all languages.

eg. 
http://localhost:8080/geonetwork/srv/api/records/b07a4589-159b-4c3a-b1e7-dbdad11f7e62/formatters/xsl-view?view=advanced&language=fre MUST display French and fallback to main language
josegar74 pushed a commit that referenced this pull request Jan 18, 2022
…more

Issue introduced in #5446

An XSL formatter applied to a multilingual record always display all languages.

eg.
http://localhost:8080/geonetwork/srv/api/records/b07a4589-159b-4c3a-b1e7-dbdad11f7e62/formatters/xsl-view?view=advanced&language=fre MUST display French and fallback to main language
fxprunayre added a commit that referenced this pull request Jun 27, 2023
josegar74 pushed a commit that referenced this pull request Jul 12, 2023
* Standard / ISO19115-3 / Formatter / Insert line breaks and hyperlinks in text

In all `gco:CharacterString` add line breaks and hyperlinks eg. in lineage.

This is more consistent with ISO19139.

* Standard / ISO19115-3 / Full view / Contact and keyword layout

Backport of #5446 for 115-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants