示例#1
0
 /** Test format-time: basic numeric formats. */
 @org.junit.Test
 public void formatTime002f() {
   final XQuery query = new XQuery("format-time($t,\"[H]:[m]:[s01]:[f001]\")", ctx);
   try {
     query.bind("t", new XQuery("xs:time('09:15:06.456')", ctx).value());
     result = new QT3Result(query.value());
   } catch (final Throwable trw) {
     result = new QT3Result(trw);
   } finally {
     query.close();
   }
   test(assertStringValue(false, "9:15:06:456"));
 }
示例#2
0
 /** test format-time(): effect of width specifiers . */
 @org.junit.Test
 public void formatTime013p() {
   final XQuery query = new XQuery("format-time($t, '[f,4-4]')", ctx);
   try {
     query.bind("t", new XQuery("xs:time('09:15:06.456')", ctx).value());
     result = new QT3Result(query.value());
   } catch (final Throwable trw) {
     result = new QT3Result(trw);
   } finally {
     query.close();
   }
   test(assertStringValue(false, "4560"));
 }
示例#3
0
 /**
  * Simple combination of node sequences involving multiple xml data sources. Uses "|" operator .
  */
 @org.junit.Test
 public void combiningnodeseqhc9() {
   final XQuery query =
       new XQuery(
           "for $h in ( ($works//hours) | ($staff//grade[xs:integer(.) gt 12])) order by number($h) return $h",
           ctx);
   try {
     query.bind("$works", node(file("docs/works.xml")));
     query.bind("$staff", node(file("docs/staff.xml")));
     result = new QT3Result(query.value());
   } catch (final Throwable trw) {
     result = new QT3Result(trw);
   } finally {
     query.close();
   }
   test(
       assertSerialization(
           "<hours>12</hours><grade>13</grade><grade>13</grade><hours>20</hours><hours>20</hours><hours>20</hours><hours>20</hours><hours>20</hours><hours>20</hours><hours>40</hours><hours>40</hours><hours>40</hours><hours>80</hours><hours>80</hours><hours>80</hours>",
           false));
 }
示例#4
0
 /** test format-time(): timezones in GMT+x notation. */
 @org.junit.Test
 public void formatTime018() {
   final XQuery query =
       new XQuery(
           "string-join(\n"
               + "               for $z in -28 to +28\n"
               + "               return format-time(adjust-time-to-timezone($t, $z*xs:dayTimeDuration('PT30M')), '[h01][m01][z,2-6]'), '; ')",
           ctx);
   try {
     query.bind("t", new XQuery("xs:time('09:15:06.456Z')", ctx).value());
     result = new QT3Result(query.value());
   } catch (final Throwable trw) {
     result = new QT3Result(trw);
   } finally {
     query.close();
   }
   test(
       assertStringValue(
           true,
           "\n              0715GMT-14:00; 0745GMT-13:30; 0815GMT-13:00; 0845GMT-12:30; 0915GMT-12:00; 0945GMT-11:30; 1015GMT-11:00; 1045GMT-10:30;\n            1115GMT-10:00; 1145GMT-09:30; 1215GMT-09:00; 1245GMT-08:30; 0115GMT-08:00; 0145GMT-07:30; 0215GMT-07:00; 0245GMT-06:30;\n            0315GMT-06:00; 0345GMT-05:30; 0415GMT-05:00; 0445GMT-04:30; 0515GMT-04:00; 0545GMT-03:30; 0615GMT-03:00; 0645GMT-02:30;\n            0715GMT-02:00; 0745GMT-01:30; 0815GMT-01:00; 0845GMT-00:30; 0915GMT+00:00; 0945GMT+00:30; 1015GMT+01:00; 1045GMT+01:30; 1115GMT+02:00;\n            1145GMT+02:30; 1215GMT+03:00; 1245GMT+03:30; 0115GMT+04:00; 0145GMT+04:30; 0215GMT+05:00; 0245GMT+05:30; 0315GMT+06:00;\n            0345GMT+06:30; 0415GMT+07:00; 0445GMT+07:30; 0515GMT+08:00; 0545GMT+08:30; 0615GMT+09:00; 0645GMT+09:30; 0715GMT+10:00;\n            0745GMT+10:30; 0815GMT+11:00; 0845GMT+11:30; 0915GMT+12:00; 0945GMT+12:30; 1015GMT+13:00; 1045GMT+13:30;\n            1115GMT+14:00\n         "));
 }
示例#5
0
 /** Test format-time: 12-hour clock. */
 @org.junit.Test
 public void formatTime004() {
   final XQuery query =
       new XQuery(
           "\n"
               + "        for $i in 1 to 24 return\n"
               + "        format-time($t + xs:dayTimeDuration('PT1H')*$i, '[h].[m]')",
           ctx);
   try {
     query.bind("t", new XQuery("xs:time('09:15:06.456')", ctx).value());
     result = new QT3Result(query.value());
   } catch (final Throwable trw) {
     result = new QT3Result(trw);
   } finally {
     query.close();
   }
   test(
       assertStringValue(
           true,
           "\n         10.15 11.15 12.15 1.15 2.15 3.15 4.15 5.15 6.15 7.15 8.15 9.15 10.15 11.15 \n         12.15 1.15 2.15 3.15 4.15 5.15 6.15 7.15 8.15 9.15\n         "));
 }