[xsd-users] ID/IDREF problem

Mathew Benson mathew.benson at gmail.com
Sun Mar 9 04:11:58 EDT 2014


I narrowed it down to the <choice> schema element.  When I put an ID and an
IDREF in a <sequence></sequence> block, everything works perfectly.  But
when I put them in <choice></choice> blocks, the unmarshaller validates
correctly but the smart pointer is null.  Can an item in a choice block not
have an IDREF?  What am I doing wrong?


On Sat, Mar 8, 2014 at 7:36 AM, Mathew Benson <mathew.benson at gmail.com>wrote:

> Thats exactly what it looks like.  I checked and it is a null pointer.
>  The corresponding ID is defined and is in my input XML.  When I delete or
> rename it, it fails to unmarshall and displays a correct error indicating
> the ID is referenced but not found.  But when it is set correctly, passes
> validation, and should work, I get a null pointer.
>
> I'm using the xsd published by OMG and CCSDS.  They apparently had not
> considered ID and IDREF when it was written because I had to add that
> myself anyway.  They were just defined as unique strings.  Below is a
> snippet of the xsd section that defines that particular ID:
>
> <complexType name="ParameterSetType">
> <choice maxOccurs="unbounded">
> <element name="Parameter">
>  <complexType>
> <complexContent>
> <extension base="xtce:NameIDDescriptionType">
>  <sequence>
> <element name="ParameterProperties" type="xtce:ParameterPropertiesType"
> minOccurs="0"/>
>  </sequence>
> <attribute name="name" type="ID" use="required"/>
>  </extension>
> </complexContent>
> </complexType>
>  </element>
> <element name="ParameterRef" type="xtce:ParameterRefType"/>
>  </choice>
> </complexType>
>
> I'm new to the XML schema language.  Is this schema malformed?  The ID
> should be the "name" property of the "Parameter" element.
>
>
> On Sat, Mar 8, 2014 at 12:43 AM, Boris Kolpackov <boris at codesynthesis.com>wrote:
>
>> Hi Mathew,
>>
>> Mathew Benson <mathew.benson at gmail.com> writes:
>>
>> > I get a seg fault when I try to dereference the IDREF property.
>> >
>> > xml_schema::idref& paramRef(this->parameterRef());
>> > std::cout << typeid(*paramRef).name() << std::endl;
>> >
>> > It crashes on the second line.  I'm not really sure how to continue
>> > debugging this since I just get a seg fault.  Does anybody have any
>> ideas
>> > of what to look at?  Are there any known conditions that cause a seg
>> fault
>> > when trying to dereference a ::xml_schema::idref variable?
>>
>> xml_schema::idref is a smart pointer. What is a common condition that
>> causes a seg fault when trying to dereference a smart pointer? A NULL
>> pointer. Try printing the raw pointer to the object model node that
>> idref is supposed to reference:
>>
>> std::cout << paramRef.get () << std::endl;
>>
>> If it is NULL, then that means there is no corresponding ID in your
>> object model. Print the ID value like that the IDREF refers like
>> this:
>>
>> std::cout << paramRef << std::endl;
>>
>> Then try to figure out why there is no such ID in your object
>> model. One common cause of such problem is making a copy of
>> a fragment of the object model rather than using references.
>>
>> Boris
>>
>
>


More information about the xsd-users mailing list