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

com.sun.msv.reader.xmlschema.ElementRefState Maven / Gradle / Ivy

There is a newer version: 2.2.5.1
Show newest version
/*
 * @(#)$Id: ElementRefState.java,v 1.5 2003/06/09 20:37:34 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.xmlschema;

import com.sun.msv.grammar.Expression;
import com.sun.msv.grammar.ReferenceContainer;
import com.sun.msv.grammar.xmlschema.XMLSchemaSchema;
import com.sun.msv.reader.ExpressionWithoutChildState;

/**
 * used to parse <element > element with ref attribute.
 * 
 * @author Kohsuke KAWAGUCHI
 */
public class ElementRefState extends ExpressionWithoutChildState {

    protected Expression makeExpression() {
        final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
        
        // TODO: what attributes can be used with @ref?
        
        if( !startTag.containsAttribute("ref") )
            // existance of @ref must be checked before instanciation of this object.
            throw new Error();
        
        // this this tag has @ref.
        Expression exp = reader.resolveQNameRef(
            startTag, "ref",
            new XMLSchemaReader.RefResolver() {
                public ReferenceContainer get( XMLSchemaSchema g ) {
                    return g.elementDecls;
                }
            } );
        if( exp==null )        return Expression.epsilon;    // couldn't resolve QName.
        
        // minOccurs/maxOccurs is processed through interception
        return exp;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy