Permalink
Browse files

Fix issue #28, make sure static base URI is set in XPath expressions

  • Loading branch information...
ndw committed Jan 29, 2012
1 parent acadc72 commit 3134ac65c754a9fadbbe71ac242ca0e7a3d989a4
@@ -72,6 +72,7 @@ private void readSource() {
try {
NamespaceBinding bindings = new NamespaceBinding(runtime,context);
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(context.getBaseURI());
for (String prefix : bindings.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, bindings.getNamespaceBindings().get(prefix));
}
@@ -256,6 +256,7 @@ public Serializer makeSerializer() {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
// Extension functions are not available here...
for (QName varname : globals.keySet()) {
@@ -168,6 +168,7 @@ public void processAttribute(XdmNode node) throws SaxonApiException {
private String computedLabel(XdmNode node) throws SaxonApiException {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
// Make sure any namespace bindings in-scope for the label are available for the expression
for (String prefix : label.getNamespaceBindings().keySet()) {
@@ -101,6 +101,8 @@ public void run() throws SaxonApiException {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : test.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, test.getNamespaceBindings().get(prefix));
}
@@ -178,6 +178,7 @@ private boolean checkFailedAssert(XdmNode doc) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : nsBindings.keySet()) {
xcomp.declareNamespace(prefix, nsBindings.get(prefix));
@@ -252,6 +252,8 @@ private boolean nextMatches(XdmNode node) {
private XdmItem computeGroup(XdmNode node) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix));
}
@@ -140,6 +140,8 @@ private void runAdjacent() throws SaxonApiException {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (String prefix : groupAdjacent.getNamespaceBindings().keySet()) {
xcomp.declareNamespace(prefix, groupAdjacent.getNamespaceBindings().get(prefix));
}
@@ -571,6 +571,7 @@ protected RuntimeValue computeValue(ComputableValue var) {
} else if (nsbinding.getXPath() != null) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (QName varname : globals.keySet()) {
xcomp.declareVariable(varname);
@@ -741,6 +742,7 @@ protected RuntimeValue computeValue(ComputableValue var) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(step.getNode().getBaseURI());
for (QName varname : boundOpts.keySet()) {
xcomp.declareVariable(varname);
@@ -81,6 +81,8 @@ private void readSource() {
try {
NamespaceBinding bindings = new NamespaceBinding(runtime,context);
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
xcomp.setBaseURI(context.getBaseURI());
IndependentContext icontext = (IndependentContext) xcomp.getUnderlyingStaticContext();
Hashtable<QName, RuntimeValue> inScopeOptions = new Hashtable<QName, RuntimeValue> ();
@@ -176,6 +176,7 @@ private boolean useWhen(XdmNode element, String xpath) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
// FIXME: Static base URI here?
XdmSequenceIterator nsIter = element.axisIterator(Axis.NAMESPACE);
while (nsIter.hasNext()) {

0 comments on commit 3134ac6

Please sign in to comment.