users@jaxb.java.net

reference error

From: Meredith Gregory <lgreg.meredith_at_gmail.com>
Date: Thu, 23 Oct 2008 10:06:38 -0700

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