Hi there.
In our XML, we need to create an 'offset' attribute, which allows users to specify date offsets.
When transforming our XML to HTML, these offsets will then be applied to the current date.
We are intending to use XSD duration type (described at http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/) as valid syntax for our offset.
However, when our XSD is compiled to JAXB-classes, the offset is mapped to a String:
public interface Offset
extends javax.xml.bind.Element
{
/**
*
* @return possible object is
* {@link java.lang.String}
*/
java.lang.String getValue();
/**
*
* @param value allowed object is
* {@link java.lang.String}
*/
void setValue(java.lang.String value);
}
We would prefer to map the offset to a 'Duration' class, that models the xsd:duration syntax more closely, using a binding extension.
For example, we could use binding extensions to convert an attribute to a boolean using:
<xs:attribute name="paperback">
<xs:simpleType>
<xs:annotation>
<xs:appinfo>
<jaxb:javaType
name="boolean"
printMethod="javax.xml.bind.DatatypeConverter.printBoolean"
parseMethod="javax.xml.bind.DatatypeConverter.parseBoolean" />
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
(A contrived example, as you can map to boolean directly by specifying xs:boolean)
Anyways, to my question, is there a Sun or Open-Source class that models xs:duration? The class would need to perform 2 functions:
1. Have static parseDuration, and printDuration methods.
2. Have a method that accepts a Date, applys the offser duration, and returns the offset Date.
Thanks, Neil