私は主なデータが xsl 変換から来る XML 生成を行っています (しかし、それは問題ではなく、PHP DOM または SimpleXML を使用していない理由です)。
このような:
$xml = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
$xml .= '<rootElement>';
foreach($xslRenderings as $rendering) {
$xml .= $rendering;
}
$xml .= '</rootElement>';
結果の XML は、 http://www.freeformatter.com/xml-validator-xsd.htmlとhttp://xsdvalidation.utilities-online.info/の XSD に対して検証されます。
しかし、ここで失敗します: http://www.xmlforasp.net/schemavalidator.aspx、
Unexpected XML declaration. The XML declaration must be the first node in the
document, and no white space characters are allowed to appear before it.
Line 2, position 3.
PHP_EOL によって生成された改行を手動で削除してリターンを押すと、検証されます。
最後のスキーマバリデーターのエラーだと思います。それとも、PHP_EOL (または PHP の手動ブレーク) は、一部のバリデータにとって問題なのでしょうか? はいの場合、それを修正する方法は?
結果の XML が .NET サービスに送信され、最後のバリデーターが NET で構築されているため、私は尋ねています。
編集
XML は次のようになります。スキームはここにありますhttp://cb.heimat.de/interface/schema/interfaceformat.xsd
<?xml version="1.0" encoding="utf-8"?>
<dataset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://cb.heimat.de/interface/schema/interfaceformat.xsd">
<production foreignId="1327" id="0" cityId="6062" productionType="3" subCategoryId="7013" keywords="" productionStart="" productionEnd="" url=""><title languageId="1">
...
</production>