Search code examples
xpathxqueryschematron

Is there any XQuery code out there to translate an XPath expression to something business people can understand?


I am working on an XQuery script that takes the context of the Schematron rule and the body of the assert to generate a report as an excel spreadsheet.

It is so that what the Schematron validates actually meets the business requirements.

Does anyone have an XPath to business English translator?


Solution

  • I was looking for something like:

    declare function local:parse-xpath($xpath as xs:string) as xs:string
    {
    fn:normalize-space(
       fn:replace(
           fn:replace(
               fn:replace(
                   fn:replace(
                       fn:replace(
                           fn:replace(
                               fn:replace(
                                   fn:replace(
                                       fn:replace(
                                           $xpath,
                                           '\[not\(\*\)\]',
                                           ' with no child elements '
                                       ),
                                       'not\(\*\)',
                                       ' there are no child elements '
                                   ),
                                   '\*',
                                   ' any element '
                               ),
                               '\.',
                               ' this element '
                           ),
                           '@',
                           ' attribute '
                       ),
                       '\]\[',
                       ' and '
                   ),
                   '\[',
                   ' where '
               ),
               '\]',
               ' '
           ),
           '//',
           ' any depth where '
       )
    )
    };