19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file
49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information
59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file
69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License.
89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at
99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software
139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and
169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License.
179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: ElemSort.java 468643 2006-10-28 06:56:03Z minchau $
209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan.templates;
229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.res.XSLTErrorResources;
249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xpath.XPath;
259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.w3c.dom.DOMException;
279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.w3c.dom.Node;
289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/**
309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Implement xsl:sort.
319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <pre>
329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <!ELEMENT xsl:sort EMPTY>
339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <!ATTLIST xsl:sort
349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   select %expr; "."
359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   lang %avt; #IMPLIED
369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   data-type %avt; "text"
379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   order %avt; "ascending"
389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   case-order %avt; #IMPLIED
399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * >
409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <!-- xsl:sort cannot occur after any other elements or
419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * any non-whitespace character -->
429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </pre>
439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#sorting">sorting in XSLT Specification</a>
449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage advanced
459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class ElemSort extends ElemTemplateElement
479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{
489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    static final long serialVersionUID = -4991510257335851938L;
499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * xsl:sort has a select attribute whose value is an expression.
529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @serial
539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private XPath m_selectExpression = null;
559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Set the "select" attribute.
589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * xsl:sort has a select attribute whose value is an expression.
599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * For each node to be processed, the expression is evaluated
609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * with that node as the current node and with the complete
619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * list of nodes being processed in unsorted order as the current
629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * node list. The resulting object is converted to a string as if
639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * by a call to the string function; this string is used as the
649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sort key for that node. The default value of the select attribute
659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is ., which will cause the string-value of the current node to
669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * be used as the sort key.
679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param v Value to set for the "select" attribute
699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setSelect(XPath v)
719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (v.getPatternString().indexOf("{") < 0)
749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      m_selectExpression = v;
759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      error(XSLTErrorResources.ER_NO_CURLYBRACE, null);
779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get the "select" attribute.
819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * xsl:sort has a select attribute whose value is an expression.
829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * For each node to be processed, the expression is evaluated
839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * with that node as the current node and with the complete
849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * list of nodes being processed in unsorted order as the current
859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * node list. The resulting object is converted to a string as if
869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * by a call to the string function; this string is used as the
879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sort key for that node. The default value of the select attribute
889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is ., which will cause the string-value of the current node to
899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * be used as the sort key.
909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The value of the "select" attribute
929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XPath getSelect()
949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_selectExpression;
969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * lang specifies the language of the sort keys.
1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @serial
1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private AVT m_lang_avt = null;
1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Set the "lang" attribute.
1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * lang specifies the language of the sort keys; it has the same
1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * range of values as xml:lang [XML]; if no lang value is
1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified, the language should be determined from the system environment.
1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param v The value to set for the "lang" attribute
1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setLang(AVT v)
1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_lang_avt = v;
1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get the "lang" attribute.
1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * lang specifies the language of the sort keys; it has the same
1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * range of values as xml:lang [XML]; if no lang value is
1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified, the language should be determined from the system environment.
1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The value of the "lang" attribute
1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public AVT getLang()
1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_lang_avt;
1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * data-type specifies the data type of the
1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * strings to be sorted.
1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @serial
1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private AVT m_dataType_avt = null;
1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Set the "data-type" attribute.
1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>data-type</code> specifies the data type of the
1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * strings; the following values are allowed:
1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <ul>
1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <li>
1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>text</code> specifies that the sort keys should be
1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sorted lexicographically in the culturally correct manner for the
1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * language specified by <code>lang</code>.
1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </li>
1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <li>
1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>number</code> specifies that the sort keys should be
1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * converted to numbers and then sorted according to the numeric value;
1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the sort key is converted to a number as if by a call to the
1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <b><a href="http://www.w3.org/TR/xpath#function-number">number</a></b> function; the <code>lang</code>
1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * attribute is ignored.
1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </li>
1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <li>
1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * A <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> with a prefix
1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is expanded into an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> as described
1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * in <a href="#qname">[<b>2.4 Qualified Names</b>]</a>; the expanded-name identifies the data-type;
1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the behavior in this case is not specified by this document.
1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </li>
1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </ul>
1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>The default value is <code>text</code>.</p>
1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote>
1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <b>NOTE: </b>The XSL Working Group plans that future versions of XSLT will
1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * leverage XML Schemas to define further values for this
1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * attribute.</blockquote>
1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param v Value to set for the "data-type" attribute
1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setDataType(AVT v)
1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_dataType_avt = v;
1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get the "data-type" attribute.
1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>data-type</code> specifies the data type of the
1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * strings; the following values are allowed:
1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <ul>
1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <li>
1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>text</code> specifies that the sort keys should be
1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sorted lexicographically in the culturally correct manner for the
1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * language specified by <code>lang</code>.
1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </li>
1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <li>
1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>number</code> specifies that the sort keys should be
1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * converted to numbers and then sorted according to the numeric value;
1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the sort key is converted to a number as if by a call to the
1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <b><a href="http://www.w3.org/TR/xpath#function-number">number</a></b> function; the <code>lang</code>
1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * attribute is ignored.
1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </li>
1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <li>
1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * A <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> with a prefix
1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is expanded into an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> as described
1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * in <a href="#qname">[<b>2.4 Qualified Names</b>]</a>; the expanded-name identifies the data-type;
1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the behavior in this case is not specified by this document.
1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </li>
1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </ul>
1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>The default value is <code>text</code>.</p>
1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote>
2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <b>NOTE: </b>The XSL Working Group plans that future versions of XSLT will
2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * leverage XML Schemas to define further values for this
2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * attribute.</blockquote>
2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The value of the "data-type" attribute
2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public AVT getDataType()
2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_dataType_avt;
2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * order specifies whether the strings should be sorted in ascending
2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * or descending order.
2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @serial
2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private AVT m_order_avt = null;
2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Set the "order" attribute.
2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * order specifies whether the strings should be sorted in ascending
2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * or descending order; ascending specifies ascending order; descending
2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specifies descending order; the default is ascending.
2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param v The value to set for the "order" attribute
2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setOrder(AVT v)
2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_order_avt = v;
2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get the "order" attribute.
2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * order specifies whether the strings should be sorted in ascending
2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * or descending order; ascending specifies ascending order; descending
2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specifies descending order; the default is ascending.
2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The value of the "order" attribute
2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public AVT getOrder()
2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_order_avt;
2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case-order has the value upper-first or lower-first.
2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The default value is language dependent.
2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @serial
2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private AVT m_caseorder_avt = null;
2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Set the "case-order" attribute.
2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case-order has the value upper-first or lower-first; this applies
2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * when data-type="text", and specifies that upper-case letters should
2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sort before lower-case letters or vice-versa respectively.
2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * For example, if lang="en", then A a B b are sorted with
2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case-order="upper-first" and a A b B are sorted with case-order="lower-first".
2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The default value is language dependent.
2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param v The value to set for the "case-order" attribute
2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @serial
2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setCaseOrder(AVT v)
2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_caseorder_avt = v;
2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get the "case-order" attribute.
2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case-order has the value upper-first or lower-first; this applies
2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * when data-type="text", and specifies that upper-case letters should
2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sort before lower-case letters or vice-versa respectively.
2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * For example, if lang="en", then A a B b are sorted with
2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case-order="upper-first" and a A b B are sorted with case-order="lower-first".
2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The default value is language dependent.
2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The value of the "case-order" attribute
2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public AVT getCaseOrder()
2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_caseorder_avt;
2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get an int constant identifying the type of element.
2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see org.apache.xalan.templates.Constants
2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The token ID of the element
2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int getXSLToken()
2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return Constants.ELEMNAME_SORT;
2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Return the node name.
2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return The element's name
3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public String getNodeName()
3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return Constants.ELEMNAME_SORT_STRING;
3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Add a child to the child list.
3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param newChild Child to add to the child list
3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return Child just added to the child list
3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws DOMException
3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public Node appendChild(Node newChild) throws DOMException
3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    error(XSLTErrorResources.ER_CANNOT_ADD,
3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          new Object[]{ newChild.getNodeName(),
3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        this.getNodeName() });  //"Can not add " +((ElemTemplateElement)newChild).m_elemName +
3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //" to " + this.m_elemName);
3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This function is called after everything else has been
3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * recomposed, and allows the template to set remaining
3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * values that may be based on some other property that
3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * depends on recomposition.
3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void compose(StylesheetRoot sroot)
3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    throws javax.xml.transform.TransformerException
3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    super.compose(sroot);
3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    StylesheetRoot.ComposeState cstate = sroot.getComposeState();
3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    java.util.Vector vnames = cstate.getVariableNames();
3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(null != m_caseorder_avt)
3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      m_caseorder_avt.fixupVariables(vnames, cstate.getGlobalsSize());
3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(null != m_dataType_avt)
3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      m_dataType_avt.fixupVariables(vnames, cstate.getGlobalsSize());
3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(null != m_lang_avt)
3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      m_lang_avt.fixupVariables(vnames, cstate.getGlobalsSize());
3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(null != m_order_avt)
3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      m_order_avt.fixupVariables(vnames, cstate.getGlobalsSize());
3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(null != m_selectExpression)
3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      m_selectExpression.fixupVariables(vnames, cstate.getGlobalsSize());
3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}
350