Error using custom xslt

I have a system that allows a user to provide their own XSLT to apply to some data that has been extracted, as a means of determining how that data should be presented. However, if the user includes XSLT equivalent code:

<xsl:template match="/">
  <xsl:element name="data">
    <xsl:apply-templates select="." />
  </xsl:element>
</xsl:template>

this causes .NET to infinitely recursively try to process it and generate an error. I need to catch this before it works, when the data that has been retrieved from time to time takes quite a lot of time, and the data is lost when this happens.

Is there any way to do this? I know that it is theoretically possible to identify any occurrences of xsl: apply-templates with "." in the select attribute, but this is not the only way infinite recursion can happen, I need a way to capture it all.

+3
source share
3 answers

You are talking about stopping problems . This is impossible: it is impossible to create an algorithm that can determine whether any program (or, in your case, any XSLT script) will stop or continue to endlessly process its possible inputs.

/ XSLT. , JavaScript, .

, , / , .

+4

"" , -, XSLT. ( Saxon , XSLT 2 ). XSLT script xslt-tranformer ( , IIS/mod_mono). , , XSLT, .

+2

@welbog , !

, " " , , " ". (, ).

.

0

Source: https://habr.com/ru/post/1747991/


All Articles