private static void readSCXML()

in src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java [2306:2370]


    private static void readSCXML(final XMLStreamReader reader, final Configuration configuration, final SCXML scxml)
            throws IOException, ModelException, XMLStreamException {

        scxml.setDatamodelName(readAV(reader, SCXMLConstants.ATTR_DATAMODEL));
        scxml.setExmode(readAV(reader, SCXMLConstants.ATTR_EXMODE));
        scxml.setInitial(readAV(reader, SCXMLConstants.ATTR_INITIAL));
        scxml.setName(readAV(reader, SCXMLConstants.ATTR_NAME));
        scxml.setProfile(readAV(reader, SCXMLConstants.ATTR_PROFILE));
        scxml.setVersion(readRequiredAV(reader, SCXMLConstants.ELEM_SCXML, SCXMLConstants.ATTR_VERSION));
        final String binding = readAV(reader, SCXMLConstants.ATTR_BINDING);
        if (binding != null) {
            if (SCXMLConstants.ATTR_BINDING_LATE.equals(binding)) {
                scxml.setLateBinding(true);
            } else if (SCXMLConstants.ATTR_BINDING_EARLY.equals(binding)) {
                scxml.setLateBinding(false);
            } else {
                reportIgnoredAttribute(reader, configuration, SCXMLConstants.ELEM_SCXML, SCXMLConstants.ATTR_BINDING, binding);
            }
        }
        if (!SCXML_REQUIRED_VERSION.equals(scxml.getVersion())) {
            throw new ModelException(new MessageFormat(ERR_INVALID_VERSION).format(new Object[] {scxml.getVersion()}));
        }
        scxml.setNamespaces(readNamespaces(reader));

        boolean hasGlobalScript = false;

        loop : while (reader.hasNext()) {
            String name, nsURI;
            switch (reader.next()) {
                case XMLStreamConstants.START_ELEMENT:
                    nsURI = reader.getNamespaceURI();
                    name = reader.getLocalName();
                    if (SCXMLConstants.XMLNS_SCXML.equals(nsURI)) {
                        switch (name) {
                        case SCXMLConstants.ELEM_STATE:
                            readState(reader, configuration, scxml, null);
                            break;
                        case SCXMLConstants.ELEM_PARALLEL:
                            readParallel(reader, configuration, scxml, null);
                            break;
                        case SCXMLConstants.ELEM_FINAL:
                            readFinal(reader, configuration, scxml, null);
                            break;
                        case SCXMLConstants.ELEM_DATAMODEL:
                            readDatamodel(reader, configuration, scxml, null);
                            break;
                        default:
                            if (SCXMLConstants.ELEM_SCRIPT.equals(name) && !hasGlobalScript) {
                                readGlobalScript(reader, configuration, scxml);
                                hasGlobalScript = true;
                            } else {
                                reportIgnoredElement(reader, configuration, SCXMLConstants.ELEM_SCXML, nsURI, name);
                            }
                            break;
                        }
                    } else {
                        reportIgnoredElement(reader, configuration, SCXMLConstants.ELEM_SCXML, nsURI, name);
                    }
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    break loop;
                default:
            }
        }
    }