Exemple #1
0
  public void checkArguments(ExpressionVisitor visitor) throws XPathException {
    StaticContext env = visitor.getStaticContext();
    if (checked) return;
    checked = true;
    super.checkArguments(visitor);
    if (argument[1] instanceof StringLiteral) {
      // picture is known statically - optimize for this common case
      picture = ((StringLiteral) argument[1]).getStringValue();
    }
    if (argument.length == 3) {
      if (argument[2] instanceof StringLiteral) {
        // common case, decimal format name is supplied as a string literal

        String lexicalName = ((StringLiteral) argument[2]).getStringValue();

        StructuredQName qName;
        try {
          qName =
              StructuredQName.fromLexicalQName(
                  lexicalName,
                  false,
                  visitor.getConfiguration().getNameChecker(),
                  env.getNamespaceResolver());
        } catch (XPathException e) {
          XPathException se = new XPathException("Invalid decimal format name. " + e.getMessage());
          se.setErrorCode("XTDE1280");
          throw se;
        }

        DecimalFormatManager dfm =
            ((ExpressionContext) env).getXSLStylesheet().getDecimalFormatManager();
        requireFixup = true;
        dfm.registerUsage(qName, this);
        // this causes a callback to the fixup() method, either now, or later if it's a forwards
        // reference
      } else {
        // we need to save the namespace context
        nsContext = env.getNamespaceResolver();
      }
    } else {
      // two arguments only: it uses the default decimal format
      if (env instanceof ExpressionContext) {
        // this is XSLT
        DecimalFormatManager dfm =
            ((ExpressionContext) env).getXSLStylesheet().getDecimalFormatManager();
        dfm.registerUsage(DecimalFormatManager.DEFAULT_NAME, this);
        // Note: if using the "default default", there will be no fixup call.
      } else {
        // using saxon:decimal-format in some other environment
      }
    }
  }