|
Blogs
In this weblog I show you a program that scans XSLT programs and Simple Transformations for certain commands. I present you a simple use case: In NW 7.02 Simple Transformations can call ABAP classes by the tt:call-method command. But how does it work? With this program you can scan existing transformations for examples. This is the input: All XSLT and ST programs are scanned for an element tt:call-method – this is an element call-method in an XML namespace http://www.sap.com/transformation-templates . The output is as follows: In fact there are ST programs that contain the command like DEMO_ST_WITH_METHOD_CALL. There are also programs that have syntax errors like SEC_WSSP_POLICY2 which contain severe errors. IMHO SAP should use the program to ensure the quality of transformation in their software. How does the program work? At first the transformations are selected and loaded using the class cl_o2_api_xsltdesc. Then the XSLT program zscan_transformation is used to scan the program – the result is a boolean flag. Then the result is given out resp. the message that an error occurs: REPORT zscan_transformation. How does the transformation ZSCAN_TRANSFORMATION work? It is an XSLT program that gets an XML document (in fact the code of an XSLT or ST program) as input together with two parameters: a name of an XML element and a namespace (in fact an URI). The result is a boolean flag given back in asXML format - the typical way to bridge the gap between XML and ABAP. The result is X if and only if the number of elements of given name and namespace is greater than zero, i.e. there is at least one element. This is evaluated in an XPath expression in the following transformation: <xsl:transform xmlns:xsl=http://www.w3.org/1999/XSL/Transform Why is this useful? You can find examples for ST commands (ST is a proprietary language) and SAP proprietary XSLT commands. A list of those commands (and of course an explanation together with details) can be found in my SAP Press book about XML in ABAP. As an easy exercise I suggest you to write a program that scans for XPath functions which are within certain attributes of an XSLT program. You can also write programs that scan comments or other parts of the transformation which can be useful maintenance of transformations. Tobias Trapp
| |||||||||||||||||||||||