xml spy
Previous  Top  Next

Formatting Dates


A date in an XML document is saved in the format specific to the datatype of its node. For example, the value of an xs:date node will have the format YYYY-MM-DD[±HH:MM], while the value of an xs:dateTime node will have the format YYYY-MM-DDTHH:MM:SS[±HH:MM]. These formats are said to be the lexical representations of that data. By default, it is the lexical representation of the data that is displayed in Authentic View and the output. However, in the SPS, the Input Formatting feature can be used to display dates in alternative formats in Authentic View and, in some cases, optionally in the output.

 

Input Formatting for dates can be used to define custom formats for nodes and Auto-Calculations of the following datatypes:

 

xs:date
xs:dateTime
xs:duration
xs:gYear
xs:gYearMonth
xs:gMonth
xs:gMonthDay
xs:gDay

 

 

Using Input Formatting to format date nodes

To format dates alternatively to the lexical format of the date node, do the following:

 

1.Select the contents placeholder or input field of the node. Note that input formatting can only be applied to nodes created as contents or an input field.
2.In the Properties sidebar, select the content item, and then the Content group of properties. Now click the Edit button BtnEdit of the Input Formatting property. This pops up the Input Formatting dialog (screenshot below).

 

DlgInpFmtDateUnformatted

 

By default, the Unformatted radio button (the standard lexical format for the node's datatype) is selected.

3.To define an alternative format, select the Formatted radio button.
4.You can now select a predefined date format from the drop-down list of the combo box (screenshot below), or define your own format in the input field of the combo box. See Input Formatting Syntax for details about the syntax to use when defining your own format.

 

DlgInpFmtDateSelect

 

 

Using Input Formatting to format Auto-Calculations

When Auto-Calculations evaluate to a value that is a lexical date format, Input Formatting can be used to format the display of the result. Do this as follows:

 

1.Select the Auto-Calculation in the design.
2.In the Properties sidebar, select the content item, and then the AutoCalc group of properties. Now click the Edit button BtnEdit of the Input Formatting property. This pops up the Input Formatting dialog (screenshot below).

 

DlgInpFmtAutoCalc

 

By default, the Unformatted radio button is selected.

3.To define an alternative format, select the Formatted radio button.
4.In the combo box to the right of the Formatted radio button, select the date datatype to which the Auto-Calculation will evaluate. You can now select a predefined date format from the drop-down list of the definition combo box (available options depend on the selected datatype), or define your own format in the input field of the combo box. See Input Formatting Syntax for details about the syntax to use when defining your own format.

 

 

Applying Input Formatting to the output

The Input Formatting that you define applies to Authentic View. Additionally, some Input Formatting definitions—not all—can also be applied to HTML, RTF, PDF, and Word 2007 output. To do this, check the Apply Same Format to XSLT Output check box. If this option is not checked or if it is not available, then only Authentic View will display the Input Formatting; the output will display the value in its lexical format (for nodes) or, in the case of Auto-Calculations, in the format to which the Auto-Calculation evaluates.

 

 


See also:

 

 


 

 


Previous  Top  Next

© 2008 Altova