This project is archived. Its data is read-only.

Oga.parse_xml fails with emsg: 'end of input, expected closing tag'

Created by: skoona

Cannot read and parse this xml file. Gem does not appear to recognize the final closing element and close the document at that point. I removed all blank lines after the closing tag, with no effect on this error.

I cannot use the gem at this point. Please help figure out why step one fails, reading a xml file.

This is the statement

@xml_doc =  Oga.parse_xml(File.open('accessregistry.xml', 'r')) # .xpath("//accessRegistry/resource")

This is the xml file

<?xml version="1.0" encoding="UTF-8"?>
<accessRegistry>
  <usage><![CDATA[

   Along with class AccessRegistry and module AccessControl, this file contains those
   application resource that should be documented and/or secured. This file is pre-processed
   by the class AccessRegistryUtility to enable the overall Authorization capability.

   Authorization is accomplished by first declaring those resources which need to be secured.  URI's are plain
   text strings which contain the label of the thing to be secured.  On the surrounding <resource> statement
   is a 'secured' attribute which indicates if this resource record is secure or not.  If its not, this
   record is considered documentation and will always return true to the #has_access?() api.

   Second, each entry is evaluated using the semantics of CRUD.  CREATE, READ, UPDATE, DELETE permissions
   each contain a list of authorized roles which a user MUST match in order to be considered as having
   permission.  The user object is expected to have an array list of authorization roles which they were
   granted by some administrator.  Permission entries are considered and created at application design time
   and represent the application's clickable capabilities or pages and task links.

   Each authorized role in a permission statement may have one additional attribute named options.  An options
   attribute is composed of a string with one or more comma separated values; ex. options="OWNER,SCHEDULER,MANAGER".
   These entry if present must be matched by user's provided option, for the users authorization request to be
   granted.  Having the correct authorized role and the wrong or missing option, will cause the request to
   be denied.  If an authorized role is defined with an options present, it must be matched.  The possibility of
   a authorization request occurring against a authorized role that was not defined with the optional options attribute
   will simply be ignored; i.e. no attempt will be made to evaluate an options attribute that does not exist.

   In summary, if every application resource and action is predefined in this registry and the
   #has_[access|create|read|update|delete]? api's are used to check access; the application can secure and
   easily administer its core capabilities.



                        -*-*-*-   Table of Contents  -*-*-*-

     * Menu Page Registry                 All pages accessable from a menu
     * GLOBAL System Resources          Unsecured (login, logout, etc.)

     * GLOBAL User Pages                Unsecured (home )
     * PROTECTED Task Links               Secured Navigation Links.  (Create Account, Admin, etc.)

     * Development Resources        Secured pages which show system activity or state


   * FULL RESOURCE SYNTAX **********************************************

    <resource secured="true|false">
        <uri>anyString</uri>
        <regex>.*a4j_3_1_4.*</regex>
        <description></description>
        <permission type="CREATE|READ|UPDATE|DELETE">
            <authorizedRoles>
                <authorizedRole options="anyOption">security-role-name</authorizedRole>
                <authorizedRole>security-user-group-name</authorizedRole>
                <authorizedRole>All Authorized Users</authorizedRole>
            </authorizedRoles>
        </permission>
    </resource>



   * PARTIAL RESOURCE SYNTAX *******************************************

    <resource secured="false">
        <uri>anyString</uri>
        <description>Any String can be a URI.</description>
    </resource>

            ]]>
</usage>

<!--========================= MENU PAGE REGISTRY  ================================ -->
    <!--============== RSpec Test Data  ========== -->
    <resource secured="true">
        <uri>testing/role/progressive</uri>
        <description>Testing Resource Only: Progressive Capability</description>
        <permission type="READ">
            <authorizedRoles>
                <authorizedRole>Test.Action.Create</authorizedRole>
                <authorizedRole>Test.Action.Read</authorizedRole>
                <authorizedRole>Test.Action.Update</authorizedRole>
                <authorizedRole>Test.Action.Delete</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="UPDATE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Update</authorizedRole>
                <authorizedRole>Test.Action.Create</authorizedRole>
                <authorizedRole>Test.Action.Delete</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="CREATE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Create</authorizedRole>
                <authorizedRole>Test.Action.Delete</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="DELETE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Delete</authorizedRole>
                <authorizedRole>Developer.Access.Status</authorizedRole>
            </authorizedRoles>
        </permission>
    </resource>

    <resource secured="true">
        <uri>testing/role/absolutes</uri>
        <description>Testing Resource Only: Absolute Capability</description>
        <permission type="READ">
            <authorizedRoles>
                <authorizedRole>Test.Action.Read</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="UPDATE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Update</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="CREATE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Create</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="DELETE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Delete</authorizedRole>
                <authorizedRole>Developer.Access.Status</authorizedRole>
            </authorizedRoles>
        </permission>
    </resource>

    <resource secured="true">
        <uri>testing/role/options</uri>
        <description>Testing Resource Only: Options Special Ownership Granting Capability</description>
        <permission type="READ">
            <authorizedRoles>
                <authorizedRole>Test.Action.Read</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="UPDATE">
            <authorizedRoles>
                <authorizedRole options="OBJECT-OWNER">Test.Action.Read</authorizedRole>
                <authorizedRole>Test.Action.Update</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="CREATE">
            <authorizedRoles>
                <authorizedRole options="CLIENT-MANAGER">Test.Action.Read</authorizedRole>
                <authorizedRole>Test.Action.Create</authorizedRole>
            </authorizedRoles>
        </permission>
        <permission type="DELETE">
            <authorizedRoles>
                <authorizedRole>Test.Action.Delete</authorizedRole>
                <authorizedRole>Developer.Access.Status</authorizedRole>
            </authorizedRoles>
        </permission>
    </resource>

    <!--========================= GLOBAL SYSTEM RESOURCES ============================ -->

    <resource secured="false"> <!-- This resource is not protected, since unauthorized users need to see it. -->
        <uri>/signout</uri>
        <description>Logout Page</description>
    </resource>
    <resource secured="false"> <!-- This resource is not protected, since unauthorized users need to see it. -->
        <uri>/signin</uri>
        <description>Login Page</description>
    </resource>

    <resource secured="false">
        <uri>pages/home</uri>
        <description>Home Page</description>
    </resource>
    <resource secured="false">
        <uri>pages/help</uri>
        <description>Help Page</description>
    </resource>
    <resource secured="false">
        <uri>pages/contact</uri>
        <description>Contact Us Page</description>
    </resource>
    <resource secured="false">
        <uri>pages/about</uri>
        <description>About Us Page</description>
    </resource>

    <!--=========================  DEVELOPMENT RESOURCES  ============================ -->
    <resource secured="true">
      <uri>/developer</uri>
      <description>System Status Page for Developers</description>
      <permission type="READ">
        <authorizedRoles>
          <authorizedRole>Developer.Access.Status</authorizedRole>
        </authorizedRoles>
      </permission>
    </resource>

    <!--=========================    GLOBAL USER PAGES    ============================ -->

</accessRegistry>

This is the error/exceptions

LL::ParserError: Unexpected end of input, expected element closing tag instead on line 204
           parser_error at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/oga-0.3.1-java/lib/oga/xml/parser.rb:255
             each_token at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/oga-0.3.1-java/lib/oga/xml/parser.rb:231
                  parse at org/libll/Driver.java:303
                  parse at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/oga-0.3.1-java/lib/oga/xml/parser.rb:262
              parse_xml at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/oga-0.3.1-java/lib/oga/oga.rb:12
             initialize at /Users/jscott/rDeveloper/RpgService/lib/utility/access_registry_utility.rb:68
         AccessRegistry at /Users/jscott/rDeveloper/RpgService/app/domains/access_registry.rb:66
                 (root) at /Users/jscott/rDeveloper/RpgService/app/domains/access_registry.rb:61
                require at org/jruby/RubyKernel.java:1071
                 (root) at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:1
                require at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:247
        load_dependency at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:232
                require at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:247
        require_or_load at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:348
  load_missing_constant at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:480
          const_missing at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:180
                   load at org/jruby/RubyKernel.java:1087
                 (root) at /Users/jscott/rDeveloper/RpgService/spec/domains/access_registry_spec.rb:46
                 (root) at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:1
                   load at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:241
        load_dependency at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:232
                   each at org/jruby/RubyArray.java:1613
                   load at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/activesupport-4.1.10/lib/active_support/dependencies.rb:241
        load_spec_files at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226
        load_spec_files at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224
                  setup at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:97
                    run at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:85
                    run at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:70
                   load at org/jruby/RubyKernel.java:1087
                 invoke at /Users/jscott/.rvm/gems/jruby-1.7.19@bmicruby/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:38
Assignee Loading
Time tracking Loading