Jeez, you're making me sorry I even spoke up.  I set the test code to end at 128
because that is what YOU guys do in DeferredDocumentImpl.  After you set index
127 of fIdElement (the last index, line 1014) you increment fIdCount making it
128.  If you don't add any more elements, both the array size AND fIdCount will
be 128.  Later you call binarySearch with an end value of fIdCount and a target
value that's greater than the value in index 127.  That causes binarySearch to
TRY index 128.

The schema updated to 12/17 is appended below.  Move your debug code in
binarySearch to just before "int value  = values[middle];" (where the exception
is thrown) and run it through DOMCount.

-----Original Message-----
From: Andy Clark [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 03, 2000 7:23 PM
To: [EMAIL PROTECTED]
Subject: Re: BUG java.lang.ArrayIndexOutOfBoundsException: 128


"George T. Joseph" wrote:
>   int[] n = new int[128];
>   for(int i=0;i<n.length;i++)n[i]=i*2;
>   int rc = DeferredDocumentImpl.binarySearch(n, 0, 128,
Integer.parseInt(argv[0]));
>   System.out.println("Index: "+rc);

The start and end points passed into the binarySearch method
are INCLUSIVE. Therefore, you are causing the error by
specifying an end point OUTSIDE of the legal index values.

Change the end point from 128 to 127 and the binary search
function will work correctly.

As for Karen's problem, I want to run the sample file
through the latest code but we've updated the XML Schema
support to the 17 Dec 1999 Working Draft and her schema
is written to the November draft.

I was hoping someone would be willing to convert her file
to the latest draft so that I can test it. I would do it
but I'm bogged down trying to get a release together.

Better yet, is it possible to write an XSLT stylesheet to
transform the old XML Schema syntax to the new one? This
could be an extremely useful for people migrating their
schema documents. Just run it through Xalan and BAM! all
done. :)

--
Andy Clark * IBM, JTC - Silicon Valley * [EMAIL PROTECTED]


<?xml version="1.0" encoding="US-ASCII"?>
<!-- <!DOCTYPE schema SYSTEM "structures.dtd"> -->
<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 19991216//EN"
        "http://www.w3.org/TR/1999/WD-xmlschema-1-19991217/structures.dtd";>

<schema>

<!-- DATA TYPES -->

<datatype name="uri" source="string"/>

<datatype name="ces" source="string"/>

<datatype name="phone" source="string"/>

<datatype name="dn" source="string"/>

<datatype name="keyValue" source="string"/>

<datatype name="file" source="string"/>

<datatype name="textBlock" source="string"/>


<!-- DOCUMENT ELEMENT -->

<!-- SCHEMA -->

<element name="ris">
  <type content='elementOnly'>
   <element ref="ris-directory-schema" minOccurs='1' maxOccurs='*'/>
   <attribute name="xmlns"/>
  </type>
</element>

<element name="ris-directory-schema">
  <type content='elementOnly'>
    <group order="choice" minOccurs="0" maxOccurs="*">
      <element ref="class"/>
      <element ref="attribute-type"/>
   </group>
  </type>
</element>

<!-- element types common to class and attribute-type -->
<element name="name" type="string"/>
<element name="description" type="string"/>
<element name="rdn" type="string"/>
<element name="dn" type="distinguished-name"/>
<element name="childof" type="uri"/>

<element name="class">
  <type content='elementOnly'>
    <element ref="name" maxOccurs="*"/>
    <element ref="rdn" minOccurs="0" maxOccurs="1"/>
    <element ref="childof" minOccurs="0" maxOccurs="*"/>
    <element ref="description" minOccurs="0" maxOccurs="1"/>
    <element ref="attribute" minOccurs="0" maxOccurs="*"/>
    <attribute name="id" type="ID" minOccurs="1"/>
    <attribute name="superior" type="uri"/>
    <attribute name="obsolete" type="boolean" default="false"/>
    <attribute name="type" type="NMTOKEN" minOccurs="1">
         <datatype source='string'>
      <enumeration value="structural"/>
        <enumeration value="abstract"/>
        <enumeration value="auxiliary"/>
                  </datatype>
    </attribute>
  </type>
</element>


<!--
  This is changed from DSML in that we moved some attributes here just
  for the readability of the document.  We use the reference only for the
  description now.
-->
<element name="attribute">
  <type content="empty">
    <attribute name="ref" type="uri" minOccurs="0"/>
    <attribute name="required" type="boolean" minOccurs="1"/>
    <attribute name="singular" type="boolean" default="false"/>
  </type>
</element>


<!--
  The only thing we are really using out of this is the description
  See comments in file header regarding why some elements are commented
  out.
-->
<element name="type">
  <type  content="empty">
  <attribute name="type" type="NMTOKEN" minOccurs="1">
  <datatype source='string'>
        <enumeration value="string"/>
        <enumeration value="ces"/>
        <enumeration value="phone"/>
        <enumeration value="binary"/>
        <enumeration value="dn"/>
        <enumeration value="integer"/>
        <enumeration value="positive-integer"/>
        <enumeration value="timeInstant"/>
        <enumeration value="file"/>
        <enumeration value="boolean"/>
        <enumeration value="uri"/>
        <enumeration value="keyValue"/>
        <enumeration value="textBlock"/>
        <enumeration value="decimal"/>
                  </datatype>
  </attribute>
  </type>
</element>

<element name="attribute-type">
  <type>
    <element ref="name" minOccurs="1" maxOccurs="1"/>
    <element ref="type" minOccurs="1" maxOccurs="1"/>
    <element ref="description" minOccurs="0"/>
    <element ref="object-identifier" minOccurs="0"/>
<!--
    <element name="syntax" type="oid" minOccurs="0"/>
    <element name="equality" type="oid" minOccurs="0"/>
    <element name="ordering" type="oid" minOccurs="0"/>
    <element name="substring" type="oid" minOccurs="0"/>
-->
    <attribute name="id" type="ID" minOccurs="1"/>
    <attribute name="sup" type="uri"/>
    <attribute name="obsolete" type="boolean" default="false"/>
    <attribute name="user-modification" type="boolean" default="true"/>
  </type>
</element>



</schema>

Reply via email to