/
schema_rnc.php
745 lines (719 loc) · 28.8 KB
/
schema_rnc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
<?php
//Assembler of RNC schema for RuleML 1.01
// Step 000. Initialize some parameters
header('Content-Description: File Transfer');
header('Content-type: application/relax-ng-compact-syntax; charset=utf-8');
header('Content-Disposition: attachment; filename="'.basename('custom_driver.rnc').'"');
$schemaLocation='';
$modulesLocation = $schemaLocation . 'modules/';
$start = ' start = Node.choice | edge.choice'."\n";
$end = ' inherit = ruleml {start |= notAllowed}';
$base_url = "http://deliberation.ruleml.org/1.01/relaxng/schema_rnc.php";
$now = date(DATE_ATOM,time());
//Step 00. Write the header
echo 'namespace dc = "http://purl.org/dc/elements/1.1/"
namespace dcterms = "http://purl.org/dc/terms/"
namespace ruleml = "http://ruleml.org/spec"
dc:title [ "Deliberation RuleML Custom-Built Schema" ]
dc:version [ "1.01" ]
dc:creator [ "Tara Athan (taraathan AT gmail.com)" ]
dc:subject [ "Deliberation RuleML, custom-built" ]
dc:description [
"custom-built main module for a Deliberation RuleML sublanguage."
]
dc:date [ "';
echo($now);
echo '" ]
dc:language [ "en" ]
dcterms:rights [ "TBD" ]
dc:relation [ "http://deliberation.ruleml.org/1.01" ]
echo "\n";
echo "# Call parameters\n";
$this_url = $base_url;
$this_url = $this_url . "?";
echo "# Base URL = $base_url \n";
//
//Step 0. Extract all GET parameters
$backbone = "backbone";
$backbone_andor = 0;
$backbone_implies = 1;
$backbone_quant = 2;
$backbone_expr = 3;
$backbone_dis = 4;
$backbone_fo = 5;
$bbackbone = processGETParameter ($backbone);
$backboneParam = "x".dechex(bindec($bbackbone));
$call_fragment = $backbone."=".$backboneParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$default = "default";
$default_absent = 0;
$default_present = 1;
$default_absent_fo = 2;
$bdefault = processGETParameter ($default);
$defaultParam = "x".dechex(bindec($bdefault));
$call_fragment = $default."=".$defaultParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$termseq = "termseq";
$termseq_unary = 0;
$termseq_binary = 1;
$termseq_ternary_plus = 2;
$btermseq = processGETParameter ($termseq);
$termseqParam = "x".dechex(bindec($btermseq));
$call_fragment = $termseq."=".$termseqParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$lng = "lng";
$lng_abbrev_en = 0;
$lng_long_en = 1;
//$lng_long_fr = 2;
$blng = processGETParameter ($lng);
$lngParam = "x".dechex(bindec($blng));
$call_fragment = $lng."=".$lngParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$propo = "propo";
$propo_iri = 0;
$propo_rulebase = 1;
$propo_entails = 2;
$propo_degree = 3;
$propo_neg = 4;
$propo_naf = 5;
$propo_node = 6;
$propo_meta = 7;
$propo_xmlbase = 8;
$propo_xmlid = 9;
$bpropo = processGETParameter ($propo);
$propoParam = "x".dechex(bindec($bpropo));
$call_fragment = $propo."=".$propoParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$implies = "implies";
$implies_equivalent = 0;
$implies_direction = 1;
$implies_material = 2;
$bimplies = processGETParameter ($implies);
$impliesParam = "x".dechex(bindec($bimplies));
$call_fragment = $implies."=".$impliesParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$terms = "terms";
$terms_oid = 0;
$terms_slot = 1;
$terms_card = 2;
$terms_weight = 3;
$terms_equal = 4;
$terms_oriented = 5;
$terms_type = 8;
$terms_data = 9;
$terms_skolem = 10;
$terms_reify = 11;
$bterms = processGETParameter ($terms);
$termsParam = "x".dechex(bindec($bterms));
$call_fragment = $terms."=".$termsParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$quant = "quant";
$quant_closure = 0;
$quant_resl = 1;
$quant_repo = 2;
$bquant = processGETParameter ($quant);
$quantParam = "x".dechex(bindec($bquant));
$call_fragment = $quant."=".$quantParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
//
$expr = "expr";
$expr_val_absent = 0;
$expr_plex = 1;
$expr_val_nondefault = 2;
$expr_in = 3;
$bexpr = processGETParameter ($expr);
$exprParam = "x".dechex(bindec($bexpr));
$call_fragment = $expr."=".$exprParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment."&";
$serialization = "serial";
$serialization_unordered = 0;
$serialization_stripeskip = 1;
$serialization_datatyping = 2;
$serialization_schemaLocation = 3;
$bserialization = processGETParameter ($serialization);
$serializationParam = "x".dechex(bindec($bserialization));
$call_fragment = $serialization."=".$serializationParam;
echo "# GET parameter: ".$call_fragment."\n";
$this_url = $this_url . $call_fragment;
echo "# Complete URL = \n";
echo "# " . $this_url . "\n";
if ($bdefault==0){
echo "#\n# Error: The ".$default." parameter value ".$defaultParam." is not allowed.\n";
} else {
$needAndOr = extractBit($bbackbone, $backbone_andor);
$needImp = extractBit($bbackbone, $backbone_implies);
$needQuant = extractBit($bbackbone, $backbone_quant);
$needExpr = extractBit($bbackbone, $backbone_expr);
$needDis = extractBit($bbackbone, $backbone_dis);
$needFO = extractBit($bbackbone, $backbone_fo);
$needDefaultAbsent = extractBit($bdefault, $default_absent);
$bdefault_present = extractBit($bdefault, $default_present);
$needDefaultAbsentFO = extractBit($bdefault, $default_absent_fo);
$btermseq_unary = extractBit($btermseq, $unary);
$btermseq_binary = extractBit($btermseq, $binary);
$btermseq_ternary_plus = extractBit($btermseq, $ternary_plus);
$needPoly = $btermseq_ternary_plus * $btermseq_binary * $btermseq_unary;
// Apparent lack of monotonicity caused by incomplete orthogonalization
// of modules for binary and polyadic positional term sequences.
// Orthogonalization is possible but awkward, leading to complex and unreadable grammar rules.
$needBin = extractBit($btermseq, $termseq_binary) * (1-$needPoly);
$needUn = extractBit($btermseq, $termseq_unary) * (1-$needPoly);
$needLongNames = extractBit($blng, $lng_long_en);
// Apparent lack of monotonicity caused by incomplete orthogonalization
// of modules for ordered and unordered groups.
// Orthogonalization is possible but awkward, leading to complex and unreadable grammar rules.
$needUnordered = extractBit($bserialization, $serialization_unordered);
$needOrdered = (1-$needUnordered);
$needStripeSkip = extractBit($bserialization, $serialization_stripeskip);
$needDatatyping = extractBit($bserialization, $serialization_datatyping);
$needSchemaLocation = extractBit($bserialization, $serialization_schemaLocation);
$needURI = extractBit($bpropo, $propo_iri);
$needRulebase = extractBit($bpropo, $propo_rulebase);
$needEntails = extractBit($bpropo, $propo_entails);
$needFuzzy = extractBit($bpropo, $propo_degree);
$needNeg = extractBit($bpropo, $propo_neg);
$needNaf = extractBit($bpropo, $propo_naf);
$needNode = extractBit($bpropo, $propo_node);
$needMeta = extractBit($bpropo, $propo_meta);
$needBase = extractBit($bpropo, $propo_xmlbase);
$needId = extractBit($bpropo, $propo_xmlid);
$needEquiv = extractBit($bimplies, $implies_equivalent);
$needDirND = extractBit($bimplies, $implies_direction);
$needDirD = $bdefault_present;
$needDirAtt = $needDirD + $needDirND;
$needMatND = extractBit($bimplies, $implies_material);
$needMatD = $bdefault_present;
$needMatAtt = $needMatD + $needMatND;
$needOid = extractBit($bterms, $terms_oid);
$needSlot = extractBit($bterms, $terms_slot);
$needCard = extractBit($bterms, $terms_card);
$needWeight = extractBit($bterms, $terms_weight);
$needEqual = extractBit($bterms, $terms_equal);
$needOrientedND = extractBit($bterms, $terms_oriented);
$needOrientedD = $bdefault_present * $needEqual;
$needOrientedAtt = $needOrientedD * $needEqual + $needOrientedND;
$needType = extractBit($bterms, $terms_type);
$needDataTerms = extractBit($bterms, $terms_data);
$needData = $needDataTerms + $needFuzzy;
$needSkolem = extractBit($bterms, $terms_skolem);
$needReify = extractBit($bterms, $terms_reify);
$needInd = $btermseq + $needOid + $needSlot + $needEqual;
$needVar = $needQuant;
$needClosure = extractBit($bquant, $quant_closure);
$needResl = extractBit($bquant, $quant_resl);
$needRepo = extractBit($bquant, $quant_repo);
$needValAbsent = extractBit($bexpr, $expr_val_absent);
$needPlex = extractBit($bexpr, $expr_plex);
$needValND = extractBit($bexpr, $expr_val_nondefault);
$needValD = $bdefault_present * $needExpr * $needEqual;
$needValAtt = $needValD + $needValND;
$needInND = extractBit($bexpr, $expr_in);
$needInD = $bdefault_present * $needExpr;
$needInAtt = $needInD + $needInND;
$needPerformatives = 1;
$needAtom = 1;
$needInit = 1;
$needDefaultPresent = $bdefault_present + $needDirND + $needMatND + $needInND + $needValND + $needOrientedND;
$needDefaultPresentFO = $needDefaultPresent * $needFO;
//Step 1. Assemble the language foundation
//Step 1A. Assemble the propositional language
// Add the start statement
echo $start;
// Include the root and performatives if needed
if ($needPerformatives){
echo "#\n# ROOT NODE AND PERFORMATIVES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'performative_expansion_module.rnc"'."$end\n";
}
//Step 1B. Assemble the backbone expressivity from expansion modules
if ($needAtom){
echo "#\n# ATOMIC FORMULAS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'atom_expansion_module.rnc"'."$end\n";
}
if ($needAndOr){
echo "#\n# CONJUNCTIONS AND DISJUNCTIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'andor_expansion_module.rnc"'."$end\n";
}
if ($needImp){
echo "#\n# IMPLICATIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'implication_expansion_module.rnc"'."$end\n";
}
if ($needQuant){
echo "#\n# QUANTIFICATION OVER VARIABLES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'quantification_expansion_module.rnc"'."$end\n";
}
if ($needExpr){
echo "#\n# EXPRESSIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'expr_expansion_module.rnc"'."$end\n";
}
if ($needDis){
echo "#\n# DISJUNCTIONS IN CONCLUSIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'dis_expansion_module.rnc"'."$end\n";
}
if ($needFO){
echo "#\n# RESTRICTIONS ON COMPOUNDING CLASSICAL FORMULAS REMOVED \n";
if ($needNeg){
echo "# FULL FIRST-ORDER EXPRESSIVITY (INCLUDING NEGATION) IS AVAILABLE \n";
}
echo "#\n".'include "' . $modulesLocation .
'folog_cl_expansion_module.rnc"'."$end\n";
}
//Step 1C. Include the appropriate module(s) for default values present
// absent, or optional
echo "#\n# ATTRIBUTES WITH DEFAULT VALUES ARE INITIALIZED\n";
echo "#\n".'include "' . $modulesLocation .
'default_inf_expansion_module.rnc"'."$end\n";
if ($needDefaultAbsent){
echo "#\n# ATTRIBUTES WITH DEFAULT VALUES ARE ABSENT OR OPTIONAL\n";
echo "#\n".'include "' . $modulesLocation .
'default_absent_expansion_module.rnc"'."$end\n";
}
if ($needDefaultAbsentFO){
echo 'include "' . $modulesLocation .
'default_absent_folog_expansion_module.rnc"'."$end\n";
}
if ($needDefaultPresent) {
echo "#\n# ATTRIBUTES WITH DEFAULT VALUES REQUIRED\n";
echo "#\n".'include "' . $modulesLocation .
'default_present_expansion_module.rnc"'."$end\n";
}
if ($needDefaultPresentFO){
echo 'include "' . $modulesLocation .
'default_present_folog_expansion_module.rnc"'."$end\n";
}
//Step 1D. Determine which module to include for positional arguments
if ($needUn){
echo "#\n# UNARY TERM (ONE TERM ONLY) SEQUENCES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'termseq_un_expansion_module.rnc"'."$end\n";
}
if ($needBin){
echo "#\n# BINARY TERM (TWO TERMS ONLY) SEQUENCES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'termseq_bin_expansion_module.rnc"'."$end\n";
}
if ($needPoly){
echo "#\n# POLYADIC TERM (ONE OR MORE TERMS) SEQUENCES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'termseq_poly_expansion_module.rnc"'."$end\n";
}
//Step 3F. Include serialization modules
// DOCUMENTME: apparent violation of monotonicity with else clause
// However, ordered groups is contained in unorder groups
// so it is redundant.
// Include unordered groups
if ($needUnordered){
echo "#\n# ORDER MODE - UNORDERED GROUPS ENABLED\n";
echo "#\n".'include "' . $modulesLocation .
'unordered_groups_expansion_module.rnc"'."$end\n";
}
if ($needOrdered){
echo "#\n# ORDER MODE - UNORDERED GROUPS DISABLED\n";
echo "#\n".'include "' . $modulesLocation .
'ordered_groups_expansion_module.rnc"'."$end\n";
}
// Include stripe-skipping
if ($needStripeSkip){
echo "#\n# STRIPE-SKIPPING MODE ENABLED\n";
echo "#\n".'include "' . $modulesLocation .
'stripe_skipping_expansion_module.rnc"'."$end\n";
echo "#\n".'include "' . $modulesLocation .
'asynchronous_stripe_skipping_entailment_expansion_module.rnc"'."$end\n";
echo "#\n".'include "' . $modulesLocation .
'asynchronous_stripe_skipping_implication_expansion_module.rnc"'."$end\n";
}
// Include explicit datatyping
if ($needDatatyping){
echo "#\n# EXPLICIT DATATYPING ENABLED\n";
echo "#\n".'include "' . $modulesLocation .
'explicit_datatyping_expansion_module.rnc"'."$end\n";
echo 'include "' . $modulesLocation .
'dataterm_simple_expansion_module.rnc"'."$end\n";
echo 'include "' . $modulesLocation .
'data_simple_content_expansion_module.rnc"'."$end\n";
}
// Include xsi:schemaLocation
if ($needSchemaLocation){
echo "#\n# xsi:schemaLocation ALLOWED IN RuleML\n";
echo "#\n".'include "' . $modulesLocation .
'xsi_schemalocation_expansion_module.rnc"'."$end\n";
}
//Step 4. Mix-in optional expansion modules
//Step 4A. Include proposition-related modules
// Include universal resource identifiers (URIs) if needed
if ($needURI){
echo "#\n# UNIVERSAL RESOURCE IDENTIFIERS (URIs) INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'iri_expansion_module.rnc"'."$end\n";
}
// Include rulebases if needed
if ($needRulebase){
echo "#\n# RULEBASES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'rulebase_expansion_module.rnc"'."$end\n";
}
// Include entailments if needed
if ($needEntails){
echo "#\n# ENTAILMENTS (PROVES) INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'metalevel_expansion_module.rnc"'."$end\n";
}
// Include degree of uncertainty if needed
if ($needFuzzy){
echo "#\n# DEGREE OF UNCERTAINTY INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'fuzzy_expansion_module.rnc"'."$end\n";
}
// Include strong negations if needed
if ($needNeg){
echo "#\n# STRONG NEGATION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'neg_expansion_module.rnc"'."$end\n";
}
// Include weak negations if needed
if ($needNaf){
echo "#\n# WEAK NEGATIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'naf_expansion_module.rnc"'."$end\n";
}
// Include node identifiers if needed
if ($needNode){
echo "#\n# NODE IDENTIFIERS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'node_attribute_expansion_module.rnc"'."$end\n";
}
// Include in-place annotations if needed
if ($needMeta){
echo "#\n# IN-PLACE ANNOTATIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'meta_expansion_module.rnc"'."$end\n";
}
// Include XML base attribute if needed
if ($needBase){
echo "#\n# XML BASE ATTRIBUTE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'xml_base_expansion_module.rnc"'."$end\n";
}
// Include XML id attribute if needed
if ($needId){
echo "#\n# XML ID ATTRIBUTE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'xml_id_expansion_module.rnc"'."$end\n";
}
//Step 4B. Include implication-related modules
// Include equivalences
if ($needEquiv){
echo "#\n# EQUIVALENCES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'equivalent_expansion_module.rnc"'."$end\n";
}
// Include inference direction attribute if needed
if ($needDirAtt){
echo "#\n# INFERENCE DIRECTION ATTRIBUTE IS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'direction_attrib_expansion_module.rnc"'."$end\n";
}
// Include non-symmetric inference direction attribute value if needed
if ($needDirND){
echo "#\n# NON-DEFAULT VALUES OF INFERENCE DIRECTION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'direction_non-default_expansion_module.rnc"'."$end\n";
}
// Include symmetric inference direction attribute value if needed
if ($needDirD){
echo "#\n# DEFAULT VALUES OF INFERENCE DIRECTION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'direction_default_expansion_module.rnc"'."$end\n";
}
// Include material implication attributes if needed
if ($needMatAtt){
echo "#\n# MATERIAL IMPLICATION ATTRIBUTE IS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'material_attrib_expansion_module.rnc"'."$end\n";
}
// Include non-material implication if needed
if ($needMatND){
echo "#\n# NON-DEFAULT VALUES OF MATERIAL IMPLICATION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'material_non-default_expansion_module.rnc"'."$end\n";
}
// Include material implication if needed
if ($needMatD){
echo "#\n# DEFAULT VALUES OF MATERIAL IMPLICATION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'material_default_expansion_module.rnc"'."$end\n";
}
//Step 3C. Include term-related modules
// Include object identifiers
if ($needOid){
echo "#\n# OBJECT IDENTIFIERS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'oid_expansion_module.rnc"'."$end\n";
}
// Include slots
if ($needSlot){
echo "#\n# SLOTS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'slot_expansion_module.rnc"'."$end\n";
}
// Include slot cardinality
if ($needCard){
echo "#\n# SLOT CARDINALITY INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'card_expansion_module.rnc"'."$end\n";
}
// Include slot weights
if ($needWeight){
echo "#\n# SLOT WEIGHTS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'weight_expansion_module.rnc"'."$end\n";
}
// Include equations
if ($needEqual){
echo "#\n# EQUATIONS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'equal_expansion_module.rnc"'."$end\n";
}
// Include oriented equality attribute if needed
if ($needOrientedAtt){
echo "#\n# ORIENTED EQUALITY ATTRIBUTE IS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'oriented_attrib_expansion_module.rnc"'."$end\n";
}
// Include non-symmetric equality attribute values if needed
if ($needOrientedND){
echo "#\n# NON-DEFAULT VALUES OF ORIENTED EQUALITY ATTRIBUTE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'oriented_non-default_expansion_module.rnc"'."$end\n";
}
// Include symmetric equality attribute values if needed
if ($needOrientedD){
echo "#\n# DEFAULT VALUE OF ORIENTED EQUALITY ATTRIBUTE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'oriented_default_expansion_module.rnc"'."$end\n";
}
// Include explicit typing of terms if needed
if ($needType){
echo "#\n# EXPLICIT TYPING OF TERMS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'type_expansion_module.rnc"'."$end\n";
}
// Include data terms if needed
if ($needDataTerms){
echo "#\n# DATA TERMS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'dataterm_any_expansion_module.rnc"'."$end\n";
}
// Include data element if needed
// for example, for either terms or degree of uncertainty
if ($needData){
echo "#\n# DATA ELEMENTS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'data_any_content_expansion_module.rnc"'."$end\n";
}
// Include skolem constants if needed
if ($needSkolem){
echo "#\n# SKOLEM CONSTANTS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'skolem_expansion_module.rnc"'."$end\n";
}
// Include reified terms if needed
// DOCUMENTME: apparent violation of monotonicity with else clause
// needed for conversion to XSD with process strict
// In that case, monotonicity is preserved.
if ($needReify){
if ($needSchemaLocation){
echo "#\n# REIFICATION TERMS INCLUDED, EXPLICIT CONTENT\n";
echo "#\n".'include "' . $modulesLocation .
'reify_expansion_module.rnc"'."$end\n";
} else {
// FIXME: this module is needed for conversion of the reify syntax to XSD
// It is a HACK to use the "xsi:schemaLocation" selector to also switch the reification module.
// Instead, there should be an explicit option in MYNG for "pivot"
echo "#\n# REIFICATION TERMS INCLUDED, ANY CONTENT\n";
echo "#\n".'include "' . $modulesLocation .
'reify_any_expansion_module.rnc"'."$end\n";
}
}
// Include individuals if needed
if ($needInd){
echo "#\n# INDIVIDUAL TERMS (INTERPRETED NAMES) ARE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'individual_expansion_module.rnc"'."$end\n";
}
// Include variables if needed
if ($needVar){
echo "#\n# VARIABLES (INTERPRETABLE NAMES) ARE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'variable_expansion_module.rnc"'."$end\n";
}
//Step 3D. Include quantification-related modules if needed
// Include implicit closure if needed
if ($needClosure){
echo "#\n# IMPLICIT CLOSURE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'closure_expansion_module.rnc"'."$end\n";
}
// Include slotted rest variables if needed
if ($needResl){
echo "#\n# SLOTTED REST VARIABLES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'resl_expansion_module.rnc"'."$end\n";
}
// Include positional rest variables if needed
if ($needRepo){
echo "#\n# POSITIONAL REST VARIABLES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'repo_expansion_module.rnc"'."$end\n";
}
//Step 3E. Include expression-related modules
// Include generalized lists
if ($needPlex){
echo "#\n# GENERALIZED LISTS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'plex_expansion_module.rnc"'."$end\n";
}
// Include empty initialization of set-valued attribute if needed
if ( $needValAbsent ){
echo "#\n# SET-VALUED EXPRESSION ATTRIBUTE IS ABSENT OR OPTIONAL\n";
echo "#\n".'include "' . $modulesLocation .
'val_absence_expansion_module.rnc"'."$end\n";
}
// Include set-valued expression attribute if needed
if ($needValAtt){
echo "#\n# SET-VALUED EXPRESSION ATTRIBUTE IS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'val_attrib_expansion_module.rnc"'."$end\n";
}
// Include non-default values of set-valued expression attribute if needed
if ($needValND){
echo "#\n# NON-DEFAULT VALUES OF THE SET-VALUED ATTRIBUTE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'val_non-default_expansion_module.rnc"'."$end\n";
}
// Include default values of set-valued expression attribute if needed
if ($needValD){
echo "#\n# DEFAULT VALUE OF THE SET-VALUED ATTRIBUTE INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'val_default_expansion_module.rnc"'."$end\n";
}
// Include interpreted expression attribute if needed
if ($needInAtt){
echo "#\n# INTERPRETED EXPRESSION ATTRIBUTE IS INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'per_attrib_expansion_module.rnc"'."$end\n";
}
// Include non-default values of interpretation of expressions if needed
if ($needInND){
echo "#\n# NON-DEFAULT VALUES OF EXPRESSION INTERPRETATION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'per_non-default_expansion_module.rnc"'."$end\n";
}
// Include default values of interpretation of expressions if needed
if ($needInD){
echo "#\n# DEFAULT VALUE OF EXPRESSION INTERPRETATION INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'per_default_expansion_module.rnc"'."$end\n";
}
//Step 4B. Initialize abstract patterns
if ($needInit){
echo "#\n# INITIALIZATION MODULES INCLUDED\n";
echo "#\n".'include "' . $modulesLocation .
'init_expansion_module.rnc"'."$end\n";
}
//Step 4A. Translate to requested xs:lang
// FIXME: need to handle differently when more than one alternate available
// or simulataneous alternate element names allowed
if ($blng){
// Include long English element names
if ($needLongNames){
echo "#\n# LONG ENGLISH ELEMENT NAMES\n";
echo "#\n".'include "' . $modulesLocation .
'long_name_expansion_module.rnc"'."$end\n";
// this second module is separated out because of a short-coming in trang
// where element xyz{notAllowed} is not simplified to notAllowed
// with the result that we cannot rename abstract elements if
// we want to be able to generate XSD or monolithic content-models
if ($needRepo){
echo "#\n".'include "' . $modulesLocation .
'long_name_repo_expansion_module.rnc"'."$end\n";
}
if ($needResl){
echo "#\n".'include "' . $modulesLocation .
'long_name_resl_expansion_module.rnc"'."$end\n";
}
}
}
echo "\n#";
}
//Functions
function processGETParameter ($paramName){
//FIXME: error/warning handling needs to be cleaned up
// if a parameter is not passed, then select sup(remum) or inf(imum) value depending on value of parameter "mode" (default sup)
$param_base_default = "x";
$bparam_default = decbin(hexdec(fff));
$param = $_GET[$paramName];
//echo("#\n# The ".$paramName." parameter has length ".strlen($param)."\n");
if (strlen($param)>0){
$param_base = substr($param,0,1);
} else {
$param_base = $param_base_default;
}
if (preg_match('/x|0/',$param_base)){
//echo("# The ".$paramName." parameter base is ".$param_base."\n");
if (strcmp($param_base, 'x')==0){
$xparam = substr($param,1);
//echo("# The ".$paramName." parameter was provided in hexadecimal");
//echo(" as ".$xparam);
//echo(".\n");
if (ctype_xdigit($xparam)) {
$bparam = decbin(hexdec($xparam));
} else {
echo "#\n# Warning: The string $xparam does not consist of all".
"hexadecimal digits.\n";
echo "# Default (supremum) ".$paramName." parameter is assumed.\n";
$bparam = $bparam_default;
}
} elseif (strcmp($param_base, '0')==0){
$bparam = 0;
}
} else {
echo "<#\n# Warning: The ".$paramName." parameter ".$param." is not a".
" hexidecimal or blank string.\n";
echo "# Default (supremum) ".$paramName." parameter is assumed.\n";
$bparam = $bparam_default;
}
//echo("#\n# The ".$paramName." parameter is ".$bparam." in binary.\n");
return $bparam;
}
function extractBit ($bparam, $bitIndex) {
if (strlen($bparam)>$bitIndex) {
$bparamBit = (boolean) (substr($bparam, -1-$bitIndex, 1)==1);
} else {
$bparamBit = false;
}
return $bparamBit;
}
?>