Package com.sun.org.apache.xalan.internal.xsltc.compiler.util

Examples of com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg


        final Template template = stable.lookupTemplate(_name);
        if (template != null) {
            typeCheckContents(stable);
        }
        else {
            ErrorMsg err = new ErrorMsg(ErrorMsg.TEMPLATE_UNDEF_ERR,_name,this);
            throw new TypeCheckError(err);
        }
        return Type.Void;
    }
View Full Code Here


        final SymbolTable stable = parser.getSymbolTable();

        // Handle the 'name' attribute
        String name = getAttribute("name");
        if (name == EMPTYSTRING) {
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ELEM_NAME_ERR,
                                        name, this);
            parser.reportError(WARNING, msg);
            parseChildren(parser);
            _ignore = true;     // Ignore the element if the QName is invalid
            return;
        }

        // Get namespace attribute
        String namespace = getAttribute("namespace");

        // Optimize compilation when name is known at compile time
        _isLiteralName = Util.isLiteral(name);
        if (_isLiteralName) {
            if (!XML11Char.isXML11ValidQName(name)) {
                ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ELEM_NAME_ERR,
                                            name, this);
                parser.reportError(WARNING, msg);
                parseChildren(parser);
                _ignore = true;         // Ignore the element if the QName is invalid
                return;
            }

            final QName qname = parser.getQNameSafe(name);
            String prefix = qname.getPrefix();
            String local = qname.getLocalPart();

            if (prefix == null) {
                prefix = EMPTYSTRING;
            }

            if (!hasAttribute("namespace")) {
                namespace = lookupNamespace(prefix);
                if (namespace == null) {
                    ErrorMsg err = new ErrorMsg(ErrorMsg.NAMESPACE_UNDEF_ERR,
                                                prefix, this);
                    parser.reportError(WARNING, err);
                    parseChildren(parser);
                    _ignore = true;     // Ignore the element if prefix is undeclared
                    return;
                }
                _prefix = prefix;
                _namespace = new AttributeValueTemplate(namespace, parser, this);
            }
            else {
                if (prefix == EMPTYSTRING) {
                    if (Util.isLiteral(namespace)) {
                        prefix = lookupPrefix(namespace);
                        if (prefix == null) {
                            prefix = stable.generateNamespacePrefix();
                        }
                    }

                    // Prepend prefix to local name
                    final StringBuffer newName = new StringBuffer(prefix);
                    if (prefix != EMPTYSTRING) {
                        newName.append(':');
                    }
                    name = newName.append(local).toString();
                }
                _prefix = prefix;
                _namespace = new AttributeValueTemplate(namespace, parser, this);
            }
        }
        else {
            _namespace = (namespace == EMPTYSTRING) ? null :
                         new AttributeValueTemplate(namespace, parser, this);
        }

        _name = new AttributeValueTemplate(name, parser, this);

        final String useSets = getAttribute("use-attribute-sets");
        if (useSets.length() > 0) {
            if (!Util.isValidQNames(useSets)) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, useSets, this);
                parser.reportError(Constants.ERROR, err);
            }
            setFirstElement(new UseAttributeSets(useSets, parser));
        }
View Full Code Here

            // Store existing DOM on stack - must be restored when loop is done
            il.append(methodGen.loadDOM());

            // <xsl:sort> cannot be applied to a result tree - issue warning
            if (sortObjects.size() > 0) {
                ErrorMsg msg = new ErrorMsg(ErrorMsg.RESULT_TREE_SORT_ERR,this);
                getParser().reportError(WARNING, msg);
            }

            // Put the result tree on the stack (DOM)
            _select.translate(classGen, methodGen);
View Full Code Here

                canonicalEncoding = Encodings.convertMime2JavaEncoding(_encoding);
                OutputStreamWriter writer =
                    new OutputStreamWriter(System.out, canonicalEncoding);
            }
            catch (java.io.UnsupportedEncodingException e) {
                ErrorMsg msg = new ErrorMsg(ErrorMsg.UNSUPPORTED_ENCODING,
                                            _encoding, this);
                parser.reportError(Constants.WARNING, msg);
            }
            outputProperties.setProperty(OutputKeys.ENCODING, _encoding);
        }

        // Should the XML header be omitted - translate to true/false
        attrib = getAttribute("omit-xml-declaration");
        if (!attrib.equals(Constants.EMPTYSTRING)) {
            if (attrib.equals("yes")) {
                _omitHeader = true;
            }
            outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, attrib);
        }

        // Add 'standalone' decaration to output - use text as is
        _standalone = getAttribute("standalone");
        if (_standalone.equals(Constants.EMPTYSTRING)) {
            _standalone = null;
        }
        else {
            outputProperties.setProperty(OutputKeys.STANDALONE, _standalone);
        }

        // Get system/public identifiers for output DOCTYPE declaration
        _doctypeSystem = getAttribute("doctype-system");
        if (_doctypeSystem.equals(Constants.EMPTYSTRING)) {
            _doctypeSystem = null;
        }
        else {
            outputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, _doctypeSystem);
        }


        _doctypePublic = getAttribute("doctype-public");
        if (_doctypePublic.equals(Constants.EMPTYSTRING)) {
            _doctypePublic = null;
        }
        else {
            outputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, _doctypePublic);
        }

        // Names the elements of whose text contents should be output as CDATA
        _cdata = getAttribute("cdata-section-elements");
        if (_cdata.equals(Constants.EMPTYSTRING)) {
            _cdata = null;
        }
        else {
            StringBuffer expandedNames = new StringBuffer();
            StringTokenizer tokens = new StringTokenizer(_cdata);

            // Make sure to store names in expanded form
            while (tokens.hasMoreTokens()) {
                String qname = tokens.nextToken();
                if (!XML11Char.isXML11ValidQName(qname)) {
                    ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, qname, this);
                    parser.reportError(Constants.ERROR, err);
                }
                expandedNames.append(
                   parser.getQName(qname).toString()).append(' ');
            }
View Full Code Here

        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);
        }
View Full Code Here

    /**
     * Translate this node into JVM bytecodes.
     */
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  ErrorMsg msg = new ErrorMsg(ErrorMsg.NOT_IMPLEMENTED_ERR,
            getClass(), this);
  getParser().reportError(FATAL, msg);
    }
View Full Code Here

  }
  if (InternalTypeMap.maps(tleft, _type) != null) {
      return _type;
  }
  // throw new TypeCheckError(this); 
  throw new TypeCheckError(new ErrorMsg(
      ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString()));
    }
View Full Code Here

  Stylesheet context = parser.getCurrentStylesheet();
       
  String docToLoad = getAttribute("href");
  try {
      if (context.checkForLoop(docToLoad)) {
    final ErrorMsg msg = new ErrorMsg(ErrorMsg.CIRCULAR_INCLUDE_ERR,
                                                  docToLoad, this);
    parser.reportError(Constants.FATAL, msg);
    return;
      }

      InputSource input = null;
      XMLReader reader = null;
      String currLoadedDoc = context.getSystemId();
      SourceLoader loader = context.getSourceLoader();
           
            // Use SourceLoader if available
      if (loader != null) {
    input = loader.loadSource(docToLoad, currLoadedDoc, xsltc);
                if (input != null) {
                    docToLoad = input.getSystemId();
                    reader = xsltc.getXMLReader();
                } else if (parser.errorsFound()) {
                    return;
                }
      }

            // No SourceLoader or not resolved by SourceLoader
            if (input == null) {
                docToLoad = SystemIDResolver.getAbsoluteURI(docToLoad, currLoadedDoc);
                input = new InputSource(docToLoad);
      }

      // Return if we could not resolve the URL
      if (input == null) {
    final ErrorMsg msg =
        new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this);
    parser.reportError(Constants.FATAL, msg);
    return;
      }

      final SyntaxTreeNode root;
View Full Code Here

  final Vector whenElements = new Vector();
  Otherwise otherwise = null;
  Enumeration elements = elements();

  // These two are for reporting errors only
  ErrorMsg error = null;
  final int line = getLineNumber();

  // Traverse all child nodes - must be either When or Otherwise
  while (elements.hasMoreElements()) {
      Object element = elements.nextElement();
      // Add a When child element
      if (element instanceof When) {
    whenElements.addElement(element);
      }
      // Add an Otherwise child element
      else if (element instanceof Otherwise) {
    if (otherwise == null) {
        otherwise = (Otherwise)element;
    }
    else {
        error = new ErrorMsg(ErrorMsg.MULTIPLE_OTHERWISE_ERR, this);
        getParser().reportError(Constants.ERROR, error);
    }
      }
      else if (element instanceof Text) {
    ((Text)element).ignore();
      }
      // It is an error if we find some other element here
      else {
    error = new ErrorMsg(ErrorMsg.WHEN_ELEMENT_ERR, this);
    getParser().reportError(Constants.ERROR, error);
      }
  }

  // Make sure that there is at least one <xsl:when> element
  if (whenElements.size() == 0) {
      error = new ErrorMsg(ErrorMsg.MISSING_WHEN_ERR, this);
      getParser().reportError(Constants.ERROR, error);
      return;
  }

  InstructionList il = methodGen.getInstructionList();
View Full Code Here

     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  if (argument() instanceof LiteralExpr) {
      return _type = Type.Boolean;
  }
  ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR,
            "element-available", this);
  throw new TypeCheckError(err);
    }
View Full Code Here

TOP

Related Classes of com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.