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

MCR-2966 move saxon compatible stylesheets to folder xslt #1964

Merged
merged 29 commits into from
Nov 3, 2023

Conversation

michael-becker
Copy link
Contributor

Link to jira.

The following changes were made:

  • moved all XSL3 stylesheets (ending with -3.xsl) to the xslt folder
  • created a new MCR configuration variable MCR.Layout.Transformer.Factory.XSLFolder=xslt
  • replaced "xsl/"+stylsesheet statements in code with the configuration variable
  • created a new URI resolver for XEditor templates: xslStyleXEditor and used this resolver in the xed
  • created new iview2-solr.xsl in xslt folder and added isFileSupported to MCRIview2URIResolver

Michael Becker added 4 commits September 18, 2023 18:51
move saxon xsls to xslt folder, add configuration variable for default xsl folder
add URI resolver for XEditor XSLs
add xsl to xslt folder
default to xsl3, remove -3 suffixes from configuration
fix class name for XEditor URI resolver
Copy link
Member

@rsteph-de rsteph-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bei den Imports verzichten wir noch beim Pfadanfang auf "/xslt" bzw. "/xsl"?
Auch wenn dadurch Dinge "kaputt" gehen, würde ich das gerne vereinheitlichen.
Die "Magie" sollte noch raus. Außerdem können wir so besser erkennen, ob es sich um alte oder neue Stylesheets handelt.

@@ -5,9 +5,9 @@
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:mcrsolr="http://www.mycore.de/xslt/solr">

<xsl:import href="xslImport:solr-document-3:solr/indexing/mycoreobject-dynamicfields-3.xsl" />
<xsl:import href="xslImport:solr-document:solr/indexing/mycoreobject-dynamicfields.xsl" />
Copy link
Member

@rsteph-de rsteph-de Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the path should also start with /xsl or /xslt to distinguish version 1 and version 3 XSL templates.
Or does that break to much existing code?

Copy link
Contributor Author

@michael-becker michael-becker Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we cann not use resource:xslt/ in xslImport, since the respective URI resolver always adds a resource: on its own (https://github.com/MyCoRe-Org/mycore/blob/issues/MCR-2966-xslt-folder/mycore-base/src/main/java/org/mycore/common/xml/MCRURIResolver.java#L1400)

MCR.URIResolver.xslIncludes.xeditorTemplates=%MCR.URIResolver.xslIncludes.xeditorTemplates%,solr-xeditor-templates.xsl
MCR.URIResolver.xslIncludes.xeditorTemplates-3=%MCR.URIResolver.xslIncludes.xeditorTemplates-3%,solr/xeditor/solr-xeditor-templates-3.xsl
MCR.URIResolver.xslImports.solr-document=%MCR.URIResolver.xslImports.solr-document%,solr/indexing/mycoreobject-dynamicfields.xsl
MCR.URIResolver.xslIncludes.xeditorTemplates=%MCR.URIResolver.xslIncludes.xeditorTemplates%,solr/xeditor/solr-xeditor-templates.xsl
Copy link
Member

@rsteph-de rsteph-de Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the path should also start with /xsl or /xslt to distinguish version 1 and version 3 XSL templates.
Or does that break to much existing code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as abvoe: xlsImport does not allow for adding resource:xsl/ or /xslt/ in the beginning. I would suggest to adapt these references in a separate PR after we added this.

@michael-becker
Copy link
Contributor Author

Bei den Imports verzichten wir noch beim Pfadanfang auf "/xslt" bzw. "/xsl"? Auch wenn dadurch Dinge "kaputt" gehen, würde ich das gerne vereinheitlichen. Die "Magie" sollte noch raus. Außerdem können wir so besser erkennen, ob es sich um alte oder neue Stylesheets handelt.

Ja wäre ich auch dafür. Das haben wir momentan noch raus gelassen, um den Umstieg etwas sanfter zu machen. Nehmen wir die vollständige Angabe mit resource:xslt/... müssen in allen Anwendungen, die 2023 und XSL1 verwenden, noch mehr an der Konfiguration angepasst werden als ohnehin schon - siehe die Mail, du warst zu schnell ;)

@toKrause toKrause changed the title mcr-2966 move saxon compatible stylesheets to folder xslt MCR-2966 move saxon compatible stylesheets to folder xslt Sep 21, 2023
Michael Becker added 2 commits September 26, 2023 09:18
use folder from configuration, use full resource statement for xeditor XSL
process new xslImport mechanism
final String baseURI = getParentDirectoryResourceURI(base);
// set xslt folder
final String xslFolder;
if (StringUtils.contains(baseURI, "/xsl/")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseURI.startswith would work more secure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, getParentDirectoryResourceURI always returns a string starting with resource (https://github.com/MyCoRe-Org/mycore/blob/2022.06.x/mycore-base/src/main/java/org/mycore/common/xml/MCRURIResolver.java#L293)
e.g.:
base: jar:file:/home/musiclpz/production/build/webapps/WEB-INF/lib/mycore-solr-2023.08-SNAPSHOT.jar!/xslt/solr/indexing/mycoreobject-dynamicfields.xsl
baseuri: resource:xslt/solr/indexing/

so startsWith resource:xsl/ should be feasible.

However, in some edge cases getParentDirectoryResourceURI returns the given base. In these cases, this would not work. But I am not totally aware if in these cases something else goes wrong. If we can ignore these edge cases, we can test on startsWith resource:xsl/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, getParentDirectoryResourceURI always returns a string starting with resource (https://github.com/MyCoRe-Org/mycore/blob/2022.06.x/mycore-base/src/main/java/org/mycore/common/xml/MCRURIResolver.java#L293)
e.g.:
base: jar:file:/home/musiclpz/production/build/webapps/WEB-INF/lib/mycore-solr-2023.08-SNAPSHOT.jar!/xslt/solr/indexing/mycoreobject-dynamicfields.xsl
baseuri: resource:xslt/solr/indexing/

Yes you are right.

However, in some edge cases getParentDirectoryResourceURI returns the given base. In these cases, this would not work. But I am not totally aware if in these cases something else goes wrong. If we can ignore these edge cases, we can test on startsWith resource:xsl/

I think in the edge cases the property should be used. So check for startsWith resource:xsl/ or resource:xslt/ and if both false than use the property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to startsWith resource:xsl/ / resource:xslt/

I had to rollback the changes in nextImportStep, since it produced errors when using the proposed new xslImport syntax (without selfname). This resulted in errors because xsl:import href="xslImport:xxx" was included more than once and ultimately failed with a stylesheet including itself. I was not able to fix this and, thus. would suggest to postpone the syntax change to a later point.


importXSL = MCRXMLFunctions.nextImportStep(importPart);
} else {
final String selfName = StringUtils.substringAfter(baseURI, xslFolder + "/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe more secure to use baseURI.substring(xslFolder.length+1)

Michael Becker added 2 commits September 28, 2023 15:20
use startsWith for evaluating folder, fallback via configuration; reverse xmlfunctions:nextImportStep
remove test for new xslimport mechanism
@michael-becker michael-becker marked this pull request as ready for review September 29, 2023 09:08
@michael-becker
Copy link
Contributor Author

michael-becker commented Oct 4, 2023

Falls weiterhin XSLT-1 verwendet werden soll, sind folgende Anpassungen an der Konfiguration vorzunehmen:

  • Für alle Anwendungen

    • MCR.Layout.Transformer.Factory.XSLFolder=xsl
    • MCR.LayoutService.TransformerFactoryClass=org.apache.xalan.processor.TransformerFactoryImpl
  • Anwendungen, die mycore-solr nutzen

    • MCR.URIResolver.xslImports.solr-document=solr-basetemplate.xsl
    • MCR.URIResolver.xslImports.solr-document=%MCR.URIResolver.xslImports.solr-document%,mycoreobject-dynamicfields.xsl
    • MCR.URIResolver.xslIncludes.components=%MCR.URIResolver.xslIncludes.components%,solr-layout-utils.xsl
    • MCR.ContentTransformer.response.TransformerFactoryClass=org.apache.xalan.processor.TransformerFactoryImpl
    • MCR.ContentTransformer.response.Stylesheet=%MCR.ContentTransformer.response-prepared.Stylesheet%,xsl/response.xsl
    • MCR.ContentTransformer.response-browse.Stylesheet=xsl/response-browse.xsl
    • MCR.ContentTransformer.mycoreobject-solrdocument.Class=org.mycore.common.content.transformer.MCRXSL2JAXBTransformer
    • MCR.ContentTransformer.mycoreobject-solrdocument.TransformerFactoryClass=org.apache.xalan.processor.TransformerFactoryImpl
    • MCR.ContentTransformer.mycoreobject-solrdocument.Stylesheet=xsl/mycoreobject-solrdocument.xsl
    • MCR.ContentTransformer.mycoreobject-solrdocument.Context=org.mycore.solr.index.document.jaxb
    • MCR.ContentTransformer.response-solrdocument.Class=org.mycore.common.content.transformer.MCRXSL2JAXBTransformer
    • MCR.ContentTransformer.response-solrdocument.TransformerFactoryClass=org.apache.xalan.processor.TransformerFactoryImpl
    • MCR.ContentTransformer.response-solrdocument.Stylesheet=xsl/response2batch.xsl,%MCR.ContentTransformer.mycoreobject-solrdocument.Stylesheet%
    • MCR.ContentTransformer.response-solrdocument.Context=%MCR.ContentTransformer.mycoreobject-solrdocument.Context%
    • MCR.ContentTransformer.response-prepared.Class=org.mycore.common.content.transformer.MCRXSLTransformer
    • MCR.ContentTransformer.response-prepared.TransformerFactoryClass=org.apache.xalan.processor.TransformerFactoryImpl
    • MCR.ContentTransformer.response-prepared.Stylesheet=xsl/response-join-results.xsl,xsl/response-addDocId.xsl,xsl/response-addDerivates.xsl
    • MCR.URIResolver.xslIncludes.xeditorTemplates=solr-xeditor-templates.xsl
  • Anwendungen, die mycore-mods nutzen

    • MCR.URIResolver.xslImports.solr-document=%MCR.URIResolver.xslImports.solr-document%,mods-solr.xsl

Anwendungen, die schon auf XSLT3 umgestellt sind, brauchen folgende Einträge:

  • MCR.LayoutService.TransformerFactoryClass=net.sf.saxon.TransformerFactoryImpl
  • MCR.URIResolver.xslIncludes.xeditorTemplates=resource:xsl/solr-xeditor-templates.xsl

Michael Becker added 13 commits October 4, 2023 15:53
move saxon xsls to xslt folder, add configuration variable for default xsl folder
add URI resolver for XEditor XSLs
add xsl to xslt folder
default to xsl3, remove -3 suffixes from configuration
fix class name for XEditor URI resolver
use folder from configuration, use full resource statement for xeditor XSL
process new xslImport mechanism
use startsWith for evaluating folder, fallback via configuration; reverse xmlfunctions:nextImportStep
remove test for new xslimport mechanism
…folder

# Conflicts:
#	mycore-base/src/test/java/org/mycore/common/xml/MCRURIResolverTest.java
fix code style
Copy link
Member

@yagee-de yagee-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works with MIR branch MyCoRe-Org/mir#913

@yagee-de yagee-de changed the base branch from main to 2023.06.x November 3, 2023 09:25
@yagee-de yagee-de merged commit d797e1a into 2023.06.x Nov 3, 2023
3 checks passed
@yagee-de yagee-de deleted the issues/MCR-2966-xslt-folder branch November 3, 2023 14:12
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Nov 16, 2023
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Nov 16, 2023
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Nov 16, 2023
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Nov 16, 2023
sebhofmann added a commit that referenced this pull request Nov 23, 2023
* 2023.06.x:
  MCR-2647 hibernate 6 jpa 3.1 (#1587)
  MCR-2959 fix property guid xslt directory
  MCR-2964 [jobqueue] update yarn dependencies
  MCR-2966 move saxon compatible stylesheets to folder xslt (#1964)
  MCR-2990 Added support of <xinclude @uri="..."/> element. (#1988)
  MCR-2993 Fixed NullPointerException
  MCR-2995 always return Source with systemId (#1995)
  MCR-2998 add save-xsl to xslt folder (#1997)
  MCR-3000 fix exception in MCRACLResolver on factbased access system (#2000)
  MCR-3002 Fix Javadoc for log4j2 (#2008)  MCR-2995 always return Source with systemId (#1995)
  MCR-3002 fix log4j2 javadoc URL
  MCR-3003 jobs in queue do not trigger onCommitTasks
  Revert "MCR-3002 fix log4j2 javadoc URL"
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jan 3, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jan 10, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Feb 5, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Mar 5, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Mar 13, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Apr 5, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Apr 22, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request May 29, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jun 6, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jun 21, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jul 9, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jul 17, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Jul 29, 2024
Possommi added a commit to MyCoRe-Org/ubo that referenced this pull request Aug 14, 2024
kkrebs added a commit to MyCoRe-Org/ubo that referenced this pull request Aug 23, 2024
* UBO-283 Set mycore version to 2022.06.3-SNAPSHOT

* UBO-283 Fixed compile errors

* UBO-283 Removed deprecated api invocation

* UBO-283 Replaced deprecated StringUtils.getLevenshteinDistance() with LevenshteinDistance.getDefaultInstance().apply(normalizeTitle(titleFromAleph), normalizeTitle(titleFromBibEntry)).intValue()

* UBO-283 Moved basket2solradd.xsl and solr2csv.xsl to /xslt. Set TransformerFactoryClass for xslt 1 stylesheets

* UBO-283 Include variable $User-Agent in html-layout.xsl to avoid blank landing page

* UBO-283 Added configuration as mentioned in MyCoRe-Org/mycore#1964 (comment)

* UBO-283 Added mapping files in persistence.xml

* UBO-283 Curly braces must now be encoded in json.facet

* UBO-283 Improved readability of added properties

* UBO-291 Use h2 for testing

* UBO-291 Set mycore version to 2023.06.1-SNAPSHOT

* UBO-291 Sort poms

* UBO-291 Added sort pom plugin

* UBO-291 Removed property "<property name="hibernate.dialect" value=" org.hibernate.dialect.H2Dialect"/>" from persistence.xml

* UBO-291 Fixed persistence.xml

* UBO-291 Set mycore version to 2023.06.2-SNAPSHOT

* UBO-283 Fixed compile error and sort pom.xml

* UBO-283 Migrated to MCRJobQueue to MCRJobQueueManager

* UBO-283 Set mycore version to 2023.06.03-SNAPSHOT

* UBO-283 Updated ImportListJobAction to mycore version 2023.06.x

* UBO-283 delete obsolete language classification, update versions and

installation documentation

---------

Co-authored-by: Kathleen Neumann <[email protected]>
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.

4 participants