Project

Profile

Help

Feature #5213

closed

Ability to specify the output mode of xsl:message

Added by Andy Yar over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2022-01-19
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

Hello, we have arrived to a very specific requirement of emitting a structured data during termination of a XSLT transformation. In other words, we would like to easily parse error output of terminated transformation.

We use classic construction of:

<xsl:message terminate="yes">

As the output we use a text anchor followed with serialized JSON:

      <xsl:message terminate="yes">
            <xsl:variable name="json">
                <fn:map>
                    <fn:string key="ErrorReport">
                        <xsl:value-of select="'ERROR'"/>
                    </fn:string>
                    <fn:string key="PartnerName">
                        <xsl:value-of select="'Mac &amp; Cheese'"/>
                    </fn:string>
                </fn:map>
            </xsl:variable>
            <xsl:sequence select="fn:concat('ERROR REPORT: ', fn:xml-to-json($json))"/>
        </xsl:message>

Sadly, this construction can't handle JSON output of XML entities correctly. For example, XML '&' doesn't get transformed to JSON '&'. The xsl:assert behaves similarly.

The spec says the body of those construct is a sequence constructor. Is there a way to treat the output as text?

Please register to edit this issue

Also available in: Atom PDF