I don't think you are allowed to have any <structure> elements inside of
a <mapping> element that has a marshaller attribute set.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tammy
Dugan
Sent: Friday, June 15, 2007 3:00 PM
To: JiBX users
Subject: Re: [jibx-users] variable element names

I tried making a custom marshaller and received and error. Here is a 
part of my binding file:

 <mapping abstract="true" 
marshaller="org.regenstrief.queryposer.CustomMarshaller" 
class="org.regenstrief.queryposer.QueryTransform">
    <structure field="variable"/>
    <structure field="subset" usage="optional"/>
  </mapping>

This is the error I received:

Error running binding compiler

*** Error during code generation for file 'binding.xml' - please enter a

bug report for this error in Jira if the problem is not listed as fixed 
on the online status page ***

org.jibx.runtime.JiBXException: Expected "mapping" end tag, found 
"structure" start tag (line 70, col 34, in binding.xml)
    at 
org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(Unmars
hallingContext.java:792)
    at 
org.jibx.runtime.impl.UnmarshallingContext.parsePastEndTag(Unmarshalling
Context.java:819)
    at 
org.jibx.binding.def.BindingBuilder.unmarshalMapping(BindingBuilder.java
:1667)
    at 
org.jibx.binding.def.BindingBuilder.unmarshalMappings(BindingBuilder.jav
a:983)
    at 
org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(BindingBu
ilder.java:1799)
    at org.jibx.binding.Utility.loadBinding(Utility.java:293)
    at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
    at org.jibx.binding.Compile.compile(Compile.java:296)
    at org.jibx.binding.Compile.main(Compile.java:385)

Here is my marshal method:

public void marshal(Object obj, IMarshallingContext ictx) throws 
JiBXException
    {
        String tagName = null;
       
        //make sure the parameters are as expected
        if (!(obj instanceof QueryTransform)) {
            throw new JiBXException("Invalid object type for
marshaller");
        } else if (!(ictx instanceof MarshallingContext)) {
            throw new JiBXException("Invalid object type for
marshaller");
        } else {
           
            MarshallingContext ctx = (MarshallingContext)ictx;
           
            QueryTransform transform = (QueryTransform) obj;
            tagName = transform.getNodename();
           
            ctx.startTag(-1,tagName);
            ictx.getMarshaller(0, 
obj.getClass().getName()).marshal(obj,ictx);
            ctx.endTag(-1,tagName);
        }
    }

I am just trying to wrap a tag name around the actual serialized form of

the abstract mapping for QueryTransform.

Tammy


Dees, Ian (GE Healthcare) wrote:
> Yes, it looks like you are correct. I haven't used Custom Serializers,
> but the explanation you gave is correct. You are trying to create XML
> elements with custom names, not serialize custom content as the values
> for the elements.
>
> -Ian
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Tammy
> Dugan
> Sent: Friday, June 15, 2007 10:59 AM
> To: JiBX users
> Subject: Re: [jibx-users] variable element names
>
> Thanks for the quick response. Just to clarify, the reason I should
use 
> a custom marshaller instead of a custom serializer in this situation
is 
> that I need to create extra xml tags. The custom serializer is just 
> meant for the content of a tag and doesn't support making additional 
> tags. Is this correct?
>
> Thanks,
>
> Tammy
>
> Dees, Ian (GE Healthcare) wrote:
>   
>> Tammy,
>>
>> I ran into the exact same issue. The way I worked around it is to use
>>     
> a
>   
>> custom marshaller for the object.
>>
>> JiBX is meant to be used for one Object to one Element mappings, and
>> technically if you are trying to deviate from that then you should be
>> using another marshalling framework. That being said, if almost all
of
>> your objects have a one-to-one mapping with an element name (except
>>     
> for
>   
>> a few), then a custom marshaller would make sense.
>>
>> For more info, read
>> http://jibx.sourceforge.net/tutorial/binding-custom.html
>>
>> -Ian
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Tammy
>> Dugan
>> Sent: Friday, June 15, 2007 9:55 AM
>> To: jibx-users@lists.sourceforge.net
>> Subject: [jibx-users] variable element names
>>
>> I have objects that represent logical relationships that can produce 
>> variable element names in a jibx binding. For example, I have an
>>     
> object 
>   
>> called QueryComparisonSet that can produce elements with values like 
>> "and","or", or "not". The element name is actually stored in a field
>>     
> in 
>   
>> the object. It doesn't look like there is a way to assign an element 
>> name from a field. I am assuming I need to write a custom serializer
>>     
> for
>   
>> this. I am very new to jibx so can you give me some idea of what the 
>> custom serializer might look like in this case.
>>
>> Thanks,
>>
>> Tammy
>>
>>   
>>     
>
>   

-- 
Tammy Dugan
Computer Programmer

Regenstrief Institute, Inc.
Medical Informatics
Health Information and Translational Sciences (HITS) Building
410 West 10th Street, Suite 2000
Indianapolis, IN 46202
Main: 317.423.5500
Fax: 317.423.5695
IU campus mail address: HS, 2000

(317) 423 - 5541

Confidentiality Notice: The contents of this message and any files
transmitted with it may contain confidential and/or privileged
information and are intended solely for the use of the named
addressee(s). Additionally, the information contained herein may have
been disclosed to you from medical records with confidentiality
protected by federal and state laws. Federal regulations and State laws
prohibit you from making further disclosure of such information without
the specific written consent of the person to whom the information
pertains or as otherwise permitted by such regulations. A general
authorization for the release of medical or other information is not
sufficient for this purpose.
 
If you have received this message in error, please notify the sender by
return e-mail and delete the original message. Any retention,
disclosure, copying, distribution or use of this information by anyone
other than the intended recipient is strictly prohibited.



------------------------------------------------------------------------
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to