Skip to content

Commit

Permalink
Fix bug 4645
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Jul 24, 2020
1 parent 561f17c commit a35007d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 14 additions & 0 deletions latest10/hej/net/sf/saxon/expr/HomogeneityChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

package net.sf.saxon.expr;

import net.sf.saxon.Configuration;
import net.sf.saxon.expr.parser.ContextItemStaticInfo;
import net.sf.saxon.expr.parser.ExpressionTool;
import net.sf.saxon.expr.parser.ExpressionVisitor;
import net.sf.saxon.expr.parser.RebindingMap;
import net.sf.saxon.expr.sort.DocumentSorter;
import net.sf.saxon.om.SequenceIterator;
import net.sf.saxon.pattern.AnyNodeTest;
import net.sf.saxon.pattern.Pattern;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.tree.iter.HomogeneityCheckerIterator;
import net.sf.saxon.type.Affinity;
Expand Down Expand Up @@ -80,6 +82,18 @@ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo con
return this;
}

/**
* Convert this expression to an equivalent XSLT pattern
*
* @param config the Saxon configuration
* @return the equivalent pattern
* @throws net.sf.saxon.trans.XPathException if conversion is not possible
*/
@Override
public Pattern toPattern(Configuration config) throws XPathException {
return getBaseExpression().toPattern(config);
}

/*@NotNull*/
@Override
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException {
Expand Down
14 changes: 12 additions & 2 deletions latest10/hej/net/sf/saxon/expr/SlashExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,18 @@ public Pattern toPattern(Configuration config) throws XPathException {
}
}
if (headPattern == null) {
axis = PatternMaker.getAxisForPathStep(tail);
headPattern = head.toPattern(config);
if (tail instanceof VennExpression) {
Expression lhExpansion = new SlashExpression(
head.copy(new RebindingMap()), ((VennExpression)tail).getLhsExpression());
Expression rhExpansion = new SlashExpression(
head.copy(new RebindingMap()), ((VennExpression) tail).getRhsExpression());
VennExpression topExpansion = new VennExpression(
lhExpansion, ((VennExpression)tail).operator, rhExpansion);
return topExpansion.toPattern(config);
} else {
axis = PatternMaker.getAxisForPathStep(tail);
headPattern = head.toPattern(config);
}
}
return new AncestorQualifiedPattern(tailPattern, headPattern, axis);
}
Expand Down

0 comments on commit a35007d

Please sign in to comment.