users@jaxb.java.net

Re: reference error

From: Meredith Gregory <lgreg.meredith_at_gmail.com>
Date: Thu, 23 Oct 2008 15:23:48 -0700

JAXBians,

i discovered that if i use reflection to dig out the DelayedRef and then
call run on this, it resolves the reference and everything works. Obviously,
this is a hack and will break if someone changes the internal
representation. Any help would be much appreciated.

Best wishes,

--greg

On Thu, Oct 23, 2008 at 11:05 AM, Meredith Gregory <lgreg.meredith_at_gmail.com
> wrote:

> JAXBians,
>
> Actually, i have groveled through the source a bit and i suspect this to be
> a bug. All of the necessary context to resolve this reference actually lives
> on the DelayedRef object stored on the ElementDecl in its type field. It
> looks as though resolve was never called for this type, and thus ref was
> never set. i can't be sure at this point, but if anyone knows anything about
> this, i'd love to hear from you.
>
> Best wishes,
>
> --greg
>
>
> On Thu, Oct 23, 2008 at 10:06 AM, Meredith Gregory <
> lgreg.meredith_at_gmail.com> wrote:
>
>> JAXBians,
>>
>> i'm hitting the following error when calling getType.
>>
>> java.lang.InternalError: unresolved reference
>> at com.sun.xml.xsom.impl.parser.DelayedRef._get(DelayedRef.java:82)
>> at
>> com.sun.xml.xsom.impl.parser.DelayedRef$Type.getType(DelayedRef.java:127)
>> at com.sun.xml.xsom.impl.ElementDecl.getType(ElementDecl.java:88)
>>
>> The call chain/code context that produces this error looks like
>>
>> XSOMParser schemaParser = new XSOMParser();
>> schemaParser.parse( new URL( "file://" + fileName ) ); // fileName points
>> to the schema listed below
>>
>> SchemaDocument schemaDocument = ... ; // a filter on the documents in the
>> parser
>> XSSchema schema = schemaDocument.getSchema();
>> XSComplexType cplxType = ... ; // a filter on the complex types in the
>> schema
>>
>> XSParticle[] mgProgeny =
>> xsType.getContentType().asParticle().getTerm().asModelGroup().getChildren();
>> mgProgeny[0].getTerm().asElementDecl().getType()
>>
>> i suspect that this has to do with the fact that the DelayedRef does not
>> have access to the other SchemaDocument (the one for the xsd SimpleTypes).
>> i'm guessing that i would not run into this problem if i used the visitor
>> pattern, i.e. that the visitor infrastructure would maintain the context to
>> resolve the delay ref. Can anyone confirm this? In this particular case, i'd
>> rather not use the visitor as the pattern doesn't fit the ambient
>> programming context.
>>
>>
>> Best wishes,
>>
>> --greg
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <xs:schema version="1.0" targetNamespace="http://calculator.me.org/"
>> xmlns:tns="http://calculator.me.org/" xmlns:xs="
>> http://www.w3.org/2001/XMLSchema">
>>
>> <xs:element name="ArithmeticException" type="tns:ArithmeticException"/>
>>
>> <xs:element name="add" type="tns:add"/>
>>
>> <xs:element name="addResponse" type="tns:addResponse"/>
>>
>> <xs:element name="mult" type="tns:mult"/>
>>
>> <xs:element name="multResponse" type="tns:multResponse"/>
>>
>> <xs:complexType name="mult">
>> <xs:sequence>
>> <xs:element name="m" type="xs:int"/>
>> <xs:element name="n" type="xs:int"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> <xs:complexType name="multResponse">
>> <xs:sequence>
>> <xs:element name="return" type="xs:int" minOccurs="0"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> <xs:complexType name="ArithmeticException">
>> <xs:sequence>
>> <xs:element name="message" type="xs:string" minOccurs="0"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> <xs:complexType name="add">
>> <xs:sequence>
>> <xs:element name="i" type="xs:int"/>
>> <xs:element name="j" type="xs:int"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> <xs:complexType name="addResponse">
>> <xs:sequence>
>> <xs:element name="return" type="xs:int"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:schema>
>>
>> --
>> L.G. Meredith
>> Managing Partner
>> Biosimilarity LLC
>> 806 55th St NE
>> Seattle, WA 98105
>>
>> +1 206.650.3740
>>
>> http://biosimilarity.blogspot.com
>>
>
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 806 55th St NE
> Seattle, WA 98105
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com
>



-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105
+1 206.650.3740
http://biosimilarity.blogspot.com