com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg Java Examples
The following examples show how to use
com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessingInstruction.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); }
Example #2
Source File: TransletOutput.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Parse the contents of this <xsltc:output> element. The only attribute * we recognise is the 'file' attribute that contains teh output filename. */ public void parseContents(Parser parser) { // Get the output filename from the 'file' attribute String filename = getAttribute("file"); // If the 'append' attribute is set to "yes" or "true", // the output is appended to the file. String append = getAttribute("append"); // Verify that the filename is in fact set if ((filename == null) || (filename.equals(EMPTYSTRING))) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "file"); } // Save filename as an attribute value template _filename = AttributeValue.create(this, filename, parser); if (append != null && (append.toLowerCase().equals("yes") || append.toLowerCase().equals("true"))) { _append = true; } else _append = false; parseChildren(parser); }
Example #3
Source File: StartsWithCall.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Type check the two parameters for this function */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Check that the function was passed exactly two arguments if (argumentCount() != 2) { ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, getName(), this); throw new TypeCheckError(err); } // The first argument must be a String, or cast to a String _base = argument(0); Type baseType = _base.typeCheck(stable); if (baseType != Type.String) _base = new CastExpr(_base, Type.String); // The second argument must also be a String, or cast to a String _token = argument(1); Type tokenType = _token.typeCheck(stable); if (tokenType != Type.String) _token = new CastExpr(_token, Type.String); return _type = Type.Boolean; }
Example #4
Source File: TransletOutput.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Parse the contents of this <xsltc:output> element. The only attribute * we recognise is the 'file' attribute that contains teh output filename. */ public void parseContents(Parser parser) { // Get the output filename from the 'file' attribute String filename = getAttribute("file"); // If the 'append' attribute is set to "yes" or "true", // the output is appended to the file. String append = getAttribute("append"); // Verify that the filename is in fact set if ((filename == null) || (filename.equals(EMPTYSTRING))) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "file"); } // Save filename as an attribute value template _filename = AttributeValue.create(this, filename, parser); if (append != null && (append.toLowerCase().equals("yes") || append.toLowerCase().equals("true"))) { _append = true; } else _append = false; parseChildren(parser); }
Example #5
Source File: If.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Parse the "test" expression and contents of this element. */ public void parseContents(Parser parser) { // Parse the "test" expression _test = parser.parseExpression(this, "test", null); // Make sure required attribute(s) have been set if (_test.isDummy()) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test"); return; } // Ignore xsl:if when test is false (function-available() and // element-available()) Object result = _test.evaluateAtCompileTime(); if (result != null && result instanceof Boolean) { _ignore = !((Boolean) result).booleanValue(); } parseChildren(parser); }
Example #6
Source File: When.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void parseContents(Parser parser) { _test = parser.parseExpression(this, "test", null); // Ignore xsl:if when test is false (function-available() and // element-available()) Object result = _test.evaluateAtCompileTime(); if (result != null && result instanceof Boolean) { _ignore = !((Boolean) result).booleanValue(); } parseChildren(parser); // Make sure required attribute(s) have been set if (_test.isDummy()) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test"); } }
Example #7
Source File: WithParam.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * The contents of a <xsl:with-param> elements are either in the element's * 'select' attribute (this has precedence) or in the element body. */ public void parseContents(Parser parser) { final String name = getAttribute("name"); if (name.length() > 0) { if (!XML11Char.isXML11ValidQName(name)) { ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); parser.reportError(Constants.ERROR, err); } setName(parser.getQNameIgnoreDefaultNs(name)); } else { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name"); } final String select = getAttribute("select"); if (select.length() > 0) { _select = parser.parseExpression(this, "select", null); } parseChildren(parser); }
Example #8
Source File: When.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void parseContents(Parser parser) { _test = parser.parseExpression(this, "test", null); // Ignore xsl:if when test is false (function-available() and // element-available()) Object result = _test.evaluateAtCompileTime(); if (result != null && result instanceof Boolean) { _ignore = !((Boolean) result).booleanValue(); } parseChildren(parser); // Make sure required attribute(s) have been set if (_test.isDummy()) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test"); } }
Example #9
Source File: TransformerImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Receive notification of a recoverable error. * The transformer must continue to provide normal parsing events after * invoking this method. It should still be possible for the application * to process the document through to the end. * * @param e The warning information encapsulated in a transformer * exception. * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ @Override public void error(TransformerException e) throws TransformerException { Throwable wrapped = e.getException(); if (wrapped != null) { System.err.println(new ErrorMsg(ErrorMsg.ERROR_PLUS_WRAPPED_MSG, e.getMessageAndLocation(), wrapped.getMessage())); } else { System.err.println(new ErrorMsg(ErrorMsg.ERROR_MSG, e.getMessageAndLocation())); } throw e; }
Example #10
Source File: TransformerImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Receive notification of a non-recoverable error. * The application must assume that the transformation cannot continue * after the Transformer has invoked this method, and should continue * (if at all) only to collect addition error messages. In fact, * Transformers are free to stop reporting events once this method has * been invoked. * * @param e The warning information encapsulated in a transformer * exception. * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ @Override public void fatalError(TransformerException e) throws TransformerException { Throwable wrapped = e.getException(); if (wrapped != null) { System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_PLUS_WRAPPED_MSG, e.getMessageAndLocation(), wrapped.getMessage())); } else { System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_MSG, e.getMessageAndLocation())); } throw e; }
Example #11
Source File: TransformerFactoryImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Receive notification of a non-recoverable error. * The application must assume that the transformation cannot continue * after the Transformer has invoked this method, and should continue * (if at all) only to collect addition error messages. In fact, * Transformers are free to stop reporting events once this method has * been invoked. * * @param e warning information encapsulated in a transformer * exception. * @throws TransformerException if the application chooses to discontinue * the transformation (always does in our case). */ @Override public void fatalError(TransformerException e) throws TransformerException { Throwable wrapped = e.getException(); if (wrapped != null) { System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_PLUS_WRAPPED_MSG, e.getMessageAndLocation(), wrapped.getMessage())); } else { System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_MSG, e.getMessageAndLocation())); } throw e; }
Example #12
Source File: CallTemplate.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void parseContents(Parser parser) { final String name = getAttribute("name"); if (name.length() > 0) { if (!XML11Char.isXML11ValidQName(name)) { ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name, this); parser.reportError(Constants.ERROR, err); } _name = parser.getQNameIgnoreDefaultNs(name); } else { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name"); } parseChildren(parser); }
Example #13
Source File: TemplatesImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Overrides the default readObject implementation since we decided * it would be cleaner not to serialize the entire tranformer * factory. [ ref bugzilla 12317 ] * We need to check if the user defined class for URIResolver also * implemented Serializable * if yes then we need to deserialize the URIResolver * Fix for bugzilla bug 22438 */ @SuppressWarnings("unchecked") private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException { SecurityManager security = System.getSecurityManager(); if (security != null){ String temp = SecuritySupport.getSystemProperty(DESERIALIZE_TRANSLET); if (temp == null || !(temp.length()==0 || temp.equalsIgnoreCase("true"))) { ErrorMsg err = new ErrorMsg(ErrorMsg.DESERIALIZE_TRANSLET_ERR); throw new UnsupportedOperationException(err.toString()); } } // We have to read serialized fields first. ObjectInputStream.GetField gf = is.readFields(); _name = (String)gf.get("_name", null); _bytecodes = (byte[][])gf.get("_bytecodes", null); _class = (Class[])gf.get("_class", null); _transletIndex = gf.get("_transletIndex", -1); _outputProperties = (Properties)gf.get("_outputProperties", null); _indentNumber = gf.get("_indentNumber", 0); if (is.readBoolean()) { _uriResolver = (URIResolver) is.readObject(); } _tfactory = new TransformerFactoryImpl(); }
Example #14
Source File: TransformerImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Implements JAXP's Transformer.setErrorListener() * Set the error event listener in effect for the transformation. * Register a message handler in the translet in order to forward * xsl:messages to error listener. * * @param listener The error event listener to use * @throws IllegalArgumentException */ @Override public void setErrorListener(ErrorListener listener) throws IllegalArgumentException { if (listener == null) { ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR, "Transformer"); throw new IllegalArgumentException(err.toString()); } _errorListener = listener; // Register a message handler to report xsl:messages if (_translet != null) _translet.setMessageHandler(new MessageHandler(_errorListener)); }
Example #15
Source File: XSLTC.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Compiles an XSL stylesheet pointed to by a URL * @param url An URL containing the input XSL stylesheet * @param name The name to assign to the translet class */ public boolean compile(URL url, String name) { try { // Open input stream from URL and wrap inside InputSource final InputStream stream = url.openStream(); final InputSource input = new InputSource(stream); input.setSystemId(url.toString()); return compile(input, name); } catch (IOException e) { _parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e)); return false; } }
Example #16
Source File: Copy.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void parseContents(Parser parser) { 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); } _useSets = new UseAttributeSets(useSets, parser); } parseChildren(parser); }
Example #17
Source File: ForEach.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void parseContents(Parser parser) { _select = parser.parseExpression(this, "select", null); parseChildren(parser); // make sure required attribute(s) have been set if (_select.isDummy()) { reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select"); } }
Example #18
Source File: TransformerImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Implements JAXP's Transformer.setOutputProperties(). * Set the output properties for the transformation. These properties * will override properties set in the Templates with xsl:output. * Unrecognised properties will be quitely ignored. * * @param properties The properties to use for the Transformer * @throws IllegalArgumentException Never, errors are ignored */ @Override public void setOutputProperties(Properties properties) throws IllegalArgumentException { if (properties != null) { final Enumeration names = properties.propertyNames(); while (names.hasMoreElements()) { final String name = (String) names.nextElement(); // Ignore lower layer properties if (isDefaultProperty(name, properties)) continue; if (validOutputProperty(name)) { _properties.setProperty(name, properties.getProperty(name)); } else { ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name); throw new IllegalArgumentException(err.toString()); } } } else { _properties = _propertiesClone; } }
Example #19
Source File: Copy.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void parseContents(Parser parser) { 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); } _useSets = new UseAttributeSets(useSets, parser); } parseChildren(parser); }
Example #20
Source File: Copy.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void parseContents(Parser parser) { 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); } _useSets = new UseAttributeSets(useSets, parser); } parseChildren(parser); }
Example #21
Source File: FunctionAvailableCall.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Argument of function-available call must be literal, typecheck * returns the type of function-available to be boolean. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { if (_type != null) { return _type; } if (_arg instanceof LiteralExpr) { return _type = Type.Boolean; } ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, "function-available", this); throw new TypeCheckError(err); }
Example #22
Source File: Parser.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Prints all compile-time warnings */ public void printWarnings() { final int size = _warnings.size(); if (size > 0) { System.err.println(new ErrorMsg(ErrorMsg.COMPILER_WARNING_KEY)); for (int i = 0; i < size; i++) { System.err.println(" " + _warnings.elementAt(i)); } } }
Example #23
Source File: FunctionAvailableCall.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Argument of function-available call must be literal, typecheck * returns the type of function-available to be boolean. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { if (_type != null) { return _type; } if (_arg instanceof LiteralExpr) { return _type = Type.Boolean; } ErrorMsg err = new ErrorMsg(ErrorMsg.NEED_LITERAL_ERR, "function-available", this); throw new TypeCheckError(err); }
Example #24
Source File: BinOpExpr.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final InstructionList il = methodGen.getInstructionList(); _left.translate(classGen, methodGen); _right.translate(classGen, methodGen); switch (_op) { case PLUS: il.append(_type.ADD()); break; case MINUS: il.append(_type.SUB()); break; case TIMES: il.append(_type.MUL()); break; case DIV: il.append(_type.DIV()); break; case MOD: il.append(_type.REM()); break; default: ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_BINARY_OP_ERR, this); getParser().reportError(Constants.ERROR, msg); } }
Example #25
Source File: XSLTC.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Compiles an XSL stylesheet pointed to by a URL * @param url An URL containing the input XSL stylesheet */ public boolean compile(URL url) { try { // Open input stream from URL and wrap inside InputSource final InputStream stream = url.openStream(); final InputSource input = new InputSource(stream); input.setSystemId(url.toString()); return compile(input, _className); } catch (IOException e) { _parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e)); return false; } }
Example #26
Source File: Parser.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Prints all compile-time warnings */ public void printWarnings() { final int size = _warnings.size(); if (size > 0) { System.err.println(new ErrorMsg(ErrorMsg.COMPILER_WARNING_KEY)); for (int i = 0; i < size; i++) { System.err.println(" " + _warnings.get(i)); } } }
Example #27
Source File: StringCall.java From hottub with GNU General Public License v2.0 | 5 votes |
public Type typeCheck(SymbolTable stable) throws TypeCheckError { final int argc = argumentCount(); if (argc > 1) { ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_ARG_ERR, this); throw new TypeCheckError(err); } if (argc > 0) { argument().typeCheck(stable); } return _type = Type.String; }
Example #28
Source File: UseAttributeSets.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Generate a call to the method compiled for this attribute set */ public void translate(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final SymbolTable symbolTable = getParser().getSymbolTable(); // Go through each attribute set and generate a method call for (int i=0; i<_sets.size(); i++) { // Get the attribute set name final QName name = (QName)_sets.elementAt(i); // Get the AttributeSet reference from the symbol table final AttributeSet attrs = symbolTable.lookupAttributeSet(name); // Compile the call to the set's method if the set exists if (attrs != null) { final String methodName = attrs.getMethodName(); il.append(classGen.loadTranslet()); il.append(methodGen.loadDOM()); il.append(methodGen.loadIterator()); il.append(methodGen.loadHandler()); il.append(methodGen.loadCurrentNode()); final int method = cpg.addMethodref(classGen.getClassName(), methodName, ATTR_SET_SIG); il.append(new INVOKESPECIAL(method)); } // Generate an error if the attribute set does not exist else { final Parser parser = getParser(); final String atrs = name.toString(); reportError(this, parser, ErrorMsg.ATTRIBSET_UNDEF_ERR, atrs); } } }
Example #29
Source File: Parser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private QName getQName(final String stringRep, boolean reportError, boolean ignoreDefaultNs) { // parse and retrieve namespace final int colon = stringRep.lastIndexOf(':'); if (colon != -1) { final String prefix = stringRep.substring(0, colon); final String localname = stringRep.substring(colon + 1); String namespace = null; // Get the namespace uri from the symbol table if (prefix.equals(XMLNS_PREFIX) == false) { namespace = _symbolTable.lookupNamespace(prefix); if (namespace == null && reportError) { final int line = getLineNumber(); ErrorMsg err = new ErrorMsg(ErrorMsg.NAMESPACE_UNDEF_ERR, line, prefix); reportError(ERROR, err); } } return getQName(namespace, prefix, localname); } else { if (stringRep.equals(XMLNS_PREFIX)) { ignoreDefaultNs = true; } final String defURI = ignoreDefaultNs ? null : _symbolTable.lookupNamespace(EMPTYSTRING); return getQName(defURI, null, stringRep); } }
Example #30
Source File: TransformerFactoryImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * javax.xml.transform.sax.TransformerFactory implementation. * Set the error event listener for the TransformerFactory, which is used * for the processing of transformation instructions, and not for the * transformation itself. * * @param listener The error listener to use with the TransformerFactory * @throws IllegalArgumentException */ @Override public void setErrorListener(ErrorListener listener) throws IllegalArgumentException { if (listener == null) { ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR, "TransformerFactory"); throw new IllegalArgumentException(err.toString()); } _errorListener = listener; }