| java.lang.Object org.apache.xmlbeans.samples.datetime.DateTime
DateTime | public class DateTime (Code) | | The sample illustrates how you can work with XML Schema types date,
dateTime, time, duration, gDay.
It parses the XML Document, prints first occurence of
value, creates a new element and saves it in a new XML Document.
This sample illustrates how you can convert XMLBean types to Java types
(java.util.Date, java.util.Calendar).
It uses the schema defined in datetime.xsd.
|
Method Summary | |
public void | createDocument(DatetimeDocument doc, String file) This method creates an new element and attaches to the existing XML Instance, and saves the
new Instance to a file(args[1]). | public static void | main(String args) Receives an XML Instance and prints the element values,
Also creates a new XML Instance. | public DatetimeDocument | parseXml(String file) Creates a File from the XML path provided in main arguments, then
parses the file's contents into a type generated from schema. | public void | printInstance(DatetimeDocument doc) This method prints first occurence of
value. | public boolean | validateXml(XmlObject xml) Validates the XML, printing error messages when the XML is invalid. |
createDocument | public void createDocument(DatetimeDocument doc, String file)(Code) | | This method creates an new element and attaches to the existing XML Instance, and saves the
new Instance to a file(args[1]).
|
main | public static void main(String args)(Code) | | Receives an XML Instance and prints the element values,
Also creates a new XML Instance.
Parameters: args - An array containing(a)Path to the XML Instance conforming to the XML schema in datetime.xsd.(b)Path for creating a new XML Instance. |
parseXml | public DatetimeDocument parseXml(String file)(Code) | | Creates a File from the XML path provided in main arguments, then
parses the file's contents into a type generated from schema.
|
printInstance | public void printInstance(DatetimeDocument doc)(Code) | | This method prints first occurence of
value. It also prints converted values from XMLBean types to Java types
(java.util.Date, java.util.Calendar) and org.apache.xmlbeans.GDate.
|
validateXml | public boolean validateXml(XmlObject xml)(Code) | | Validates the XML, printing error messages when the XML is invalid. Note
that this method will properly validate any instance of a compiled schema
type because all of these types extend XmlObject.
Note that in actual practice, you'll probably want to use an assertion
when validating if you want to ensure that your code doesn't pass along
invalid XML. This sample prints the generated XML whether or not it's
valid so that you can see the result in both cases.
Parameters: xml - The XML to validate. true if the XML is valid; otherwise, false |
|
|