コード例 #1
0
  /** Parse the attributes of the xsl:sort element */
  public void parseContents(Parser parser) {

    final SyntaxTreeNode parent = getParent();
    if (!(parent instanceof ApplyTemplates) && !(parent instanceof ForEach)) {
      reportError(this, parser, ErrorMsg.STRAY_SORT_ERR, null);
      return;
    }

    // Parse the select expression (node string value if no expression)
    _select = parser.parseExpression(this, "select", "string(.)");

    // Get the sort order; default is 'ascending'
    String val = getAttribute("order");
    if (val.length() == 0) val = "ascending";
    _order = AttributeValue.create(this, val, parser);

    // Get the sort data type; default is text
    val = getAttribute("data-type");
    if (val.length() == 0) {
      try {
        final Type type = _select.typeCheck(parser.getSymbolTable());
        if (type instanceof IntType) val = "number";
        else val = "text";
      } catch (TypeCheckError e) {
        val = "text";
      }
    }
    _dataType = AttributeValue.create(this, val, parser);

    _lang = getAttribute("lang"); // bug! see 26869
    // val =  getAttribute("lang");
    // _lang = AttributeValue.create(this, val, parser);
    // Get the case order; default is language dependant
    val = getAttribute("case-order");
    _caseOrder = AttributeValue.create(this, val, parser);
  }
コード例 #2
0
  public void parseContents(Parser parser) {
    final String name = getAttribute("name");

    if (name.length() > 0) {
      _isLiteral = Util.isLiteral(name);
      if (_isLiteral) {
        if (!XML11Char.isXML11ValidNCName(name)) {
          ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_NCNAME_ERR, name, this);
          parser.reportError(Constants.ERROR, err);
        }
      }
      _name = AttributeValue.create(this, name, parser);
    } else reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");

    if (name.equals("xml")) {
      reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
    }
    parseChildren(parser);
  }