0
votes

Need to transform XML based on some XSL files using net.sf.saxon.transformerfactoryimpl

XSL file is referring to some extension functions defined in XSL under xmlns sections as

xmlns:rad ="http://mywebsite.com/saxon-extension"

when I execute my code on local machine, everything works fine and there is no error. when the same code is deployed in AWS centos there is no error and the transformed document is not correct. is there any issue with SAXON in AWS, centos do I need to enable some External URL's defined in XSL

Transformer:

 TransformerFactory transformerFactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl",null);
if(transformerFactory instanceof net.sf.saxon.TransformerFactoryImpl)
{
    Configuration configuration =((net.sf.saxon.TransformerFactoryImpl)transformerFactory).getCOnfiguration();
SaxonExtensionFunctionRegistery.registerAll(configuration);
}

registerALL Method:

for (class c:extensionFunction)
{
  try  {
    configuration.registerExtensionFunction((ExtensionFunctionDefination)c.newInstance());

  }
  catch(Exception ex)  {
    log.error("Error registering extension function:",c.getName(),ex);
  }
}

xsl declartion and function:

xmlns:functx="http://www.functx.com" xmlns:rad="http://mywebsite.com/saxon-extension" excluse-result-prefixes="dicom xs rad functx"

<xsl:function name ="dicom:getAccessionNo">
<xsl:param name="dicomNode"/>
<xsl:choose>
<xsl:otherwise>
 <xsl:value-of select="dicom:getElement($dicomNode/attr[@tag='00080050'],rad:getResouce('StudyProcessing','unknownLabel'))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
1
Do you have functions defined in XSLT using xsl:function? Or extension functions implemented in Java? Anyway, consider to add minimal but complete samples of XML, XSLT, Java, result you want and the one you get together with exact details of the Saxon edition and version.Martin Honnen
added XSL and code , please checkNitin Bourai

1 Answers

1
votes

You appear to be different versions of Saxon, so the first thing is to establish which versions you are using. The most reliable way to do this is to add to the stylesheet (at some appropriate point) an instruction like

<xsl:message>Using XSLT processor <xsl:value-of select="system-property('xsl:product-version')"/></xsl:message>

After that, we need more details of the symptoms. You say "there is no error and the transformed document is not correct": that really doesn't give any basis for diagnosis. It's possible, for example, that in one of the cases you are using a version of Saxon that implemented a draft version of one of the XSLT specs that subsequently changed; the devil will be in the detail.

You point the finger at extension functions, but problems with extension functions usually take the form of a fatal error rather than producing incorrect results. However, the precise details of XPath-to-Java data conversions when calling Saxon extension functions have changed over the years, so it's not impossible that this could point to a possible cause of your problems.