I am working on a project which requires working with XPath (on HTML). The (multiple) XPath is transferred to client-side inside JavaScript. Since XPath strings are long, I was wondering if there is a shorter representation which is equivalent to XPath? Perhaps one which works sort of like huffman encoding but specific to XPath.
Here are some implementations of a few compression algorithms in JS: http://stackoverflow.com/questions/294297/javascript-implementation-of-gzip
If you're just worried about sending the XPath text from the server to the client, most browsers support Accept-Encoding: gzip
http://developer.yahoo.net/blog/archives/2007/07/high%5Fperformanc%5F3.html
You could do a mapping from element names to shorter alias names
like //myelement/myotherelement[@myattribute=1234]
could be mapped to //1/2[@3=1234]
You could transfer the mapping table once to the client and then it can translate these shorter xpath expressions.
A question is, do you really need an xpath for every elements? Are there common criteria? Could you transfer the criteria to the client and the client then creates an xpath from that?