Skip to content

Commit

Permalink
Added support for ForExpression; #173
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jul 24, 2024
1 parent bcd8188 commit 8ffae7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.sf.saxon.expr.ContextItemExpression;
import net.sf.saxon.expr.Expression;
import net.sf.saxon.expr.FirstItemExpression;
import net.sf.saxon.expr.ForExpression;
import net.sf.saxon.expr.GeneralComparison;
import net.sf.saxon.expr.Literal;
import net.sf.saxon.expr.SlashExpression;
Expand Down Expand Up @@ -192,6 +193,11 @@ private static QName _findReturnType (@Nonnull final Expression expr)
// skip this
return null;
}
if (expr instanceof ForExpression)
{
final ItemType aItemType = ((ForExpression) expr).getItemType ();
return _findReturnType (aItemType);
}

LOGGER.warn ("Unknown Saxon expression type: " + expr.getClass ().getName ());
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<let name="listVar" value="(1,2,3)"/>
<let name="nodeVar" value="."/>
<let name="nodeSetVar" value="//owner"/>
<let name="forVar" value="for $i in //owner[@id = 'o2']/@id return //car[@owner = $i]/@id"/>
<assert role="ERROR" test="$stringVar = 'bar'">error message</assert>
<assert role="ERROR" test="$stringVar2 = 'bar'">error message</assert>
<assert role="ERROR" test="$booleanVar = false()">error message</assert>
Expand All @@ -19,6 +20,7 @@
<assert role="ERROR" test="$listVar = (1, 2)">error message</assert>
<assert role="ERROR" test="$nodeVar = ..">error message</assert>
<assert role="ERROR" test="$nodeSetVar = ../owner">error message</assert>
<assert role="ERROR" test="$forVar = //car/@id">error message</assert>
</rule>
</pattern>
</schema>

0 comments on commit 8ffae7c

Please sign in to comment.