castor

Sorting an XML in Java

Hello I have an XML similiar to below, which needed to be sorted using the date field. <root> <Node1> <date></date> </Node1> <Node1> <date></date> </Node1> <Node1> <date></date> </Node1> <Node1> <date></date> </Node1> <Node2> <date></date> </No...

Force Decimal Regex

Hi, I'm looking for a regex or a way to format the NumberValidator so that only decimal places are allowed. The domain="real" allows you to put integer values, but I need to force the user to but in 2.0 if they want an integer. This is because they pass through a Castor mapping file, it complains if it gets an integer when it expects...

Using Castor, how do you map Java class "java.util.ArrayList" to element "ArrayList", but also generate elements for the objects that it contains?

Using Castor, how do you map Java class java.util.ArrayList to element <ArrayList/> instead of <array-list/> while still including the elements that it contains? For example, the class mapping <class name="java.util.ArrayList"> <map-to xml="ArrayList" /> </class> maps an ArrayList object to an empty element, omitting elements fo...

How change Castor mapping to remove "xmlns:xsi" and "xsi:type" attributes from element in XML output?

How do I change the Castor mapping <?xml version="1.0"?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd"&gt; <mapping> <class name="java.util.ArrayList" auto-complete="true"> <map-to xml="ArrayList" /> </class> <class name="com.db.spgit...

Castor Lists Polymorphism

Hi, I have a quick Castor question. I would like to use Castor mapping to marshal a list of objects. These objects are of two different types, both extending the same abstract base class. I would like them to have different tags in the xml, but both be added to the same list. They also have slightly different fields. Is this possible? If...

Castor XML Mapping and java.util.Map

Hello all, I've been using Castor these past couple of days to try to get a little serialization going between my Java program and XML in a readable way. Though it has a few faults, Castor's automatic xml generation via reflection is actually very functional. Unfortunately, one thing that seems to be fairly well left out of the exampl...

Ommiting unwanted fileds from mapping files of castor

Hi All My input xml has some extra tags which I donot need,like this <College> <Address> Address of the college </Address> <Name> xyz </Name> </College> In this I dont need Address details.I just need 'Name' alone.So I have just mapped Name alone as below: <?xml version="1.0" encoding="UTF-8"?> <mapping> ...

Castor XML Marshalling - XSD Contains Choice

I have a schema element that reads as follows: <xs:complexType name="day-hours"> <xs:choice> <xs:element name="twentyfourhours"/> <xs:element name="closed"/> <xs:element name="hours" type="smm:hours"/> </xs:choice> </xs:complexType> <xs:compl...

XML unmarshalling with Castor and Grails

I have a grails project that contains a few domain objects. I am using a java project in this code which can parse a document for me. The controller that calls that Java project is using JAXB to generate XML from the object returned by the Java project. I want to use this XML document (which is generated after some text parsing, using J...

Using Castor for Single Value classes

I have some XML to ingest that is set up like this <project> <client>Some client</client> <description>some description</description> </project> The Objects I need to unmarshal this data to are Project and Client. How do I set up my castor mapping for this? <class name="Project"> <field name="description" type="string" /> ...

Android Converting objects to XML and vice versa

Hello all, I created a xsd and I created Java objects using Castor. Then I imported this in my Android project and tried to build an XML from the object, using the marshal method. Marshaller.marshal(v, writer); I received some wired exception trouble processing "javax/xml/parsers/DocumentBuilder.class":... So my question is Can I use ...

XML to DynaBeans from only xsd. Possible ?

Hello, my question seems simple but I'm going crazy :) Is there a way, using JAXB, Castor or XStream to convert XML into DynaBeans, considering that I have the xsd schema but no precompiled mapping classes and no ObjectFactory or similar ? Blaise Doughan suggested to use MOXy (thanks again, Blaise) but unfortunately I have no permissio...