Skip to content

id function is not compliant to the spec #176

Open
@sadiqkhoja

Description

@sadiqkhoja

As per the spec, id function selects elements by their unique ID and attribute for unique ID is declared using DTD.

Q. If no DTD is defined then is id attribute implicitly considered as unique ID of the element node?

Following test fails, because we are not handling DTD at this moment, right?

it.only('adhoc tests', () => {
	const testDocument = xml`<?xml version="1.0" encoding="UTF-8"?>
			<!DOCTYPE root [
					<!ELEMENT root (foo+)>
					<!ELEMENT foo (bar)>
					<!ELEMENT bar (#PCDATA)>
					<!ATTLIST foo name ID #REQUIRED>
			]>
			<root>
					<foo name="first">
							<bar>Some content</bar>
					</foo>
					<foo name="second">
							<bar>Another content</bar>
					</foo>
			</root>
`;
	const evaluator = new Evaluator({rootNode: testDocument});

	const actual = evaluator.evaluate(`count(id('first second'))`);

	expect(actual.numberValue).toBe(2);
})

This issue probably just needs documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions