FileDocCategorySizeDatePackage
UnsupportedElement.javaAPI DocJava SE 6 API5106Tue Jun 10 00:22:30 BST 2008com.sun.org.apache.xalan.internal.xsltc.compiler

UnsupportedElement

public final class UnsupportedElement extends SyntaxTreeNode
author
Morten Jorgensen

Fields Summary
private Vector
_fallbacks
private ErrorMsg
_message
private boolean
_isExtension
Constructors Summary
public UnsupportedElement(String uri, String prefix, String local, boolean isExtension)
Basic consutrcor - stores element uri/prefix/localname


               
             
	super(uri, prefix, local);
	_isExtension = isExtension;
    
Methods Summary
public voiddisplay(int indent)
Displays the contents of this element

	indent(indent);
	Util.println("Unsupported element = " + _qname.getNamespace() +
		     ":" + _qname.getLocalPart());
	displayContents(indent + IndentIncrement);
    
public voidparseContents(com.sun.org.apache.xalan.internal.xsltc.compiler.Parser parser)
Find any fallback in the descendant nodes; then activate & parse it

    	processFallbacks(parser);
    
private voidprocessFallbacks(com.sun.org.apache.xalan.internal.xsltc.compiler.Parser parser)
Scan and process all fallback children of the unsupported element.


	Vector children = getContents();
	if (children != null) {
	    final int count = children.size();
	    for (int i = 0; i < count; i++) {
		SyntaxTreeNode child = (SyntaxTreeNode)children.elementAt(i);
		if (child instanceof Fallback) {
		    Fallback fallback = (Fallback)child;
		    fallback.activate();
		    fallback.parseContents(parser);
		    if (_fallbacks == null) {
		    	_fallbacks = new Vector();
		    }
		    _fallbacks.addElement(child);
		}
	    }
	}
    
public voidsetErrorMessage(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg message)
There are different categories of unsupported elements (believe it or not): there are elements within the XSLT namespace (these would be elements that are not yet implemented), there are extensions of other XSLT processors and there are unrecognised extension elements of this XSLT processor. The error message passed to this method should describe the unsupported element itself and what category the element belongs in.

	_message = message;
    
public voidtranslate(com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator classGen, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator methodGen)
Translate the fallback element (if any).

	if (_fallbacks != null) {
	    int count = _fallbacks.size();
	    for (int i = 0; i < count; i++) {
	        Fallback fallback = (Fallback)_fallbacks.elementAt(i);
	        fallback.translate(classGen, methodGen);
	    }
	}
	// We only go into the else block in forward-compatibility mode, when
	// the unsupported element has no fallback.
	else {		
	    // If the unsupported element does not have any fallback child, then
	    // at runtime, a runtime error should be raised when the unsupported
	    // element is instantiated. Otherwise, no error is thrown.
	    ConstantPoolGen cpg = classGen.getConstantPool();
	    InstructionList il = methodGen.getInstructionList();
	    
	    final int unsupportedElem = cpg.addMethodref(BASIS_LIBRARY_CLASS, "unsupported_ElementF",
                                                         "(" + STRING_SIG + "Z)V");	 
	    il.append(new PUSH(cpg, getQName().toString()));
	    il.append(new PUSH(cpg, _isExtension));
	    il.append(new INVOKESTATIC(unsupportedElem));		
	}
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypetypeCheck(com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable stable)
Run type check on the fallback element (if any).

	
	if (_fallbacks != null) {
	    int count = _fallbacks.size();
	    for (int i = 0; i < count; i++) {
	        Fallback fallback = (Fallback)_fallbacks.elementAt(i);
	        fallback.typeCheck(stable);
	    }
	}
	return Type.Void;