Debian Codegraph @

net/sf/saxon/expr/sort/SortKeyDefinition.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
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 * A SortKeyDefinition defines one component of a sort key.
35 * <p>Note that most attributes defining the sort key can be attribute value templates,
36 * and can therefore vary from one invocation to another. We hold them as expressions.</p>
37 */
38
39 // TODO: optimise also for the case where the attributes depend only on global variables
40 // or parameters, in which case the same AtomicComparer can be used for the duration of a
41 // transformation.
42
43 // TODO: at present the SortKeyDefinition is evaluated to obtain a AtomicComparer, which can
44 // be used to compare two sort keys. It would be more efficient to use a Collator to
45 // obtain collation keys for all the items to be sorted, as these can be compared more
46 // efficiently.
47
48
49 public class SortKeyDefinition extends PseudoExpression {
50
51 protected Operand sortKey;
52 protected Operand order;
53 protected Operand dataTypeExpression = null;
54 // used when the type is not known till run-time
55 protected Operand caseOrder;
56 protected Operand language;
57 protected Operand collationName = null;
58 protected Operand stable = null; // not actually used, but present so it can be validated
59 protected StringCollator collation;
60 protected String baseURI; // needed in case collation URI is relative
61 protected boolean emptyLeast = true;
62 protected boolean backwardsCompatible = false;
63 protected boolean setContextForSortKey = false;
64
65 private transient AtomicComparer finalComparator = null;
66 // Note, the "collation" defines the collating sequence for the sort key. The
67 // "finalComparator" is what is actually used to do comparisons, after taking into account
68 // ascending/descending, caseOrder, etc.
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 * Ask whether the expression can be lifted out of a loop, assuming it has no dependencies
78 * on the controlling variable/focus of the loop
79 * @param forStreaming true if we are optimizing for streamed evaluation
80 */
81
82 public boolean isLiftable(boolean forStreaming) {
83 return false;
84 }
85
86 /**
87 * Set the expression used as the sort key
88 *
89 * @param exp the sort key select expression
90 * @param setContext set to true if the sort key is to be evaluated with the
91 * item-being-sorted as the context item (as in XSLT); false if the context item
92 * is not to be set (as in XQuery)
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 * Get the expression used as the sort key
110 *
111 * @return the sort key select expression
112 */
113
114 public Expression getSortKey() {
115 return sortKey.getChildExpression();
116 }
117
118 /**
119 * Get the sort key operand
120 * @return the operand that computes the sort key
121 */
122
123 public Operand getSortKeyOperand() {
124 return sortKey;
125 }
126
127 /**
128 * Ask whether the sortkey is to be evaluated with the item-being-sorted
129 * as the context item
130 *
131 * @return true if the context needs to be set for evaluating the sort key
132 */
133
134 public boolean isSetContextForSortKey() {
135 return setContextForSortKey;
136 }
137
138
139 /**
140 * Set the order. This is supplied as an expression which must evaluate to "ascending"
141 * or "descending". If the order is fixed, supply e.g. new StringValue("ascending").
142 * Default is "ascending".
143 *
144 * @param exp the expression that determines the order (always a literal in XQuery, but
145 * can be defined by an AVT in XSLT)
146 */
147
148 public void setOrder(Expression exp) {
149 order.setChildExpression(exp);
150 }
151
152 /**
153 * Get the expression that defines the order as ascending or descending
154 *
155 * @return the expression that determines the order (always a literal in XQuery, but
156 * can be defined by an AVT in XSLT)
157 */
158
159 public Expression getOrder() {
160 return order.getChildExpression();
161 }
162
163 /**
164 * Set the data type. This is supplied as an expression which must evaluate to "text",
165 * "number", or a QName. If the data type is fixed, the valus should be supplied using
166 * setDataType() and not via this method.
167 *
168 * @param exp the expression that defines the data type, as used in XSLT 1.0
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 * Get the expression that defines the data type of the sort keys
184 *
185 * @return the expression that defines the data type, as used in XSLT 1.0
186 */
187
188 public Expression getDataTypeExpression() {
189 return dataTypeExpression == null ? null : dataTypeExpression.getChildExpression();
190 }
191
192 /**
193 * Set the case order. This is supplied as an expression which must evaluate to "upper-first"
194 * or "lower-first" or "#default". If the order is fixed, supply e.g. new StringValue("lower-first").
195 * Default is "#default".
196 *
197 * @param exp the expression that defines the case order
198 */
199
200 public void setCaseOrder(Expression exp) {
201 caseOrder.setChildExpression(exp);
202 }
203
204 /**
205 * Get the expression that defines the case order of the sort keys.
206 *
207 * @return the expression that defines the case order, whose run-time value will be "upper-first",
208 * "lower-first", or "#default".
209 */
210
211 public Expression getCaseOrder() {
212 return caseOrder.getChildExpression();
213 }
214
215 /**
216 * Set the language. This is supplied as an expression which evaluates to the language name.
217 * If the order is fixed, supply e.g. new StringValue("de").
218 *
219 * @param exp the expression that determines the language
220 */
221
222 public void setLanguage(Expression exp) {
223 language.setChildExpression(exp);
224 }
225
226 /**
227 * Get the expression that defines the language of the sort keys
228 *
229 * @return exp the expression that determines the language
230 */
231
232 public Expression getLanguage() {
233 return language.getChildExpression();
234 }
235
236 /**
237 * Set the collation name (specifically, an expression which when evaluated returns the collation URI).
238 *
239 * @param collationNameExpr the expression that determines the collation name
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 * Get the selected collation name
255 * (specifically, an expression which when evaluated returns the collation URI).
256 *
257 * @return the expression that determines the collation name
258 */
259
260 public Expression getCollationNameExpression() {
261 return collationName == null ? null : collationName.getChildExpression();
262 }
263
264 /**
265 * Set the collation to be used
266 *
267 * @param collation A StringCollator, which encapsulates both the collation URI and the collating function
268 */
269
270 public void setCollation(StringCollator collation) {
271 this.collation = collation;
272 }
273
274 /**
275 * Get the collation to be used
276 *
277 * @return A StringCollator, which encapsulates both the collation URI and the collating function
278 */
279
280 public StringCollator getCollation() {
281 return collation;
282 }
283
284 /**
285 * Set the base URI of the expression. This is needed to handle the case where a collation URI
286 * evaluated at run-time turns out to be a relative URI.
287 *
288 * @param baseURI the static base URI of the expression
289 */
290
291 public void setBaseURI(String baseURI) {
292 this.baseURI = baseURI;
293 }
294
295 /**
296 * Get the static base URI of the expression. This is needed to handle the case where a collation URI
297 * evaluated at run-time turns out to be a relative URI.
298 *
299 * @return the static base URI of the expression
300 */
301
302 public String getBaseURI() {
303 return baseURI;
304 }
305
306 /**
307 * Set whether this sort key definition is stable
308 *
309 * @param stableExpr the expression that determines whether the sort key definition is stable
310 * (it evaluates to the string "yes" or "no".
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 * Ask whether this sort key definition is stable
325 *
326 * @return the expression that determines whether the sort key definition is stable
327 * (it evaluates to the string "yes" or "no".
328 */
329
330 public Expression getStable() {
331 return stable.getChildExpression();
332 }
333
334 /**
335 * Set whether this sort key is evaluated in XSLT 1.0 backwards compatibility mode
336 *
337 * @param compatible true if backwards compatibility mode is selected
338 */
339
340 public void setBackwardsCompatible(boolean compatible) {
341 backwardsCompatible = compatible;
342 }
343
344 /**
345 * Ask whether this sort key is evaluated in XSLT 1.0 backwards compatibility mode
346 *
347 * @return true if backwards compatibility mode was selected
348 */
349
350 public boolean isBackwardsCompatible() {
351 return backwardsCompatible;
352 }
353
354 /**
355 * Set whether empty sequence comes before other values or after them
356 *
357 * @param emptyLeast true if () is considered lower than any other value
358 */
359
360 public void setEmptyLeast(boolean emptyLeast) {
361 this.emptyLeast = emptyLeast;
362 }
363
364 /**
365 * Ask whether empty sequence comes before other values or after them
366 *
367 * @return true if () is considered lower than any other value
368 */
369
370 public boolean getEmptyLeast() {
371 return emptyLeast;
372 }
373
374 /**
375 * Ask whether the sort key definition is fixed, that is, whether all the information needed
376 * to create a Comparator is known statically
377 *
378 * @return true if all information needed to create a Comparator is known statically
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 * Copy this SortKeyDefinition
393 *
394 * @return a copy of this SortKeyDefinition
395 * @param rm a mutable list of (old binding, new binding) pairs
396 * that is used to update the bindings held in any
397 * local variable references that are copied.
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 * Type-check this sort key definition (all properties other than the sort key
424 * select expression, when it has a different dynamic context)
425 *
426 * @param visitor the expression visitor
427 * @param contextItemType the type of the context item
428 * @throws XPathException if any failure occurs
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 // Otherwise rely on the containing SortExpression to type-check the sort key
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 * An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
469 * This method indicates which of these methods is provided directly. The other methods will always be available
470 * indirectly, using an implementation that relies on one of the other methods.
471 *
472 * @return the implementation method, for example {@link #ITERATE_METHOD} or {@link #EVALUATE_METHOD} or
473 * {@link #PROCESS_METHOD}
474 */
475 @Override
476 public int getImplementationMethod() {
477 return 0;
478 }
479
480 /**
481 * Allocate an AtomicComparer to perform the comparisons described by this sort key component.
482 * The AtomicComparer takes into account not only the collation, but also parameters
483 * such as order=descending and handling of empty sequence and NaN (the result of the compare()
484 * method of the comparator is +1 if the second item is to sort after the first item).
485 * The AtomicComparer is allocated at compile time if possible (during typeCheck), otherwise
486 * at run-time.
487 *
488 * @param context the dynamic evaluation context
489 * @return an AtomicComparer suitable for making the sort comparisons
490 * @throws XPathException for example if the collation URI is invalid or unknown
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 // no action
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 * Set the comparator which is used to compare two values according to this sort key. The comparator makes the final
599 * decision whether one value sorts before or after another: this takes into account the data type, the collation,
600 * whether empty comes first or last, whether the sort order is ascending or descending.
601 * <p>This method is called at compile time if all these factors are known at compile time.
602 * It must not be called at run-time, except to reconstitute a finalComparator that has been
603 * lost by virtue of serialization .</p>
604 *
605 * @param comp the Atomic Comparer to be used
606 */
607
608 public void setFinalComparator(AtomicComparer comp) {
609 finalComparator = comp;
610 }
611
612 /**
613 * Get the comparator which is used to compare two values according to this sort key. This method
614 * may be called either at compile time or at run-time. If no comparator has been allocated,
615 * it returns null. It is then necessary to allocate a comparator using the {@link #makeComparator}
616 * method.
617 *
618 * @return the Atomic Comparer to be used
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 * Compare two SortKeyDefinition values for equality. This compares the sortKeys and attribute values.
647 *
648 * @param other SortKeyDefinition
649 * @return boolean
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 * Get a hashcode to reflect the equals() method
668 *
669 * @return a hashcode based sortkey attribute values.
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