Open($userInfo);
$featureSrvc = $site->CreateService(MgServiceType::FeatureService);
$resId = new MgResourceIdentifier($resName);
$classCollection = $featureSrvc->GetClasses($resId, $schemaName);
$firstClass = substr(strrchr($classCollection->GetItem(0), ":"), 1);
$classNames = new MgStringCollection();
$classNames->Add($className);
$xml = $featureSrvc->DescribeSchemaAsXml($resId, $schemaName, $classNames);
// Parse the xml for encoded characters, however, the 'xmlns' attribute under 'targetNamespace' element
// cannot contain the translated or encoded characters. This replaces '-xffXX-' with 'ffXX' for that
// particular string while the rest of the encoded chars are translated properly.
$subXml = substr($xml, strpos($xml, 'xs:element'), -1);
$subXml = preg_replace("/-x([A-Za-z0-9]{1,4})-/e", "html_entity_decode(''.hexdec('$1').';',ENT_NOQUOTES,'UTF-8')", $subXml);
$xml = substr_replace($xml, $subXml, strpos($xml, 'xs:element'), -1);
$nameSpaceStart = strpos($xml, 'targetNamespace="');
$nameSpaceEnd = strpos($xml, '"', $nameSpaceStart+17);
$nameSpace = substr($xml, $nameSpaceStart, $nameSpaceEnd-$nameSpaceStart);
$nameSpaceModified = preg_replace("/-x([A-Za-z0-9]{1,4})-/e", "html_entity_decode(''.hexdec('$1').';',ENT_NOQUOTES,'UTF-8')", $nameSpace);
$xml = str_replace($nameSpace, $nameSpaceModified, $xml);
$xml = preg_replace("/-x([A-Za-z0-9]{1,4})-/e", "'$1'", $xml);
$xsl_file = 'displayschema.xsl';
// Create new object for the XML file
$xml_object = new DomDocument();
if(!$xml)
exit(ErrorMessages::XmlNotFound);
$xml_object->loadXML($xml);
// Create new object for the XSL stylesheet
$xsl_object = new DomDocument();
if(!file_exists($xsl_file))
exit(ErrorMessages::XslNotFound);
$xsl_object->load($xsl_file);
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl_object);
$proc->setParameter('', 'schemaName', $schemaName);
$proc->setParameter('', 'className', $className);
$proc->setParameter('', 'resName', $resName);
$proc->setParameter('', 'sessionId', $sessionId);
$proc->setParameter('', 'viewer', $viewer);
// Set localized strings
$proc->setParameter('', 'stringSchema', XslStrings::Schema);
$proc->setParameter('', 'stringClassTitle', XslStrings::ClassTitle);
$proc->setParameter('', 'stringViewData', XslStrings::ViewData);
$proc->setParameter('', 'stringViewFeature', XslStrings::ViewFeature);
$proc->setParameter('', 'stringDataProperties', XslStrings::DataProperties);
$proc->setParameter('', 'stringGeometricProperties', XslStrings::GeometricProperties);
$proc->setParameter('', 'stringPropertyName', XslStrings::PropertyName);
$proc->setParameter('', 'stringPropertyType', XslStrings::PropertyType);
$proc->setParameter('', 'stringHasMeasures', XslStrings::HasMeasures);
$proc->setParameter('', 'stringHasElevation', XslStrings::HasElevation);
$proc->setParameter('', 'stringNoGeometry', XslStrings::NoGeometry);
$proc->setParameter('', 'stringNoData', XslStrings::NoData);
$proc->setParameter('', 'stringSrsName', XslStrings::SrsName);
$html = $proc->transformToXML($xml_object);
print($html);
}
catch (MgException $e)
{
$errorMsg = $e->GetExceptionMessage();
$errorMsg = str_replace('\n', '
', $errorMsg);
echo $errorMsg;
}
?>