-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
API / XSL / Use XSL output configuration (formatter, editor). #7929
API / XSL / Use XSL output configuration (formatter, editor). #7929
Conversation
Formatter API was using an XMLOutputter formatter overriding all configuration made in `xsl:output`. This was producing "invalid" HTML and some workaround were used so far. Now, return the output produced by saxon XMLIndenter or HTMLIndenter directly.
1d86f2e
to
d111f72
Compare
The editor is an HTML page so don't use an XML formatter for the output. To format the XML in XML view, saxon is taking care of it using serialize and default-indent-mode. Use an HTML `pre` element which is not formatted by HTMLIndenter.
…ains about not closed tags like links.
Quality Gate failedFailed conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request seems working fine producing correct HTML. See questions added.
The pull request title seems a bit unclear, it seems only affects the formatters, but also affects the metadata editor (which is fine).
From the pull request description:
Also do not force editor API to output XML. It outputs HTML and XML view may contains a properly formatted XML snippet.
I guess this is related to this change https://github.com/geonetwork/core-geonetwork/pull/7929/files#diff-6619510098f17f2c27d668ff5572c83cb1e954ea115469baddc12f9bcb9667e2R42? Can you elaborate it a bit more?
@@ -688,7 +688,8 @@ private void buildEditorForm(String tab, HttpSession session, Map<String, String | |||
GeonetworkDataDirectory dataDirectory = applicationContext.getBean(GeonetworkDataDirectory.class); | |||
Path xslt = dataDirectory.getWebappDir() | |||
.resolve(isEmbedded ? "xslt/ui-metadata/edit/edit-embedded.xsl" : "xslt/ui-metadata/edit/edit.xsl"); | |||
Xml.transformXml(root, xslt, response.getOutputStream()); | |||
|
|||
Xml.transform(root, xslt, response.getOutputStream()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, calling Xml.transformXml
was setting geonet-force-xml
, that had executed some specific logic in https://github.com/geonetwork/core-geonetwork/pull/7929/files#diff-0e73f2dd016775585aabf4911d02c93bae066b3463da113616eb91a08c4c87c7R488
I guess as maybe relies now in xsl:output
in xslt files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the editor is an HTML page so using the geonet-force-xml
workaround was producing "wrong" HTML.
I think the workaround idea was to fix the XML view in order to indent the XML in the editor but https://github.com/geonetwork/core-geonetwork/pull/7929/files#diff-6619510098f17f2c27d668ff5572c83cb1e954ea115469baddc12f9bcb9667e2R45 was doing it well as far as the XML is in an HTML pre
element (which is not formatted by the Saxon HTMLIndenter).
@@ -30,11 +30,6 @@ | |||
<xsl:include href="../base-layout-cssjs-loader.xsl"/> | |||
<xsl:include href="../skin/default/skin.xsl"/> | |||
|
|||
<xsl:output omit-xml-declaration="yes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this removed due to be imported this xslt in another that includes xsl:output
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it is set properly in render-layout.xsl
https://github.com/geonetwork/core-geonetwork/pull/7929/files#diff-6e6c6733802f16a82af7204c3f782f06e6d624e342b5608b8a4f3cdb9700dc61R23
The backport to
stderr
stdout
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.2.x 4.2.x
# Navigate to the new working tree
cd .worktrees/backport-4.2.x
# Create a new branch
git switch --create backport-7929-to-4.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick d111f726135af61fb7ec5e270c9abaa8f6c89604,36d3f44d29b4893c6b2adb531b0b6a257147a951,5e51ed2fdb0b0e4995539ad309135aee350db13e,847f105c8925fe9a83164e6f604a554de4168dc7
# Push it to GitHub
git push --set-upstream origin backport-7929-to-4.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.2.x Then, create a pull request where the |
* Test / Fix formatter test. Related to #7929. * Prettier. * Test / Fix formatter test / Citation common may be embedded in other formatter. Only set xsl:output in the citation entry point.
* API / Formatter / Use XSL output configuration. Formatter API was using an XMLOutputter formatter overriding all configuration made in `xsl:output`. This was producing "invalid" HTML and some workaround were used so far. Now, return the output produced by saxon XMLIndenter or HTMLIndenter directly. * Editor / Fix formatting. The editor is an HTML page so don't use an XML formatter for the output. To format the XML in XML view, saxon is taking care of it using serialize and default-indent-mode. Use an HTML `pre` element which is not formatted by HTMLIndenter. * Formatter / Fix conflicting output when citation is used in xsl-view. * API / Formatter / iText for PDF expect xhtml document. If HTML, complains about not closed tags like links.
* Test / Fix formatter test. Related to #7929. * Prettier. * Test / Fix formatter test / Citation common may be embedded in other formatter. Only set xsl:output in the citation entry point.
… editor) (#8104) * API / XSL / Use XSL output configuration (formatter, editor). (#7929) * API / Formatter / Use XSL output configuration. Formatter API was using an XMLOutputter formatter overriding all configuration made in `xsl:output`. This was producing "invalid" HTML and some workaround were used so far. Now, return the output produced by saxon XMLIndenter or HTMLIndenter directly. * Editor / Fix formatting. The editor is an HTML page so don't use an XML formatter for the output. To format the XML in XML view, saxon is taking care of it using serialize and default-indent-mode. Use an HTML `pre` element which is not formatted by HTMLIndenter. * Formatter / Fix conflicting output when citation is used in xsl-view. * API / Formatter / iText for PDF expect xhtml document. If HTML, complains about not closed tags like links. * Test / Fix formatter test. (#7993) * Test / Fix formatter test. Related to #7929. * Prettier. * Test / Fix formatter test / Citation common may be embedded in other formatter. Only set xsl:output in the citation entry point. * API / XSL / Use XSL output configuration - formatter update for Java 8 --------- Co-authored-by: François Prunayre <fx.prunayre@gmail.com>
Formatter API was using an XMLOutputter overriding all configuration made in
xsl:output
. This was producing "invalid" HTML and some workaround were used so far.Now, return the output produced by saxon XMLIndenter or HTMLIndenter directly.
A good config for HTML output:
It was only affecting the formatter API using the
XML.getString
which was doing the prettyPrint.For schema plugin maintainer, this change requires to check plugin formatter which may export HTML, XML or Text output. Adjust the
xsl:output
configuration if needed.Also do not force editor API to output XML. It outputs HTML and XML view may contains a properly formatted XML snippet.
Checklist
main
branch, backports managed with labelREADME.md
filespom.xml
dependency management. Update build documentation with intended library use and library tutorials or documentation