Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions vendor/xpath-tests/filters
Original file line number Diff line number Diff line change
Expand Up @@ -1991,11 +1991,6 @@ K2-NodeTest-19
= prod-PathExpr
= prod-PositionalVar
= prod-Predicate
K-FilterExpr-38
K-FilterExpr-40
K-FilterExpr-92
K-FilterExpr-93
K-FilterExpr-94
= prod-QuantifiedExpr
= prod-ReturnClause
= prod-SchemaImport
Expand Down
24 changes: 12 additions & 12 deletions xee-interpreter/src/interpreter/interpret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,13 @@ impl<'a> Interpreter<'a> {

fn pop_is_numeric(&mut self) -> error::Result<bool> {
let value = self.state.pop()?;
let a = value.atomized_option(self.state.xot())?;
if let Some(a) = a {
Ok(a.is_numeric())
} else {
Ok(false)
// Only a single atomized value can be numeric; an empty or multi-item
// sequence is not numeric (and must not error — the caller falls back
// to EBV for those).
let mut atomized = value.atomized(self.state.xot());
match (atomized.next(), atomized.next()) {
(Some(only), None) => Ok(only?.is_numeric()),
_ => Ok(false),
}
}

Expand Down Expand Up @@ -1130,13 +1132,11 @@ impl<'a> Interpreter<'a> {
"Appending a whole document is not supported yet",
)));
}
xot::Value::Text(text) => {
// zero length text nodes are skipped
// Can this even exist, or does Xot not have
// them anyway?
if text.get().is_empty() {
continue;
}
// zero length text nodes are skipped
// Can this even exist, or does Xot not have
// them anyway?
xot::Value::Text(text) if text.get().is_empty() => {
continue;
}
_ => {}
}
Expand Down
4 changes: 2 additions & 2 deletions xee-interpreter/src/library/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn find_helper(
function::Function::Array(array) => {
for entry in array.iter() {
let found = find_helper(entry, key.clone())?;
result.extend(found.into_iter())
result.extend(found)
}
}
function::Function::Map(map) => {
Expand All @@ -171,7 +171,7 @@ fn find_helper(
result.push(v.clone());
}
let found = find_helper(v, key.clone())?;
result.extend(found.into_iter())
result.extend(found)
}
}
_ => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expression: "run(\"(1, 2, 3)[(2, 3)]\")"
---
Err(
SpannedError {
error: XPTY0004,
error: FORG0006,
span: Some(
SourceSpan(
10,
Expand Down
17 changes: 17 additions & 0 deletions xee-xpath/tests/xpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,23 @@ fn test_sequence_predicate_sequence_empty() {
assert_debug_snapshot!(run("(1, 2, 3)[()]"));
}

#[test]
fn test_node_predicate_with_multiple_children() -> error::Result<()> {
// Regression: `a[b]` must match even when an `<a>` has multiple `<b>`
// children. The inner sequence should be treated as a node sequence and
// evaluated via EBV, not rejected by the numeric-predicate probe.
assert_nodes(
r#"<root><a><b>1</b></a><a><b>2</b><b>3</b></a></root>"#,
"//a[b]",
|xot, root| {
let root_el = xot.document_element(root).unwrap();
let a1 = xot.first_child(root_el).unwrap();
let a2 = xot.next_sibling(a1).unwrap();
vec![a1, a2]
},
)
}

#[test]
fn test_child_axis_step1() -> error::Result<()> {
assert_nodes(r#"<doc><a/><b/></doc>"#, "doc/*", |xot, root| {
Expand Down
9 changes: 4 additions & 5 deletions xee-xslt-ast/src/whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ pub(crate) fn strip_whitespace(xot: &mut Xot, names: &Names, node: Node) {
for edge in xot.traverse(node) {
match edge {
NodeEdge::Start(node) => match xot.value(node) {
Value::Text(text) => {
Value::Text(text)
if is_xml_whitespace(text.get())
&& !is_xml_space_preserve(xot, names, node, &xml_space_preserve)
{
to_remove.push(node);
}
&& !is_xml_space_preserve(xot, names, node, &xml_space_preserve) =>
{
to_remove.push(node);
}
Value::Element(_) => {
if let Some(xml_space) = xot.attributes(node).get(xot.xml_space_name()) {
Expand Down