On 13 Mar 2014, at 19:47, Chriztian Steinmeier wrote:

[…] An alternative way would be to just open a $DIALOG, asking for the XPath expression and then do the processing - but I can't see a $DIALOG command that lets me do that (read input)...

Using the ruby UI wrapper (for DIALOG), such command could take the following form:

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui"

query = TextMate::UI.request_string(:prompt => "XPath Query:")
TextMate.exit_discard if query.to_s.empty?

# output HTML based on stdin and query…

You can mix this with the suggestion by Hans-Jörg, i.e. let the generated HTML include a text field prepopulated with the query string, allowing the user to change the query.

If so, you may want to allow an initial empty query string, for that, change ‘query.to_s.empty?’ → ‘query.nil?’ in the above. This will still allow the user to abort the command (and never see the HTML output window) via the Cancel button (or ⌘,) but if they just press return, the window will appear.