Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse axes should follow reverse document order #177

Open
sadiqkhoja opened this issue Jul 24, 2024 · 0 comments
Open

Reverse axes should follow reverse document order #177

sadiqkhoja opened this issue Jul 24, 2024 · 0 comments

Comments

@sadiqkhoja
Copy link
Contributor

sadiqkhoja commented Jul 24, 2024

From the spec:

An axis is either a forward axis or a reverse axis. An axis that only ever contains the context node or nodes that are after the context node in document order is a forward axis. An axis that only ever contains the context node or nodes that are before the context node in document order is a reverse axis. Thus, the ancestor, ancestor-or-self, preceding, and preceding-sibling axes are reverse axes; all other axes are forward axes. Since the self axis always contains at most one node, it makes no difference whether it is a forward or reverse axis. The proximity position of a member of a node-set with respect to an axis is defined to be the position of the node in the node-set ordered in document order if the axis is a forward axis and ordered in reverse document order if the axis is a reverse axis. The first position is 1.

I expect following test to pass:

it.only('adhoc tests', () => {
	const testDocument = xml`
			<root>
			  <foo name="first">
			    <bar>Some content</bar>
			  </foo>
			</root>
`;
	const evaluator = new Evaluator({rootNode: testDocument});

	const actual = evaluator.evaluate(`//bar/ancestor::*[1]/@name`);

	expect(actual.stringValue).toBe('first');
})

In the current implementation //bar/ancestor::*[1] is selecting the root node, it should select foo node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant