All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.msv.reader.trex.IncludePatternState Maven / Gradle / Ivy

There is a newer version: 2.2.5.1
Show newest version
/*
 * @(#)$Id: IncludePatternState.java,v 1.12 2003/06/09 20:37:29 kk122374 Exp $
 *
 * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 * 
 */
package com.sun.msv.reader.trex;

import com.sun.msv.grammar.Expression;
import com.sun.msv.reader.AbortException;
import com.sun.msv.reader.ExpressionOwner;
import com.sun.msv.reader.ExpressionWithoutChildState;

/**
 * <include> element in the pattern. (<externalRef> of RELAX NG).
 * 
 * @author Kohsuke KAWAGUCHI
 */
public class IncludePatternState extends ExpressionWithoutChildState implements ExpressionOwner
{
    protected Expression included = Expression.nullSet;
    // assign a default value just in case something goes wrong and onEndChild is not called.
    
    public void onEndChild( Expression included ) {
        this.included = included;
    }
    
    protected Expression makeExpression() {
        final String href = startTag.getAttribute("href");
        
        if(href==null)
        {// name attribute is required.
            reader.reportError( TREXBaseReader.ERR_MISSING_ATTRIBUTE,
                startTag.localName,"href");
            // recover by returning something that can be interpreted as Pattern
            return Expression.nullSet;
        }
        
        try {
            reader.switchSource(this,href,new RootIncludedPatternState(this));
        } catch( AbortException e ) {} // recover by ignoring an error
        
        // onEndChild method is called inside the above function call and
        // included will be set.
        
        return included;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy