Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 2 min read

Support

Motivation

XML stores dates in the format YYYY-MM-DD such as 2007-08-30. Unfortunately this is usually not the way users want to view their dates.

This example XForms program uses CSS to hide an input date and an XPath expression to get the date to display in the MM/DD/YYYY format typically used in the US.

Link to Date Format External Example

Sample Program

xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:d="http://www.mydata.com/xmlns/data">

Demo of date formatting using XPath concat and substring.
type="text/css">
@namespace xf url('http://www.w3.org/2002/xforms');

.hidden .xf-value {
display:none;
}
]]>

xmlns="">

2006-09-12

nodeset="/MyModel/MyDate" type="xs:date" />

class="hidden" ref="/MyModel/MyDate" incremental="true">
Select Date:

value="concat(substring(/MyModel/MyDate,6,2),
'/',
substring(/MyModel/MyDate,9,2),
'/',
substring(/MyModel/MyDate,1,4))"
/>

Discussion

The CSS style sheet hides the input field. The input has the class="hidden" attribute.

The output is formatted using the following XPath expression:

concat(
substring(/MyModel/MyDate,6,2),
'/',
substring(/MyModel/MyDate,9,2),
'/',
substring(/MyModel/MyDate,1,4)
)

Concat is the XPath concatenation operator.
The input is in the format: "YYYY-MM-DD". We just need to reach in and get the correct characters out.

  • The first substring goes to the 6th character and pulls out the two month (MM) characters.
  • The second substring starts at the 9th character and gets two day (DD) characters.
  • The last substring returns characters 1-4 which are the four year characters (YYYY).

You do not have to display all four letters in the year. By changing the last substring from:

substring(/MyModel/MyDate,1,4)

to be

substring(/MyModel/MyDate,3,4)

You will only get the last two digits of the year.

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
xmlns=" xmlns:xf=" xmlns:ev=" xmlns:xs=" xmlns:xsi=" > xmlns=""> xsi:type="xs:anyURI"/> ref="/Data/File"> file:///C:/tmp/*.xml text/xml ref="/Data/File"> File: ## Discussion At the time of this writing, there is little documentation on how the upload control works. The screen shot above was taken fr
CC BY-SA 4.0
Using a trigger abstraction allows your XForms to be more portable. ## Sample Program xmlns=" xmlns:xf=" xmlns:ev=" > Button Example xmlns=""> Button If you press this you will get a hello world message. level="modal" ev:event="DOMActivate">Hello World! ## Discussion This example has both a label an
CC BY-SA 4.0
This example demonstrates how to control the button appearance using labels, hint text and images. To see the button images appear you will need to create a file called XForms-button.jpg in the folder that this program is executed from. This example requires an image to be used in the program. This
CC BY-SA 4.0
It allows the user to select a numeric value from a range of values without using the keyboard. This is ideal for instructors that use interactive learning environments such as a SmartBoard. The XForms range has four attributes: - **start** - the lower bound of the range - **end** - the upper bound
CC BY-SA 4.0
This must be the ID of one of the submission elements in your model. Here is and example: submission="get-additional-data"/> If you reference this submission you will need a corresponding submission in your model. id="get-additional-data" .../> ## Common Usage The most common usage of send is to per
CC BY-SA 4.0
Show can have two values: **new** or **replace**. - **target** - the target action to be executed One is the URI of the resource to load and the other is the show attribute. The show attribute can have values of "replace" which will replace the current form with the new resource and "new" which will