public function testDisjunctionOfConcatenation()
 {
     $visitor = new slRegularExpressionDtdVisitor();
     $this->assertEquals('( ( a ) | ( ( b ), ( c ) ) )', $visitor->visit(new slRegularExpressionChoice(new slRegularExpressionSequence(new slRegularExpressionElement(new slSchemaAutomatonNode('a', 'a'))), new slRegularExpressionSequence(new slRegularExpressionSequence(new slRegularExpressionElement(new slSchemaAutomatonNode('b', 'b'))), new slRegularExpressionSequence(new slRegularExpressionElement(new slSchemaAutomatonNode('c', 'c')))))));
 }
Example #2
0
 /**
  * Visit element
  *
  * Create the element DTD specification from the provided slSchemaElement 
  * object.
  * 
  * @param slSchemaElement $element 
  * @return string
  */
 protected function visitElement(slSchemaElement $element)
 {
     $regExpVisitor = new slRegularExpressionDtdVisitor();
     switch (true) {
         case $element->type->regularExpression instanceof slRegularExpressionEmpty && $element->type->simpleTypeInferencer->inferenceType() === 'empty':
             return sprintf("<!ELEMENT %s EMPTY>\n", $element->name);
         case $element->type->regularExpression instanceof slRegularExpressionEmpty:
             return sprintf("<!ELEMENT %s (#PCDATA)>\n", $element->name);
         case $element->type->simpleTypeInferencer->inferenceType() === 'empty':
             return sprintf("<!ELEMENT %s ( %s )>\n", $element->name, $regExpVisitor->visit($element->type->regularExpression));
         default:
             return sprintf("<!ELEMENT %s ( #PCDATA | %s )*>\n", $element->name, implode(' | ', array_map(function ($type) {
                 return $type->name;
             }, $this->extractTypes($element->type->regularExpression))));
     }
 }