In JaxMeXS, method XSObject.getLocator() throws an IllegalStateException
when called for a built-in type.  However, the JavaDoc method description
does not specify that the method is allowed to throw IllegalStateException.


Either the method show not throw IllegalStateException or the documentation should specify when IllegalStateException can be thrown.

(If the first option is chosen, the method chould return null or could
return a locator that represents a position in the schema for XML schemas
(XMLSchema.xsd) from the schema specification.)

(Also, note that the method description currently says "... the objects
location" (which should be "... the object's location").)

Attached in a test program the demonstrates the problem.

This problem exists in JaxMeXS in JaxMe 0.3.1, 0.4beta, and
the default CVS branch (as of 2005-05-16).


Daniel








package test;

import org.apache.ws.jaxme.xs.*;
import org.apache.ws.jaxme.xs.parser.*;
import org.apache.ws.jaxme.xs.xml.*;
import org.xml.sax.*;
import javax.xml.parsers.ParserConfigurationException;


import java.io.*;

public class CheckBug_BuiltinLocatorException
{


    public static void main( String[] args )
        throws Exception
    {
        System.err.println( "Checking bug: undocumented exception getting 
locator from builtin type" );
        String schemaContent =
            ""
            + "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
            + "<xsd:schema "
            + "  xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; "
            + "  xmlns:xsdi=\"http://www.w3.org/2001/XMLSchema-instance\"; "
            + "  xsdi:schemaLocation=\"http://www.w3.org/2001/XMLSchema "
            + "  http://www.w3.org/2001/XMLSchema.xsd\"; "
            + "  > "
            + " "
            + "</xsd:schema> "
            ;

            InputSource source = 
                new InputSource( new ByteArrayInputStream( 
                                     schemaContent.getBytes( "ASCII" ) ) );
            source.setSystemId( "someScheme://x/whatever");

            /**
               Symptom:  ???

             */
            XSParser parser = new XSParser();
            XSSchema schema = parser.parse( source );
            XSType first = schema.getBuiltinTypes()[ 0 ];
            
            try {
                Locator locator = first.getLocator();
                System.err.println( "bug fixed" );
            }   
            catch ( IllegalStateException e ) {
                System.err.println( "bug still exists if exception not 
documented" );
            }
            


                
    } // main(...)


} // class CheckBug_BuiltinLocatorException


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to