/** * Get all elements occureing in a regular expression * * @param slRegularExpression $regExp * @return array */ protected function getChildElements(slRegularExpression $regExp) { if ($regExp instanceof slRegularExpressionElement) { return array($regExp->getContent()); } if (!$regExp instanceof slRegularExpressionContainer) { return array(); } $children = array(); foreach ($regExp->getChildren() as $child) { $children = array_merge($children, $this->getChildElements($child)); } return $children; }
/** * Extracts all types mentioned in a regular exression * * Returns an unique array with all types mentioned in the regular * expression, to create proper mixed types in the DTD schema output. * * @param slRegularExpression $regularExpression * @return array */ protected function extractTypes(slRegularExpression $regularExpression) { if ($regularExpression instanceof slRegularExpressionElement) { return array($regularExpression->getContent()); } if (!$regularExpression instanceof slRegularExpressionContainer) { return array(); } $types = array(); foreach ($regularExpression->getChildren() as $child) { $types = array_merge($types, $this->extractTypes($child)); } return array_unique($types); }