You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Simon Richard Clarsktone <sr...@decisionsoft.co.uk> on 2008/04/09 12:27:41 UTC

Converting XPath object to String

I am using the org.apache.xpath Java package to take in XPath 
expressions in text form from a file, transform them with a 
XPathVisitor, and emitting them again as text.  (This replaces an older 
solution that used regexes and was not flexible enough.)

I have had no difficulty with parsing the input into an XPath object and 
transforming it, but I cannot figure out how to print out the 
transformed XPath (or the Expression inside it).

  *  Using XPath().getPatternString() returned the original string I 
read in, not a string that represented the transformed xpath.
  *  toString() returns the usual Java "ClassName @ location" string.
  *  Writing my own Expression-to-String functions looks daunting, due 
to the large number of classes that it would have to understand.

Is there an existing stringifying method or a stringifying XPathVisitor 
available anywhere?  Or is this a totally unsuitable library for my 
task?  If so, can anyone suggest a suitable replacement?

-- 
src/