To reproduce double name space problem, I have attached a simple java
file (Description.java) and mapping file (Description.xml). You can use
following code to get Description object converted to XML.
try
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Mapping mapping = new Mapping();
mapping.setBaseURL("src/conf/mapping");
mapping.loadMapping("Description.xml");
org.w3c.dom.Document document = builder.newDocument();
Marshaller marshaller = new Marshaller(document);
marshaller.setSuppressXSIType(true);
marshaller.setMapping(mapping);
Description desc = new Description(1111,"This is test");
marshaller.marshal(desc);
Document dom4jDoc = new DOMReader().read(document); // this
converts org.w3c.dom.Document to org.d4j.Document to extract string XML
from Document
System.out.println(dom4jDoc.asXML());
}catch(Exception e)
{
e.printStackTrace();
}
Let me know if you need any more information.
- R
Ralf Joachim wrote:
Can you provide us with a minimal test case to reproduce the problem
and the workaround / patch that you used to fix that with 0.9.6. I
hope this will help us to fix that namespace issue.
Are you able to tell us if the problem you faced with 0.9.6 (random
blank tags) still exists?
Ralf
Ranjan Kumar Baisak schrieb:
I just started upgrading to v 1.1.2.1 but faced issues related to
namespace (http://jira.codehaus.org/browse/CASTOR-201). I had a fix
in my code base for this JIRA issue and it was working perfectly for
me with v0.9.6. Now I am getting double namespace prefixed to all
elements with v 1.1.2.1 e.g.
<?xml version="1.0" encoding="UTF-8"?>
<YMIA:YMIA:Description xmlns:YMIA=""
xmlns:YMIA="urn:schemas-music-yamaha-com:ymia">
??
- R
Werner Guttmann wrote:
I'd appreciate an upgrade to at least 1.1 (or higher, if possible), as
the XML class descriptor resolver has been rewritten/refactored, and as
part of that work a few inconsistencies related to 'deducing' XML names
and class names have been fixed.
In other words, can you please re-test with 1.1. or higher, and let us
know whether the issue still happens to be around.
Regards
Werner
PS I'd hold back from creating a Jira issue for the time being, as
clearly Castor 0.9.6 is quite old, and a lot of time has gone into
maintaining and progressing Castor. So let's see what difference a
version upgrades makes (first).
Jim Manico wrote:
Bingo. This is the problem. Something to do with how Castor caches
objects in an inheritance hierarchy might still be flawed. Upgrade to
the latest version of Castor and see if you can repeat your
problem, if
so, please, file a JIRA issue with an exact test case. You are on to
something here, and it could help all of us using Castor.....
Yes lots of inheritance.
When using a inheritance with Castor, I was also getting a case
where
it maps differently each time I call that code. I did a "ant clean
compile", and that seemed to fix my problem - but out of curiosity,
does this mapping involve inheritance?
I generally use it in web-application so cannot do clean build
always.
What kind of inheritance do you use in your code base. If you can
paste some example then it would help me.
- R
Hello Gurus,
I some how getting some data lost problem when I
convert Java Objects to XML using Castor API v 0.9.6. Basically
I am
getting blank tags without any data. This is not happening always
rather randomly. Has anybody faced such problem? Many times I
thought of replacing with latest build but due to some customized
wrappers which I have developed, I tend to use v 0.9.6 and also
I am
not sure whether this problem will get solved with latest
version. I
have already wasted days of work on debugging. I would appreciate
your valuable comments on this. Also ready to provide any
information that might help for suggestions.
- R
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
package com.yamaha.portal.site.transport;
import java.util.Date;
/**
* (c) 2004 Yamaha Music Interactive
* User: Alan
* Date: Feb 24, 2004
* Time: 4:42:17 PM
*/
public class Description
extends Transport {
private Integer id;
private Integer descriptionTypeId;
private String descriptionType;
private Integer displayOrder;
private String descriptionText;
private java.util.Date createDate;
private java.util.Date lastUpdated;
private java.util.Date translationDate;
public Description() {
super();
this.descriptionText = "";
}
public Description(int id, String text) {
super();
this.id = new Integer(id);
this.descriptionText = text;
}
public Description(int id, int descriptionTypeId, String text) {
super();
this.id = new Integer(id);
this.descriptionTypeId = new Integer(descriptionTypeId);
this.descriptionText = text;
}
public Description(int id, int descriptionTypeId, String descriptionText,
Date create_date, Date last_updated, Date transaltionDate) {
super();
this.id = new Integer(id);
this.descriptionTypeId = new Integer(descriptionTypeId);
this.descriptionText = descriptionText;
this.createDate = create_date;
this.lastUpdated = last_updated;
this.translationDate = transaltionDate;
}
public void setId(Integer id) {
this.setDirty(true);
this.id = id;
}
public Integer getId() {
return this.id;
}
public void setDescriptionTypeId(Integer descriptionTypeId) {
this.setDirty(true);
this.descriptionTypeId = descriptionTypeId;
}
public Integer getDescriptionTypeId() {
return this.descriptionTypeId;
}
public String getDescriptionType() {
return descriptionType;
}
public void setDescriptionType(String descriptionType) {
this.descriptionType = descriptionType;
}
public void setDescriptionText(String descriptionText) {
this.setDirty(true);
this.descriptionText = descriptionText;
}
public String getDescriptionText()
{
return this.descriptionText;
}
public java.util.Date getCreateDate() {
return createDate;
}
public void setCreateDate(java.util.Date createDate) {
this.createDate = createDate;
}
public java.util.Date getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(java.util.Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
public java.util.Date getTranslationDate() {
return translationDate;
}
public void setTranslationDate(java.util.Date translationDate) {
this.translationDate = translationDate;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("\n\tid=").append(id);
sb.append("\n\tdescriptionTypeId=").append(descriptionTypeId);
sb.append("\n\tdescriptionText=").append(descriptionText);
return sb.toString();
}
public Integer getDisplayOrder() {
return displayOrder;
}
public void setDisplayOrder(Integer displayOrder) {
this.displayOrder = displayOrder;
}
}
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">
<mapping>
<description>Description mapping</description>
<class name="com.yamaha.portal.site.transport.Description">
<map-to xml="Description" ns-prefix="YMIA"
ns-uri="urn:schemas-music-yamaha-com:ymia" />
<field name="descriptionType" type="java.lang.String">
<bind-xml name="DescriptionType" node="attribute" />
</field>
<field name="id" type="java.lang.Integer">
<bind-xml name="Id" node="element" />
</field>
<field name="descriptionTypeId" type="java.lang.Integer">
<bind-xml name="DescriptionTypeId" node="element" />
</field>
<field name="displayOrder" type="java.lang.Integer">
<bind-xml name="DisplayOrder" node="element" />
</field>
<field name="descriptionText" type="java.lang.String">
<bind-xml name="DescriptionText" node="element" />
</field>
</class>
</mapping>
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email