| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.expr.sort; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.Version; |
| 12 |
import net.sf.saxon.expr.*; |
| 13 |
import net.sf.saxon.expr.parser.ContextItemStaticInfo; |
| 14 |
import net.sf.saxon.expr.parser.ExpressionVisitor; |
| 15 |
import net.sf.saxon.expr.parser.RebindingMap; |
| 16 |
import net.sf.saxon.lib.StringCollator; |
| 17 |
import net.sf.saxon.om.StandardNames; |
| 18 |
import net.sf.saxon.trace.ExpressionPresenter; |
| 19 |
import net.sf.saxon.trans.XPathException; |
| 20 |
import net.sf.saxon.type.StringConverter; |
| 21 |
import net.sf.saxon.type.ValidationFailure; |
| 22 |
import net.sf.saxon.value.SequenceType; |
| 23 |
import net.sf.saxon.value.StringValue; |
| 24 |
import net.sf.saxon.value.Whitespace; |
| 25 |
|
| 26 |
import java.net.URI; |
| 27 |
import java.net.URISyntaxException; |
| 28 |
import java.util.ArrayList; |
| 29 |
import java.util.List; |
| 30 |
import java.util.Objects; |
| 31 |
import java.util.Properties; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public class SortKeyDefinition extends PseudoExpression { |
| 50 |
|
| 51 |
protected Operand sortKey; |
| 52 |
protected Operand order; |
| 53 |
protected Operand dataTypeExpression = null; |
| 54 |
|
| 55 |
protected Operand caseOrder; |
| 56 |
protected Operand language; |
| 57 |
protected Operand collationName = null; |
| 58 |
protected Operand stable = null; |
| 59 |
protected StringCollator collation; |
| 60 |
protected String baseURI; |
| 61 |
protected boolean emptyLeast = true; |
| 62 |
protected boolean backwardsCompatible = false; |
| 63 |
protected boolean setContextForSortKey = false; |
| 64 |
|
| 65 |
private transient AtomicComparer finalComparator = null; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public SortKeyDefinition() { |
| 71 |
order = new Operand(this, new StringLiteral("ascending"), OperandRole.SINGLE_ATOMIC); |
| 72 |
caseOrder = new Operand(this, new StringLiteral("#default"), OperandRole.SINGLE_ATOMIC); |
| 73 |
language = new Operand(this, new StringLiteral(StringValue.EMPTY_STRING), OperandRole.SINGLE_ATOMIC); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public boolean isLiftable(boolean forStreaming) { |
| 83 |
return false; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public void setSortKey(Expression exp, boolean setContext) { |
| 96 |
OperandRole opRole; |
| 97 |
if (setContext) { |
| 98 |
opRole = new OperandRole(OperandRole.HAS_SPECIAL_FOCUS_RULES | OperandRole.HIGHER_ORDER, |
| 99 |
OperandUsage.TRANSMISSION, |
| 100 |
SequenceType.ANY_SEQUENCE); |
| 101 |
} else { |
| 102 |
opRole = OperandRole.ATOMIC_SEQUENCE; |
| 103 |
} |
| 104 |
sortKey = new Operand(this, exp, opRole); |
| 105 |
setContextForSortKey = setContext; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
public Expression getSortKey() { |
| 115 |
return sortKey.getChildExpression(); |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
public Operand getSortKeyOperand() { |
| 124 |
return sortKey; |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
public boolean isSetContextForSortKey() { |
| 135 |
return setContextForSortKey; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
public void setOrder(Expression exp) { |
| 149 |
order.setChildExpression(exp); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
public Expression getOrder() { |
| 160 |
return order.getChildExpression(); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
public void setDataTypeExpression(Expression exp) { |
| 172 |
if (exp == null) { |
| 173 |
dataTypeExpression = null; |
| 174 |
} else { |
| 175 |
if (dataTypeExpression == null) { |
| 176 |
dataTypeExpression = new Operand(this, exp, OperandRole.SINGLE_ATOMIC); |
| 177 |
} |
| 178 |
dataTypeExpression.setChildExpression(exp); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
public Expression getDataTypeExpression() { |
| 189 |
return dataTypeExpression == null ? null : dataTypeExpression.getChildExpression(); |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
public void setCaseOrder(Expression exp) { |
| 201 |
caseOrder.setChildExpression(exp); |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
public Expression getCaseOrder() { |
| 212 |
return caseOrder.getChildExpression(); |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
public void setLanguage(Expression exp) { |
| 223 |
language.setChildExpression(exp); |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
public Expression getLanguage() { |
| 233 |
return language.getChildExpression(); |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
public void setCollationNameExpression(Expression collationNameExpr) { |
| 243 |
if (collationNameExpr == null) { |
| 244 |
collationName = null; |
| 245 |
} else { |
| 246 |
if (collationName == null) { |
| 247 |
collationName = new Operand(this, collationNameExpr, OperandRole.SINGLE_ATOMIC); |
| 248 |
} |
| 249 |
collationName.setChildExpression(collationNameExpr); |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
public Expression getCollationNameExpression() { |
| 261 |
return collationName == null ? null : collationName.getChildExpression(); |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
public void setCollation(StringCollator collation) { |
| 271 |
this.collation = collation; |
| 272 |
} |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
public StringCollator getCollation() { |
| 281 |
return collation; |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
public void setBaseURI(String baseURI) { |
| 292 |
this.baseURI = baseURI; |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
public String getBaseURI() { |
| 303 |
return baseURI; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
public void setStable(Expression stableExpr) { |
| 314 |
if (stableExpr == null) { |
| 315 |
stableExpr = new StringLiteral("yes"); |
| 316 |
} |
| 317 |
if (stable == null) { |
| 318 |
stable = new Operand(this, stableExpr, OperandRole.SINGLE_ATOMIC); |
| 319 |
} |
| 320 |
stable.setChildExpression(stableExpr); |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
public Expression getStable() { |
| 331 |
return stable.getChildExpression(); |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
public void setBackwardsCompatible(boolean compatible) { |
| 341 |
backwardsCompatible = compatible; |
| 342 |
} |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
public boolean isBackwardsCompatible() { |
| 351 |
return backwardsCompatible; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
public void setEmptyLeast(boolean emptyLeast) { |
| 361 |
this.emptyLeast = emptyLeast; |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
public boolean getEmptyLeast() { |
| 371 |
return emptyLeast; |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
public boolean isFixed() { |
| 382 |
return order.getChildExpression() instanceof Literal && |
| 383 |
(dataTypeExpression == null || |
| 384 |
dataTypeExpression.getChildExpression() instanceof Literal) && |
| 385 |
caseOrder.getChildExpression() instanceof Literal && |
| 386 |
language.getChildExpression() instanceof Literal && |
| 387 |
(stable == null || stable.getChildExpression() instanceof Literal) && |
| 388 |
(collationName == null || collationName.getChildExpression() instanceof Literal); |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
public SortKeyDefinition copy(RebindingMap rm) { |
| 401 |
SortKeyDefinition sk2 = new SortKeyDefinition(); |
| 402 |
sk2.setSortKey(copy(sortKey.getChildExpression(), rm), true); |
| 403 |
sk2.setOrder(copy(order.getChildExpression(), rm)); |
| 404 |
sk2.setDataTypeExpression(dataTypeExpression == null ? null : copy(dataTypeExpression.getChildExpression(), rm)); |
| 405 |
sk2.setCaseOrder(copy(caseOrder.getChildExpression(), rm)); |
| 406 |
sk2.setLanguage(copy(language.getChildExpression(), rm)); |
| 407 |
sk2.setStable(copy(stable == null ? null : stable.getChildExpression(), rm)); |
| 408 |
sk2.setCollationNameExpression(collationName == null ? null : copy(collationName.getChildExpression(), rm)); |
| 409 |
sk2.collation = collation; |
| 410 |
sk2.emptyLeast = emptyLeast; |
| 411 |
sk2.baseURI = baseURI; |
| 412 |
sk2.backwardsCompatible = backwardsCompatible; |
| 413 |
sk2.finalComparator = finalComparator; |
| 414 |
sk2.setContextForSortKey = setContextForSortKey; |
| 415 |
return sk2; |
| 416 |
} |
| 417 |
|
| 418 |
private Expression copy(Expression in, RebindingMap rebindings) { |
| 419 |
return in == null ? null : in.copy(rebindings); |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
public SortKeyDefinition typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { |
| 432 |
for (Operand o : checkedOperands()) { |
| 433 |
if (o.hasSameFocus()) { |
| 434 |
o.typeCheck(visitor, contextItemType); |
| 435 |
} |
| 436 |
|
| 437 |
} |
| 438 |
Expression lang = getLanguage(); |
| 439 |
if (lang instanceof StringLiteral && !((StringLiteral) lang).getStringValue().isEmpty()) { |
| 440 |
ValidationFailure vf = StringConverter.StringToLanguage.INSTANCE.validate(((StringLiteral) lang).getStringValue()); |
| 441 |
if (vf != null) { |
| 442 |
throw new XPathException("The lang attribute of xsl:sort must be a valid language code", "XTDE0030"); |
| 443 |
} |
| 444 |
} |
| 445 |
return this; |
| 446 |
} |
| 447 |
|
| 448 |
@Override |
| 449 |
public Iterable<Operand> operands() { |
| 450 |
List<Operand> list = new ArrayList<>(8); |
| 451 |
list.add(sortKey); |
| 452 |
list.add(order); |
| 453 |
if (dataTypeExpression != null) { |
| 454 |
list.add(dataTypeExpression); |
| 455 |
} |
| 456 |
list.add(caseOrder); |
| 457 |
list.add(language); |
| 458 |
if (stable != null) { |
| 459 |
list.add(stable); |
| 460 |
} |
| 461 |
if (collationName != null) { |
| 462 |
list.add(collationName); |
| 463 |
} |
| 464 |
return list; |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
@Override |
| 476 |
public int getImplementationMethod() { |
| 477 |
return 0; |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
public AtomicComparer makeComparator(XPathContext context) throws XPathException { |
| 494 |
|
| 495 |
String orderX = order.getChildExpression().evaluateAsString(context).toString(); |
| 496 |
|
| 497 |
final Configuration config = context.getConfiguration(); |
| 498 |
|
| 499 |
AtomicComparer atomicComparer; |
| 500 |
StringCollator stringCollator; |
| 501 |
if (collation != null) { |
| 502 |
stringCollator = collation; |
| 503 |
} else if (collationName != null) { |
| 504 |
String cname = collationName.getChildExpression().evaluateAsString(context).toString(); |
| 505 |
URI collationURI; |
| 506 |
try { |
| 507 |
collationURI = new URI(cname); |
| 508 |
if (!collationURI.isAbsolute()) { |
| 509 |
if (baseURI == null) { |
| 510 |
throw new XPathException("Collation URI is relative, and base URI is unknown"); |
| 511 |
} else { |
| 512 |
URI base = new URI(baseURI); |
| 513 |
collationURI = base.resolve(collationURI); |
| 514 |
} |
| 515 |
} |
| 516 |
} catch (URISyntaxException err) { |
| 517 |
throw new XPathException("Collation name " + cname + " is not a valid URI: " + err); |
| 518 |
} |
| 519 |
stringCollator = context.getConfiguration().getCollation(collationURI.toString()); |
| 520 |
if (stringCollator == null) { |
| 521 |
throw new XPathException("Unknown collation " + collationURI, "XTDE1035"); |
| 522 |
} |
| 523 |
} else { |
| 524 |
String caseOrderX = caseOrder.getChildExpression().evaluateAsString(context).toString(); |
| 525 |
String languageX = language.getChildExpression().evaluateAsString(context).toString(); |
| 526 |
String uri = "http://saxon.sf.net/collation"; |
| 527 |
boolean firstParam = true; |
| 528 |
Properties props = new Properties(); |
| 529 |
if (!languageX.isEmpty()) { |
| 530 |
ValidationFailure vf = StringConverter.StringToLanguage.INSTANCE.validate(languageX); |
| 531 |
if (vf != null) { |
| 532 |
throw new XPathException("The lang attribute of xsl:sort must be a valid language code", "XTDE0030"); |
| 533 |
} |
| 534 |
props.setProperty("lang", languageX); |
| 535 |
uri += "?lang=" + languageX; |
| 536 |
firstParam = false; |
| 537 |
} |
| 538 |
if (!caseOrderX.equals("#default")) { |
| 539 |
props.setProperty("case-order", caseOrderX); |
| 540 |
uri += (firstParam ? "?" : ";") + "case-order=" + caseOrderX; |
| 541 |
firstParam = false; |
| 542 |
} |
| 543 |
stringCollator = Version.platform.makeCollation(config, props, uri); |
| 544 |
} |
| 545 |
|
| 546 |
|
| 547 |
if (dataTypeExpression == null) { |
| 548 |
atomicComparer = AtomicSortComparer.makeSortComparer(stringCollator, |
| 549 |
sortKey.getChildExpression().getItemType().getAtomizedItemType().getPrimitiveType(), context); |
| 550 |
if (!emptyLeast) { |
| 551 |
atomicComparer = new EmptyGreatestComparer(atomicComparer); |
| 552 |
} |
| 553 |
} else { |
| 554 |
String dataType = dataTypeExpression.getChildExpression().evaluateAsString(context).toString(); |
| 555 |
switch (dataType) { |
| 556 |
case "text": |
| 557 |
atomicComparer = AtomicSortComparer.makeSortComparer(stringCollator, |
| 558 |
StandardNames.XS_STRING, context); |
| 559 |
atomicComparer = new TextComparer(atomicComparer); |
| 560 |
break; |
| 561 |
case "number": |
| 562 |
atomicComparer = context.getConfiguration().getXsdVersion() == Configuration.XSD10 |
| 563 |
? NumericComparer.getInstance() |
| 564 |
: NumericComparer11.getInstance(); |
| 565 |
break; |
| 566 |
default: |
| 567 |
XPathException err = new XPathException("data-type on xsl:sort must be 'text' or 'number'"); |
| 568 |
err.setErrorCode("XTDE0030"); |
| 569 |
throw err; |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
if (stable != null) { |
| 574 |
StringValue stableVal = (StringValue) stable.getChildExpression().evaluateItem(context); |
| 575 |
String s = Whitespace.trim(stableVal.getStringValue()); |
| 576 |
if (s.equals("yes") || s.equals("no") || s.equals("true") || s.equals("false") || s.equals("1") || s.equals("0")) { |
| 577 |
|
| 578 |
} else { |
| 579 |
XPathException err = new XPathException("Value of 'stable' on xsl:sort must be yes|no|true|false|1|0"); |
| 580 |
err.setErrorCode("XTDE0030"); |
| 581 |
throw err; |
| 582 |
} |
| 583 |
} |
| 584 |
|
| 585 |
switch (orderX) { |
| 586 |
case "ascending": |
| 587 |
return atomicComparer; |
| 588 |
case "descending": |
| 589 |
return new DescendingComparer(atomicComparer); |
| 590 |
default: |
| 591 |
XPathException err1 = new XPathException("order must be 'ascending' or 'descending'"); |
| 592 |
err1.setErrorCode("XTDE0030"); |
| 593 |
throw err1; |
| 594 |
} |
| 595 |
} |
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
public void setFinalComparator(AtomicComparer comp) { |
| 609 |
finalComparator = comp; |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
public AtomicComparer getFinalComparator() { |
| 622 |
return finalComparator; |
| 623 |
} |
| 624 |
|
| 625 |
public SortKeyDefinition fix(XPathContext context) throws XPathException { |
| 626 |
SortKeyDefinition newSKD = this.copy(new RebindingMap()); |
| 627 |
|
| 628 |
newSKD.setLanguage(new StringLiteral(this.getLanguage().evaluateAsString(context))); |
| 629 |
newSKD.setOrder(new StringLiteral(this.getOrder().evaluateAsString(context))); |
| 630 |
|
| 631 |
if (collationName != null) { |
| 632 |
newSKD.setCollationNameExpression(new StringLiteral(this.getCollationNameExpression().evaluateAsString(context))); |
| 633 |
} |
| 634 |
|
| 635 |
newSKD.setCaseOrder(new StringLiteral(this.getCaseOrder().evaluateAsString(context))); |
| 636 |
|
| 637 |
if (dataTypeExpression != null) { |
| 638 |
newSKD.setDataTypeExpression(new StringLiteral(this.getDataTypeExpression().evaluateAsString(context))); |
| 639 |
} |
| 640 |
newSKD.setSortKey(new ContextItemExpression(), true); |
| 641 |
|
| 642 |
return newSKD; |
| 643 |
} |
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
public boolean equals(Object other) { |
| 653 |
if (other instanceof SortKeyDefinition) { |
| 654 |
SortKeyDefinition s2 = (SortKeyDefinition) other; |
| 655 |
return Objects.equals(getSortKey(), s2.getSortKey()) && |
| 656 |
Objects.equals(getOrder(), s2.getOrder()) && |
| 657 |
Objects.equals(getLanguage(), s2.getLanguage()) && |
| 658 |
Objects.equals(getDataTypeExpression(), s2.getDataTypeExpression()) && |
| 659 |
Objects.equals(getStable(), s2.getStable()) && |
| 660 |
Objects.equals(getCollationNameExpression(), s2.getCollationNameExpression()); |
| 661 |
} else { |
| 662 |
return false; |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
public int computeHashCode() { |
| 673 |
int h = 0; |
| 674 |
h ^= getOrder().hashCode(); |
| 675 |
h ^= getCaseOrder().hashCode(); |
| 676 |
h ^= getLanguage().hashCode(); |
| 677 |
|
| 678 |
if (getDataTypeExpression() != null) { |
| 679 |
h ^= getDataTypeExpression().hashCode(); |
| 680 |
} |
| 681 |
if (getStable() != null) { |
| 682 |
h ^= getStable().hashCode(); |
| 683 |
} |
| 684 |
if (getCollationNameExpression() != null) { |
| 685 |
h ^= getCollationNameExpression().hashCode(); |
| 686 |
|
| 687 |
} |
| 688 |
return h; |
| 689 |
} |
| 690 |
|
| 691 |
@Override |
| 692 |
public void export(ExpressionPresenter out) throws XPathException { |
| 693 |
out.startElement("sortKey", this); |
| 694 |
if (finalComparator != null) { |
| 695 |
out.emitAttribute("comp", finalComparator.save()); |
| 696 |
} |
| 697 |
out.setChildRole("select"); |
| 698 |
sortKey.getChildExpression().export(out); |
| 699 |
out.setChildRole("order"); |
| 700 |
order.getChildExpression().export(out); |
| 701 |
if (dataTypeExpression != null) { |
| 702 |
out.setChildRole("dataType"); |
| 703 |
dataTypeExpression.getChildExpression().export(out); |
| 704 |
} |
| 705 |
out.setChildRole("lang"); |
| 706 |
language.getChildExpression().export(out); |
| 707 |
out.setChildRole("caseOrder"); |
| 708 |
caseOrder.getChildExpression().export(out); |
| 709 |
if (stable != null) { |
| 710 |
out.setChildRole("stable"); |
| 711 |
stable.getChildExpression().export(out); |
| 712 |
} |
| 713 |
if (collationName != null) { |
| 714 |
out.setChildRole("collation"); |
| 715 |
collationName.getChildExpression().export(out); |
| 716 |
} |
| 717 |
|
| 718 |
out.endElement(); |
| 719 |
} |
| 720 |
} |
| 721 |
|