Did you know ... Search Documentation:
Pack prolog_library_collection -- prolog/xsd_grammar.pl
PublicShow source

XSD grammar rules for parsing decimals and durations.

Compatibility
- XML Schema 1.1 Part 2 ― Datatypes
 dayTimeDurationCanonicalMap(+Duration)// is det
Maps a dayTimeDuration's seconds value to a dayTimeDurationLexicalRep//1. (The months value is necessarily zero and is ignored.) dayTimeDurationCanonicalMap//1 is a restriction of durationCanonicalMap//1.

Algorithm

Let:

  • s be dt's months
  • sgn be '-' if s is negative and the empty string ('') otherwise

Return sgn & 'P' & duYearMonthCanonicalFragmentMap(|s|)

bug
- s' should be dt''s seconds rather than months.
- duYearMonthCanonicalFragmentMap should be duDayTimeCanonicalFragmentMap.
 dayTimeDurationMap(+Duration)// is det
Maps the lexical representation into the seconds of a dayTimeDuration value. (A dayTimeDuration's months is always zero.) dayTimeDurationMap//1 is a restriction of durationMap//1.

Arguments

Arguments:
Duration- A dayTimeDuration value.

Algorithm

DT necessarily consists of possibly a leading '-', followed by 'P' and then an instance D of duDayTimeFrag//1.

Return a dayTimeDuration whose:

  • months value is (necessarily) 0
  • seconds value is
    • -duDayTimeFragmentMap(D), if '-' is present in DT
    • duDayTimeFragmentMap(D), otherwise
 decimalCanonicalMap(+Decimal:rational)// is det
Maps a Decimal to its canonical representation, a decimalLexicalRep//1.

Arguments

Arguments:
Decimal- A decimal value.

Algorithm

If d is an integer, then return noDecimalPtCanonicalMap(d). Otherwise, return decimalPtCanonicalMap(d).

 decimalLexicalMap(-Decimal:rational)// is det
Maps a decimalLexicalRep//1 onto a decimal value.

Arguments

Arguments:
Decimal- A decimal value.

Algorithm

Let d be a decimal value.

Set d to:

 durationCanonicalMap(+Duration)// is det
Maps a duration's property values to durationLexicalRep//1 fragments and combines the fragments into a complete durationLexicalRep//1.

Arguments

Arguments:
Duration- A complete duration value.

Algorithm

Let:

  • m be v's months
  • s be v's seconds
  • sgn be '-' if m or s is negative and the empty string ('') otherwise

Return:

  • sgn & 'P' & duYearMonthCanonicalFragmentMap(|m|) & duDayTimeCanonicalFragmentMap(|s|), when neither m nor s is zero
  • sgn & 'P' & duYearMonthCanonicalFragmentMap(|m|), when m is not zero but s is
  • sgn & 'P' & duDayTimeCanonicalFragmentMap(|s|), when m is zero
 durationMap(-Duration:compound)// is det
Separates the durationLexicalRep//1 into the month part and the seconds part, then maps them into the months and seconds of the duration value.

Arguments

Arguments:
Duration- A complete duration value.

Algorithm

DUR consists of:

Return a duration whose:

  • months value is:
    • 0, if Y is not present
    • -duYearMonthFragmentMap(Y), if both '-' and Y are present
    • duYearMonthFragmentMap(Y), otherwise
  • seconds value is:
    • 0, if D is not present
    • -duDayTimeFragmentMap(D), if both '-' and D are present
    • duDayTimeFragmentMap(D), otherwise