Re: [xsl] Re: How to handle dynamic XPath

Subject: Re: [xsl] Re: How to handle dynamic XPath
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Tue, 14 Apr 2009 21:30:30 +0530
Hi Dimitre,

On Mon, Apr 13, 2009 at 7:20 PM, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> Another major use of an XPath 2.0 parser could be in a refactoring
> tool, and also adding to Mukuls Lint the so needed XPath expression
> analysis.

Actually analyzing the code quality of XPath expressions was not any
of goals of my project
(http://gandhimukul.tripod.com/xslt/xslquality.html).

My goal was to only analyze XML oriented quality of XSLT code.

I would be interested to know your notion of XPath code quality. Can
you please suggest some code quality rules for XPath? I would be
interested to enhance my utility for XPath code quality as well. If
the XPath parser you have written can help to enhance my utility, I
would be keen to use your parsing framework.

I express the XSLT code quality rule as, for e.g.,

<xpath>
    //(@match | @select)[starts-with(., '//')]
</xpath>

This rule is a XPath expression. Can you think of a simple way to
express XPath code quality rules (perhaps in XPath/XML format)?

One way I can think is, your parsing framework can build a AST for
XPath fragments (in user's XSLT stylesheets). Then we could serialize
this AST to XML (which will actually be an XML representation of XPath
expression to be analyzed). This XML serialized AST can be an input to
the XPath code quality rules. In this way, we can express the XPath
code quality rules like the one above.

Does your parser support building AST for an XPath expression? If yes,
can we serialize the AST to an XML format? Also can all this be done
in pure XSLT? Or we would have to use another programming language for
AST generation, and it's XML serialization?

Or can you give a better idea.


-- 
Regards,
Mukul Gandhi

Current Thread