Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.js crashes on invalid keyrefs #1

Open
CruzR opened this issue Mar 18, 2013 · 0 comments
Open

xml.js crashes on invalid keyrefs #1

CruzR opened this issue Mar 18, 2013 · 0 comments

Comments

@CruzR
Copy link

CruzR commented Mar 18, 2013

Here's a minimal test case:

Schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="foo">
        <xs:complexType>
          <xs:attribute name="index" type="xs:int"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="bar">
        <xs:complexType>
          <xs:attribute name="foo" type="xs:int"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:key name="fooIndex">
    <xs:selector xpath="./foo"/>
    <xs:field xpath="@index"/>
  </xs:key>
  <xs:keyref name="indexRef" refer="fooIndex">
    <xs:selector xpath="./bar"/>
    <xs:field xpath="@foo"/>
  </xs:keyref>
</xs:element>
</xs:schema>

XML:

<test>
<foo index="1"/>
<bar foo="2"/>
</test>

When I try to validate this on Firefox 19.0.2 on Windows XP, the console is cleared and the output switches to Validating..., but nothing ever happens (although the UI still works). When I do the same with Firebug enabled, the script seems to get into an infinite loop. The expected behaviour is:

$ xmllint --noout --schema test.xsd test.xml
test.xml:3: Schemas validity error : Element 'bar': No match found for key-sequence ['2'] of keyref 'indexRef'.
test.xml fails to validate
sterpe added a commit that referenced this issue Mar 6, 2015
Merge pull request #5 from sterpe/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant