public void forceExpand()

in mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/mixin/AxiomSourcedElementMixin.java [200:259]


    public void forceExpand() {
        // The dataSource != null is required because this method may be called indirectly
        // by the constructor before the data source is set. After the constructor has completed,
        // isExpanded is always true if dataSource is null.
        if (!isExpanded && dataSource != null) {

            if (log.isDebugEnabled()) {
                log.debug("forceExpand: expanding element " + getPrintableName());
                if (forceExpandLog.isDebugEnabled()) {
                    // When using an OMSourcedElement, it can be particularly difficult to
                    // determine why an expand occurs... a stack trace should help debugging this
                    Exception e = new Exception("Debug Stack Trace");
                    forceExpandLog.debug("forceExpand stack", e);
                }
            }

            Builder builder;
            if (OMDataSourceUtil.isPushDataSource(dataSource)) {
                // Disable namespace repairing because the OMDataSource is required to produce well
                // formed
                // XML with respect to namespaces.
                builder =
                        new BuilderImpl(
                                new PushOMDataSourceInput(this, dataSource),
                                coreGetNodeFactory().getFactory2(),
                                PlainXMLModel.INSTANCE,
                                this);
            } else {
                // Get the XMLStreamReader
                XMLStreamReader readerFromDS;
                try {
                    readerFromDS = dataSource.getReader();
                } catch (XMLStreamException ex) {
                    throw new OMException(
                            "Error obtaining parser from data source for element "
                                    + getPrintableName(),
                            ex);
                }
                builder =
                        new BuilderImpl(
                                new FilteredXmlInput(
                                        new StAXPullInput(
                                                readerFromDS,
                                                AxiomXMLStreamReaderHelperFactory.INSTANCE),
                                        NamespaceRepairingFilter.DEFAULT),
                                coreGetNodeFactory().getFactory2(),
                                PlainXMLModel.INSTANCE,
                                this);
            }
            isExpanded = true;
            coreSetState(ATTRIBUTES_PENDING);
            try {
                do {
                    builder.next();
                } while (getState() == ATTRIBUTES_PENDING);
            } catch (DeferredParsingException ex) {
                throw AxiomExceptionTranslator.translate(ex);
            }
        }
    }