Hi,
Thanks for pointing out! One other question, what if I would like this
tag (personalItems) to show only when the collection is not empty?
If the collection contains element, the XML file would be like this:
<person>
<name>John</name>
<personal-items>
<item>Scissor</item>
<item>Screwdiver</item>
</personal-item>
<person>
But if a person does not have any personal item, it should looks like this:
<person>
<name>John</name>
<person>
Instead of:
<person>
<name>John</name>
<personal-items></personal-item>
<person>
How could I define this behavior in JiBX mapping file?
Thanks!
Vairoj
--__--__--
Message: 2
From: "Mocky Habeeb" <[EMAIL PROTECTED]>
To: <[email protected]>
Subject: RE: [jibx-users] Re: Collection Mapping
Date: Thu, 20 Oct 2005 08:09:00 -0400
Reply-To: [email protected]
Just add the 'name' attribute to your collection definition:
<collection field="personalItems" name="personal-items"
type="java.util.HashSet" item-type="Item" />
Mocky
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vairoj A.
Sent: Thursday, October 20, 2005 6:24 AM
To: [email protected]
Subject: [jibx-users] Re: Collection Mapping
Maybe I might not explain my issue clearly. Let me try it again.
The domain model I have can be declared like this:
public class Person
{
private Set<Item> personalItems;
}
If I define the mapping like this, which similar to tutorial:
<collection field="personalItems" type="java.util.HashSet"
item-type="Item" />
The XML file would looks something like this:
<person>
<item>Scissor</item>
<item>Screwdiver</item>
</person>
You can see that the XML map item in the collection directly under
person tag. But what I would like to have is, instead, have a tag denote
the collection - personalItems before item tags. Like this:
<person>
<personal-items>
<item>Scissor</item>
<item>Screwdiver</item>
</personal-item>
<person>
How should I define the binding in order to achieve this?
Regards,
Vairoj
Using the same element name in different places with different
contents is going to be difficult. If you could rename the outermost
<person> to something else then it should be easy. If you can post
your binding for the second xml along with any errors or whatever
output you're getting it will be easier to troubleshoot your issues.
Mocky
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vairoj A.
Sent: Wednesday, October 19, 2005 6:30 AM
To: [email protected]
Subject: [jibx-users] Collection Mapping
Hi,
I have a question about mapping Collection attribute. Says I have the
the following class:
Person {
private Set<Person> employees;
}
And defines mapping like this:
<collection field="employees" type="java.util.HashSet"
item-type="Person" />
will results in XML file like this:
<person>
<person>
</person>
<person>
</person>
</person>
What if I would like the XML file to look like this:
<person>
<employees>
<person>
</person>
<person>
</person>
</employee>
</person>
How should I define the mapping to achieve this kind of structure?
Regards,
Vairoj
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads,
discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
--__--__--
Message: 3
Subject: RE: [jibx-users] JiBXException: Expected "A" end tag, found "B" start
tag
Date: Thu, 20 Oct 2005 12:47:45 -0700
From: "Leif Stainsby" <[EMAIL PROTECTED]>
To: <[email protected]>
Reply-To: [email protected]
Hi Mocky,
It looks like I missed something -- when the <namespace/> is added to
the <keywords/> mapping definition, it works fine. So I was simply
missing this namespace definition. Another lesson learned.
Thanks very much for your help. I have closed the bug report as well.
...Leif
--__--__--
Message: 4
Date: Thu, 20 Oct 2005 17:01:50 -0700
From: "Leif Stainsby" <[EMAIL PROTECTED]>
To: <[email protected]>
Subject: [jibx-users] Namespace URI has not been declared
Reply-To: [email protected]
Hi,
We've got more namespace fun. This binding (fragment):
<mapping ...>
<namespace uri=3D"http://www.opengeospatial.net/ows"
default=3D"elements"/>
...
<structure name=3D"ProviderSite" field=3D"providerSite" =
usage=3D"optional"
class=3D"com.galdosinc.common.ogc.xml.SimpleLink"
map-as=3D"com.galdosinc.common.ogc.xml.SimpleLink"/>
</mapping>
<mapping abstract=3D"true"
class=3D"com.galdosinc.common.ogc.xml.SimpleLink">
<namespace uri=3D"http://www.w3.org/1999/xlink" default=3D"attributes"
prefix=3D"xlink"/>
<value style=3D"attribute" name=3D"type" field=3D"type"
usage=3D"required"/>
<value style=3D"attribute" name=3D"href" field=3D"href"
usage=3D"required"/>
<value style=3D"attribute" name=3D"title" field=3D"title"
usage=3D"optional"/>
<value style=3D"attribute" name=3D"role" field=3D"role"
usage=3D"optional"/>
<value style=3D"attribute" name=3D"arcrole" field=3D"arcrole"
usage=3D"optional"/>
</mapping>
which I'm hoping will generate XML like this
<ows:ProviderSite xlink:type=3D"simple"=20
xlink:href=3D"http://..."/>
is currently throwing the exception below, when attempting to marshal.
I suspect it has to do with the abstract SimpleLink mapping <namespace/>
definition not being picked up correctly -- possibly due to it only
having attributes and no element content? That's just my wild guess.
Any insight into how to map this link type is appreciated. Note that it
is used in multiple places on different elements (elsewhere in the
binding file), hence my attempt to define it using an abstract mapping
(for reuse).
Regards
...Leif
------------------------------
Error writing marshalled document
java.io.IOException: Namespace URI has not been declared.
at
org.jibx.runtime.impl.StreamWriterBase.writePrefix(StreamWriterBase.java
:253)
at
org.jibx.runtime.impl.XMLWriterBase.addAttribute(XMLWriterBase.java:199)
at
org.jibx.runtime.impl.MarshallingContext.attribute(MarshallingContext.ja
va:1021)
at
com.galdosinc.common.ogc.xml.SimpleLink.JiBX_WRSCapabilities_marshalAttr
_1_4(SimpleLink.java)
at
com.galdosinc.common.ogc.ows.capabilities.ServiceProvider.JiBX_WRSCapabi
lities_marshal_1_1(ServiceProvider.java)
at
com.galdosinc.common.ogc.ows.capabilities.JiBX_WRSCapabilitiesServicePro
vider_access.marshal()
at
com.galdosinc.common.ogc.ows.capabilities.BaseCapabilities.JiBX_WRSCapab
ilities_marshal_1_1(BaseCapabilities.java)
at
com.galdosinc.common.ogc.ows.capabilities.BaseCapabilities.JiBX_WRSCapab
ilities_marshal_1_2(BaseCapabilities.java)
at
com.galdosinc.common.ogc.ows.capabilities.JiBX_WRSCapabilitiesBaseCapabi
lities_access.marshal()
at
com.galdosinc.common.ogc.ows.capabilities.BaseCapabilities.marshal(BaseC
apabilities.java)
at
org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingContext.
java:1997)
at
org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingCont
ext.java:2137)
at
com.galdosinc.common.ogc.OgcUtilTest.marshal(OgcUtilTest.java:112)
------------------------------
--__--__--
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
End of jibx-users Digest
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users