[xslt2] error внутри variable
То есть получается, что exception хранится в переменной и если мы не сделаем что-нибудь изМожет я не в тему, но погуглив "xslt lazy evaluation", нашёл в частности вот такое:
<xsl:value-of select="$x"/>, <xsl:copy-of select="$x"/> или <xsl:message select="$x"/>, то преобразование благополучно закончится.
Lazy evaluation. With a functional language such as XSLT, the only result of a variable declaration is that the variable now exists; no side effects are possible or allowed. This allows the XSLT processor to optimize stylesheet execution by declaring the variable only when — and if — necessary. This feature is called lazy evaluation, but not all XSLT processors behave that way; one of the "lazy" processors is Saxon.
Lazy evaluation means that if, for example, your xsl:variable declaration contains a debugging output (xsl:message) or a document creation instruction (xsl:result-document neither will ever get control if its parent variable is not used. And the variable may remain unused simply because none of the templates that reference it are triggered by the current source document.
Вопрос: как можно остановить преобразование внутри функции?А как ты себе представляешь остановку преобразования?
In cases where an implementation is able to produce the final result trees without evaluating a particular construct, the implementation is never required to evaluate that construct solely in order to determine whether doing so causes a dynamic error. For example, if a variable is declared but never referenced, an implementation may choose whether or not to evaluate the variable declaration, which means that if evaluating the variable declaration causes a dynamic error, some implementations will signal this error and others will not.
Может я не в тему, но погуглив "xslt lazy evaluation", нашёл в частности вот такое:очень даже в тему, спасибо
А как ты себе представляешь остановку преобразования?хотелось написать что-то типа:
<xsl:template match="XXX">
....
<xsl:variable name="x" select="f:getX($y)"/>
....
</xsl:template>
<xsl:function name="f:getX">
<xsl:param name="y"/>
<xsl:variabble name="tmp" select="f:checkPar($y)"/>
.....
</xsl:function>
<xsl:function name="f:checkPar">
<xsl:param name="y"/>
<xsl:variabble name="tmp" select="if (not($y f:runError"/>
</xsl:function>
<xsl:function name="f:runError">
<xsl:message select="error(collection'Err_Info')"/>
</xsl:function>
Остановить хотел вот так: <xsl:message select="error(collection'Err_Info')"/>
Оставить комментарий
puzelena
Saxon8.6Такой код обрабатывается без ошибок
Такой все-таки выдаст runtime error и преобразование остановится
То есть получается, что exception хранится в переменной и если мы не сделаем что-нибудь из
<xsl:value-of select="$x"/>, <xsl:copy-of select="$x"/> или <xsl:message select="$x"/>, то преобразование благополучно закончится.
Хочется написать функцию проверки параметов, котрая если-что не так останавливает преобразование.
Вопрос: как можно остановить преобразование внутри функции?