public void doTag()

in jelly-tags/betwixt/src/main/java/org/apache/commons/jelly/tags/betwixt/ParseTag.java [67:124]


    public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException {
        if ( var == null ) {
            throw new MissingAttributeException( "var" );
        }
        if ( rootClass == null ) {
            throw new MissingAttributeException( "rootClass" );
        }

        reader.setXMLIntrospector(getIntrospector());

        Class theClass = null;
        try {
            theClass = getClassLoader().loadClass( rootClass );
        }
        catch (Exception e) {
            throw new JellyTagException( "Could not load class called: " + rootClass, e );
        }

        if ( theClass == null ) {
            throw new JellyTagException( "Could not load class called: " + rootClass );
        }

        try {
            if ( path != null ) {
                reader.registerBeanClass( path, theClass );
            }
            else {
                reader.registerBeanClass( theClass );
            }
        }
        catch (IntrospectionException e) {
            throw new JellyTagException(e);
        }

        Object value = null;
        if ( uri != null ) {
            invokeBody(output);

            try {
                URL url = context.getResource( uri );
                value = reader.parse( url.toString() );
            } catch (IOException e) {
                throw new JellyTagException(e);
            } catch (SAXException e) {
                throw new JellyTagException(e);
            }
        }
        else {

            // invoke the body and pass that into the reader
            XMLOutput newOutput = new XMLOutput( reader );

            invokeBody(newOutput);

            value = reader.getRoot();
        }
        context.setVariable( var, value );
    }