StackTrace: org.dom4j.XPathException: Exception occurred evaluting XPath: /StateTable/State[ Name='Tender']/Action[InputEvent=$m]/ProcessFile. Exception: Variable :m at org.dom4j.xpath.DefaultXPath.handleJaxenException(DefaultXPath.java:3 20) at org.dom4j.xpath.DefaultXPath.valueOf(DefaultXPath.java:172) at org.dom4j.tree.AbstractNode.valueOf(AbstractNode.java:193) at com.xslsystems.util.XPathEvaluator.go(XPathEvaluator.java:40) at com.xslsystems.util.XPathEvaluator.main(XPathEvaluator.java:18)
For completeness, here is my complete program: package com.xslsystems.util; import java.io.*; import java.util.*; import org.dom4j.*; import org.dom4j.io.*; import org.dom4j.xpath.*; import org.jaxen.*; public class XPathEvaluator { public static void main(String[] args) { CommandLine cmd = new CommandLine(args); if (cmd.exists("file") && cmd.exists("expr")) { String para = cmd.exists("para") ? cmd.value("para") : ""; (new XPathEvaluator()).go(cmd.value("file"), cmd.value("expr"), para); } else System.out.println( "Useage: XPath - file <xmlFileName> - expr <XPath expression>"); } void go(String fileName, String expr, String para) { try { SAXReader reader = new SAXReader(false); Document doc = reader.read(fileName); XMLWriter out = new XMLWriter(); out.write(doc); XPath xp = doc.createXPath(expr); SimpleVariableContext vc = new SimpleVariableContext(); vc.setVariableValue("m",(Object) para); System.out.println("A " + para); xp.setVariableContext(vc); System.out.println("B "+ xp.getVariableContext().getVariableValue(null,null,"m")); System.out.println(doc.valueOf(xp.getText())); } catch (Exception e) { e.printStackTrace(System.out); } } } and the XML file: <?xml version="1.0" encoding="UTF-8"?> <StateTable> <State> <Name>Sale</Name> <Action> <InputEvent>ItemSale</InputEvent> <ProcessFile>ItemSale.xsl</ProcessFile> </Action> <Action> <InputEvent>Total</InputEvent> <ProcessFile>Total.xsl</ProcessFile> <NextState>Tender</NextState> </Action> <Action> <InputEvent>VoidTransaction</InputEvent> <ProcessFile>VoidTransaction.xsl</ProcessFile> <NextState>Sale</NextState> </Action> </State> <State> <Name>Tender</Name> <Action> <InputEvent>Cash</InputEvent> <ProcessFile>Cash.xsl</ProcessFile> <NextState>Tender</NextState> <NextState>Sale</NextState> </Action> <Action> <InputEvent>VoidTransaction</InputEvent> <ProcessFile>VoidTransaction.xsl</ProcessFile> <NextState>Sale</NextState> </Action> </State> </StateTable> All the jars came from the bdom4j-1.1.zip. I've tried putting the jaxen-core and jaxen-dom4j jars from the Jaxen site ahead in the classpath, but that doesn't change it. Cheers Tony _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest