Skip to content

Commit f24ffac

Browse files
committed
[XPath] Fix some problems with the type hierarchy and fix documentation.
17205 76.4% successes 0 0.0% skipped 3598 16.0% failures 1711 7.6% errors
1 parent 9d16926 commit f24ffac

File tree

6 files changed

+42
-23
lines changed

6 files changed

+42
-23
lines changed

lib/src/xpath/GEMINI.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ All other XPath types directly map to corresponding Dart types.
2525

2626
| XPath Type | Dart Type | Type Implementation
2727
| --- | --- | ---
28-
| `item()` | `xsAny` | `Object`
29-
| `sequence` | `xsSequence` or `XPathSequenceType` | `XPathSequence`
30-
| `empty-sequence` | `xsEmptySequence` | `XPathSequence`
28+
| `item()` | `Object` | `xsAny`
29+
| `sequence` | `XPathSequence` | `xsSequence`
30+
| `empty-sequence` | `XPathSequence` | `xsEmptySequence`
3131

3232
### Nodes
3333

@@ -40,7 +40,8 @@ XML nodes are represented by the [XmlNode](../../xml/nodes/node.dart) class and
4040
| `document` | `XmlDocument` | `xsDocument`
4141
| `element` | `XmlElement` | `xsElement`
4242
| `node` | `XmlNode` | `xsNode`
43-
| `processing-instruction` | `XmlProcessingInstruction` | `xsProcessingInstruction`
43+
| `namespace` | `XmlNamespace` | `xsNamespace`
44+
| `processing-instruction` | `XmlProcessing` | `xsProcessingInstruction`
4445
| `text` | `XmlText` and `XmlCDATA` | `xsText`
4546

4647
### Functions
@@ -78,22 +79,22 @@ Numeric values are represented by the Dart `num` class and its subtypes.
7879
| XPath Type | Dart Type | Implementation
7980
| --- | --- | ---
8081
| `xs:numeric` | `num` | `xsNumeric`
81-
| `xs:byte` | `int` | `xsInteger`
82-
| `xs:decimal` | `int` | `xsInteger`
82+
| `xs:byte` | `int` | `xsByte`
83+
| `xs:decimal` | `num` | `xsDecimal`
8384
| `xs:double` | `double` | `xsDouble`
8485
| `xs:float` | `double` | `xsDouble`
85-
| `xs:int` | `int` | `xsInteger`
86+
| `xs:int` | `int` | `xsInt`
8687
| `xs:integer` | `int` | `xsInteger`
87-
| `xs:long` | `int` | `xsInteger`
88-
| `xs:negativeInteger` | `int` | `xsInteger`
89-
| `xs:nonNegativeInteger` | `int` | `xsInteger`
90-
| `xs:nonPositiveInteger` | `int` | `xsInteger`
91-
| `xs:positiveInteger` | `int` | `xsInteger`
92-
| `xs:short` | `int` | `xsInteger`
93-
| `xs:unsignedByte` | `int` | `xsInteger`
94-
| `xs:unsignedInt` | `int` | `xsInteger`
95-
| `xs:unsignedLong` | `int` | `xsInteger`
96-
| `xs:unsignedShort` | `int` | `xsInteger`
88+
| `xs:long` | `int` | `xsLong`
89+
| `xs:negativeInteger` | `int` | `xsNegativeInteger`
90+
| `xs:nonNegativeInteger` | `int` | `xsNonNegativeInteger`
91+
| `xs:nonPositiveInteger` | `int` | `xsNonPositiveInteger`
92+
| `xs:positiveInteger` | `int` | `xsPositiveInteger`
93+
| `xs:short` | `int` | `xsShort`
94+
| `xs:unsignedByte` | `int` | `xsUnsignedByte`
95+
| `xs:unsignedInt` | `int` | `xsUnsignedInt`
96+
| `xs:unsignedLong` | `int` | `xsUnsignedLong`
97+
| `xs:unsignedShort` | `int` | `xsUnsignedShort`
9798

9899
### Strings
99100

@@ -128,6 +129,8 @@ Boolean values are represented by the Dart `bool` class.
128129
| `xs:hexBinary` | `XPathHexBinary` | `xsHexBinary`
129130
| `xs:anyURI` | `String` | `xsString`
130131
| `xs:QName` | `XmlName` | `xsQName`
132+
| `xs:untyped` | `Object` | `xsAny`
133+
| `xs:untypedAtomic` | `Object` | `xsAny`
131134
| `xs:NOTATION` | `String` | `xsString`
132135

133136
## Functions & Operators

lib/src/xpath/evaluation/types.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import '../definitions/type.dart';
2+
import '../types/any.dart';
23
import '../types/array.dart';
34
import '../types/binary.dart';
45
import '../types/boolean.dart';
56
import '../types/date_time.dart';
67
import '../types/duration.dart';
78
import '../types/function.dart';
89
import '../types/map.dart';
10+
import '../types/node.dart';
911
import '../types/number.dart';
1012
import '../types/qname.dart';
1113
import '../types/sequence.dart';
@@ -21,30 +23,39 @@ final Map<String, XPathType<Object>> standardTypes = {
2123

2224
/// Internal list of basic types.
2325
const basicTypes = <XPathType<Object>>[
26+
xsAny,
2427
xsArray,
28+
xsAttribute,
2529
xsBase64Binary,
2630
xsBoolean,
2731
xsByte,
32+
xsComment,
2833
xsDateTime,
2934
xsDecimal,
35+
xsDocument,
3036
xsDouble,
3137
xsDuration,
38+
xsElement,
3239
xsEmptySequence,
3340
xsFunction,
3441
xsHexBinary,
3542
xsInt,
3643
xsInteger,
3744
xsLong,
3845
xsMap,
46+
xsNamespace,
3947
xsNegativeInteger,
48+
xsNode,
4049
xsNonNegativeInteger,
4150
xsNonPositiveInteger,
4251
xsNumeric,
4352
xsPositiveInteger,
53+
xsProcessingInstruction,
4454
xsQName,
4555
xsSequence,
4656
xsShort,
4757
xsString,
58+
xsText,
4859
xsUnsignedByte,
4960
xsUnsignedInt,
5061
xsUnsignedLong,

lib/src/xpath/types/any.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class _XPathAnyType extends XPathType<Object> {
99
@override
1010
String get name => 'item()';
1111

12+
@override
13+
Iterable<String> get aliases => ['xs:untyped', 'xs:untypedAtomic'];
14+
1215
@override
1316
bool matches(Object value) => true;
1417

lib/src/xpath/types/qname.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class _XPathQNameType extends XPathType<Object> {
1010
const _XPathQNameType();
1111

1212
@override
13-
String get name => 'xs:QName()';
13+
String get name => 'xs:QName';
1414

1515
@override
1616
bool matches(Object value) => value is XmlName;

lib/src/xpath/types/string.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ class _XPathStringType extends XPathType<String> {
2626
'xs:token',
2727
'xs:language',
2828
'xs:NMTOKEN',
29+
'xs:NMTOKENS',
2930
'xs:Name',
3031
'xs:NCName',
3132
'xs:ID',
3233
'xs:IDREF',
34+
'xs:IDREFS',
3335
'xs:ENTITY',
36+
'xs:ENTITIES',
3437
'xs:anyURI',
35-
'xs:QName',
3638
'xs:NOTATION',
3739
];
3840

test/xpath/types/qname_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '../../utils/matchers.dart';
88
void main() {
99
group('xsQName', () {
1010
test('name', () {
11-
expect(xsQName.name, 'xs:QName()');
11+
expect(xsQName.name, 'xs:QName');
1212
});
1313
test('matches', () {
1414
expect(xsQName.matches(const XmlName.qualified('foo')), isTrue);
@@ -34,7 +34,7 @@ void main() {
3434
() => xsQName.cast(XPathSequence.empty),
3535
throwsA(
3636
isXPathEvaluationException(
37-
message: 'Unsupported cast from () to xs:QName()',
37+
message: 'Unsupported cast from () to xs:QName',
3838
),
3939
),
4040
);
@@ -49,7 +49,7 @@ void main() {
4949
),
5050
throwsA(
5151
isXPathEvaluationException(
52-
message: 'Unsupported cast from (a, b) to xs:QName()',
52+
message: 'Unsupported cast from (a, b) to xs:QName',
5353
),
5454
),
5555
);
@@ -59,7 +59,7 @@ void main() {
5959
() => xsQName.cast(123),
6060
throwsA(
6161
isXPathEvaluationException(
62-
message: 'Unsupported cast from 123 to xs:QName()',
62+
message: 'Unsupported cast from 123 to xs:QName',
6363
),
6464
),
6565
);

0 commit comments

Comments
 (0)