Esri / geoportal-server

Geoportal Server is a standards-based, open source product that enables discovery and use of geospatial resources including data and services.
https://gptogc.esri.com/geoportal
Apache License 2.0
244 stars 149 forks source link

Unable to transform document #123

Closed smrgeoinfo closed 9 years ago

smrgeoinfo commented 9 years ago

I'm setting up a configuration to transform FGDC CSDGM metadata to ISO19115/19139 USGIN profile, and have reworked the NOAA CSDGM to ISO xslt to use XSLT v1.0 so it should work with Geoportal. The xslt is on gitHUB at https://github.com/usgin/usgin-geoportal-specs/blob/master/fgdc/csdgm-to-iso19115_USGIN_xslt1.xslt. I set up the schemas.xml to look at the definition file with: <interrogation count="count(/metadata/idinfo)" toKnownSchemaXslt="gpt/metadata/fgdc/csdgm-to-iso19115_USGIN.xslt"/>, and upload a CSDGM xml record, getting this error: Unable to transform document with: gpt/metadata/fgdc/csdgm-to-iso19115_USGIN.xslt In the logs it looks like geoportal can't create a template from the file. The xslt validates and works using Oxygen xml editor set for XPath 1.0 and xalan xslt validation, and says version 1.0 in the xslt root element. How can I figure out why the transform isn't working?

mhogeweg commented 9 years ago

hi Steve, it appears several XSLT 2.0 functions are still in use, like fn:exists. I suggest replacing "fn:exists(xpath)" with "count(xpath)>0" and also look at other functions. I get the error in XMLSpy already when applying the xslt to an fgdc doc.

smrgeoinfo commented 9 years ago

Dang! I thought Oxygen would catch all those with the xslt version=1.0 in the header. Thanks, I'll comb through it again.

mhogeweg commented 9 years ago

at some point I want us to switch to xslt 2.0. do you know of a good java implementation?

smrgeoinfo commented 9 years ago

not right off hand--we haven't been doing any Java programming. What about Saxon? http://saxon.sourceforge.net/

smrgeoinfo commented 9 years ago

I converted the exists to count>0 function calls, but run into problems with testing nodes vs. tree-fragments, apparently a common problem with XSLT 1.0. Requires some deeper re-engineering to work around. I also had replace(), upper-case() and lower-case() calls, which are not consistent with xslt1.0 (I was using them from an xpath namespace). More to do still. Hasn't anyone already gotten a good xslt1.0 transform from CSDGM to ISO?

smrgeoinfo commented 9 years ago

OK, I found some more XLST2.0 relicts and cleaned up a lot of TreeFragment problems (count()>0 doesn't work to test existence, switch to using string-length()>0). The transfrom actually ran on one test record, but the topicCategoryCode had a problem. I fixed that, and now the xslt won't compile, and the log message are useless: Caused by: javax.xml.transform.TransformerConfigurationException: Could not load the translet class 'csdgm_to_iso19115_USGIN_xslt1'. at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.defineTransletClasses(TemplatesImpl.java:347) at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.getTransletInstance(TemplatesImpl.java:365) at com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:398)

The xslt runs fine with Xalan engine on Oxygen...

The xslt is still on github https://github.com/usgin/usgin-geoportal-specs/blob/master/fgdc/csdgm-to-iso19115_USGIN_xslt1.xslt. Any ideas?

mhogeweg commented 9 years ago

I downloaded this XSLT and configured it in my geoportal and it actually uploaded an FGDC doc and translated to ISO! No changes to the xslt processor in Geoportal Server.

Snippet from my FGDC defnition:

  <!-- schema interrogation -->
  <interrogation count="count(/metadata/idinfo/citation/*[name()='citeinfo'])"
  toKnownSchemaXslt="gpt/metadata/fgdc/csdgm-to-iso19115_USGIN_xslt1.xslt" />

the xslt is in the same folder as the fgdc-definition.xml.

smrgeoinfo commented 9 years ago

that's good news-- I was at my wit's end trying to figure out the problem with the xslt. I'll try it on a couple of our other geoportal installs.