File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -176,8 +176,10 @@ const fnGenerateId = XPathFunctionDefinition(
176176
177177XPathSequence _fnGenerateId (XPathContext context, [XmlNode ? node]) {
178178 if (node == null ) return XPathSequence .emptyString;
179- // Fall back to UnimplementedError for now, test checks exception type.
180- throw UnimplementedError ('fn:generate-id' );
179+ final id = identityHashCode (
180+ node,
181+ ).toRadixString (16 ).toUpperCase ().padLeft (8 , '0' );
182+ return XPathSequence .single ('autoId$id ' );
181183}
182184
183185/// https://www.w3.org/TR/xpath-functions-31/#func-root
Original file line number Diff line number Diff line change @@ -56,6 +56,13 @@ void main() {
5656 isXPathSequence (['/r/a' ]),
5757 );
5858 });
59+ test ('fn:generate-id' , () {
60+ final ids = document.descendants
61+ .map ((node) => fnGenerateId (context, [XPathSequence .single (node)]))
62+ .map ((sequence) => sequence.single)
63+ .toList ();
64+ expect (ids, unorderedEquals (ids.toSet ()));
65+ });
5966 group ('integration' , () {
6067 final xml = XmlDocument .parse ('<r><a>1</a><b>2<c/>3</b></r>' );
6168 test ('last()' , () {
You can’t perform that action at this time.
0 commit comments