Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing XML

XML XSD Data Types Date/Time:



Certainly! Let's discuss XML Schema (XSD) data types for Date and Time values in simple language with an example:

XML Schema Data Types for Date/Time

XML Schema provides several built-in data types to represent dates, times, and durations. Some of the commonly used date/time related types include xs:date, xs:time, xs:dateTime, and xs:duration.

Examples:

  1. xs:date: Represents a date value in the format YYYY-MM-DD.

        

Example

<birthdate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="person.xsd">1990-05-31</birthdate>

In this example, 1990-05-31 is a date represented using the

2. xs:date type.xs:time: Represents a time value in the format hh:mm:ss.

        

Example

<meetingTime xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="meeting.xsd">14:30:00</meetingTime>

Here, 14:30:00 represents a specific time of day using the xs:time type.

3. xs:dateTime: Represents a combined date and time value in the format YYYY-MM-DDThh:mm:ss.

        

Example

<timestamp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="log.xsd">2023-06-21T09:45:00</timestamp>

The value 2023-06-21T09:45:00 represents a timestamp using the xs:dateTime type.

XSD Definitions:

To define these types in an XSD schema, you would use their respective type definitions:

        

Example

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="birthdate" type="xs:date"/> <xs:element name="meetingTime" type="xs:time"/> <xs:element name="timestamp" type="xs:dateTime"/> </xs:schema>

In this XSD schema:

Summary:

These built-in data types in XML Schema help standardize the representation of date and time values in XML documents, ensuring consistency and facilitating interoperability across different systems and applications.




Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java