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

com.sun.msv.relaxns.reader.GrammarState Maven / Gradle / Ivy

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

import com.sun.msv.reader.SimpleState;
import com.sun.msv.reader.State;
import com.sun.msv.util.StartTagInfo;

/**
 * parses <grammar> element.
 * 
 * @author Kohsuke KAWAGUCHI
 */
public class GrammarState extends SimpleState
{
    /** gets reader in type-safe fashion */
    protected RELAXNSReader getReader() { return (RELAXNSReader)reader; }

    protected State createChildState( StartTagInfo tag )
    {
        if(tag.localName.equals("namespace"))    return new NamespaceState();
        if(tag.localName.equals("topLevel"))    return new TopLevelState();
        if(tag.localName.equals("include"))        return new IncludeGrammarState();
        
        return null;
    }
    
    protected void startSelf()
    {
        super.startSelf();
        
        {// check relaxNamespaceVersion
            final String nsVersion = startTag.getAttribute("relaxNamespaceVersion");
            if( nsVersion==null )
                reader.reportWarning( RELAXNSReader.ERR_MISSING_ATTRIBUTE, "module", "relaxNamespaceVersion" );
            else
            if(!"1.0".equals(nsVersion))
                reader.reportWarning( RELAXNSReader.WRN_ILLEGAL_RELAXNAMESPACE_VERSION, nsVersion );
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy