[ 
https://issues.apache.org/jira/browse/NIFI-6498?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17649493#comment-17649493
 ] 

Daniel Stieglitz commented on NIFI-6498:
----------------------------------------

[~exceptionfactory] I have submitted a patch to address the issues brought in 
this ticket. There are parts I adapted from the attached patch file but there 
are parts I did not include and there are parts I needed to add.  I will detail 
below the pieces needed to address the ticket and what parts were adapted from 
the patch file and what had to be added.

There were three parts needed in order to redirect error messages to a log:
 # Setting an instance of javax.xml.transform.ErrorListener on the 
javax.xml.transform.TransformerFactory to handle error messages caused by 
processing the instructions in the XSLT file.
 # Setting an instance of javax.xml.transform.ErrorListener on the 
javax.xml.transform.Transformer to handle error messages from the transform 
itself.
 # Creating a means to log messages emitted from <xsl:message>.

The attached patch file had parts 1 and 3 but not 2. Without 2 if there were 
parsing errors in the actual XML file then those errors would be printed to the 
nifi-bootstrap.log. An example of that could be seen in output from unit test 
testNonXmlContent.

Without 1, then any messages caused by processing the instructions in the XSLT 
file are printed to the nifi-bootstrap.log. Examples of these can be seen in 
output from unit tests:
 * testNonXmlContent
 * testTransformWithControllerNoCache
 * testTransformNoCache
 * testTransformMath
 * testTransformExpressionLanguage
 * testTransformWithController
 * testNonMatchingTemplateTag

Without 3, any message  emitted from <xsl:message> is printed to the 
nifi-bootstrap.log. Examples of this can be seen in the output from unit tests 
testMessageTerminate and testMessageNonTerminate.

I have not included from the patch file  "the possibility to set binary Saxon 
properties like "http://saxon.sf.net/feature/allow-external-functions"; from the 
processor's properties" as that does not directly address the issue in this 
ticket of redirecting error messages to a  log.

> XMLTransform processor: XSLT doesn't give detail error message with line 
> number
> -------------------------------------------------------------------------------
>
>                 Key: NIFI-6498
>                 URL: https://issues.apache.org/jira/browse/NIFI-6498
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Core Framework
>    Affects Versions: 1.10.0, 1.9.2
>            Reporter: Raymond
>            Assignee: Daniel Stieglitz
>            Priority: Major
>         Attachments: 
> 0001-Add-support-for-Saxon-error-messages-and-functions.patch, 
> 0001-Add-support-for-Saxon-error-messages-and-functions.patch
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When something is wrong with the XSLT in the XMLTransform processor you get 
> an error, but this is only a general error without any details or the line 
> number where the parsing error occurs. For example when using Saxon from 
> example I get the following error:
> Error on line 17 column 5 SXXP0003: Error reported by XML parser: The element 
> type "xsl:tomplate" must be terminated by the matching end-tag 
> "</xsl:tomplate>".
> When using NiFi the following error is printed:
> 11:07:43 CEST
> ERROR
> 2b4c1dab-3a87-175f-f817-3f3c72af4102
> TransformXml[id=2b4c1dab-3a87-175f-f817-3f3c72af4102] Unable to transform 
> StandardFlowFileRecord[uuid=c4dde8e5-89b0-4f29-8f2d-a97a009cf843,claim=StandardContentClaim
>  [resourceClaim=StandardResourceClaim[id=1564391260760-1, container=default, 
> section=1], offset=0, 
> length=6380],offset=0,name=c4dde8e5-89b0-4f29-8f2d-a97a009cf843,size=6380] 
> due to IOException thrown from 
> TransformXml[id=2b4c1dab-3a87-175f-f817-3f3c72af4102]: java.io.IOException: 
> java.util.concurrent.ExecutionException: 
> javax.xml.transform.TransformerConfigurationException: 
> net.sf.saxon.s9api.SaxonApiException: Stylesheet compilation failed: 1 error 
> reported: org.apache.nifi.processor.exception.ProcessException: IOException 
> thrown from TransformXml[id=2b4c1dab-3a87-175f-f817-3f3c72af4102]: 
> java.io.IOException: java.util.concurrent.ExecutionException: 
> javax.xml.transform.TransformerConfigurationException: 
> net.sf.saxon.s9api.SaxonApiException: Stylesheet compilation failed: 1 error 
> reported
> The error in NiFi gives almost no information for debugging. Would be a big 
> improvement if the Saxon error message is catched and add to the NiFi error 
> message (bulletin board).
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to