【问题标题】:XSD Schema 1.1 validation in PHPPHP 中的 XSD Schema 1.1 验证
【发布时间】:2017-09-26 07:52:40
【问题描述】:

我已经弄清楚如何使用此代码在 PHP 中使用 XSD 模式验证 XML 文件,但似乎该处理是使用 XSD 1.0 版完成的。

$dom = new DOMDocument();
$dom->loadXML($xmlString);

$isValid = $dom->schemaValidate($xsdFile);

就我而言,我需要将 XSD 文件视为 1.1 版。这样做的主要原因是我想使用:

<xs:all>
   <xs:element type="xs:string" name="br" minOccurs="0" maxOccurs="unbounded"/>
   <xs:element type="linkType" name="link" minOccurs="0" maxOccurs="unbounded"/>
</xs:all>

注意maxOccurs="unbounded",它只能在&lt;xs:all&gt; 内部使用,版本为1.1。在 1.0 版本中,maxOccurs 只能是 0 或 1。

PHP 失败并出现一般错误:

Warning: DOMDocument::schemaValidate(): Invalid Schema

【问题讨论】:

    标签: php xml xsd xsd-validation xsd-1.1


    【解决方案1】:

    DOMDocument::schemaValidate 使用 Libxml。 Libxml 不支持 XSD 1.1。

    【讨论】:

      猜你喜欢
      • 2016-07-09
      • 1970-01-01
      • 2011-01-24
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2016-10-19
      • 2016-02-03
      相关资源
      最近更新 更多