Doc #75335 [NEW]: Missing code example in DOMDocument::schemaValidate
| From: | peterkokot at gmail dot com | Date: | Sun, 08 Oct 2017 00:34:12 +0000 |
| Subject: | Doc #75335 [NEW]: Missing code example in DOMDocument::schemaValidate | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-15048@lists.php.net to get a copy of this message | ||
From: peterkokot at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Missing code example in DOMDocument::schemaValidate
Description:
------------
Documentation at http://php.net/manual/en/domdocument.schemavalidate.php
is missing a code example. I would suggest to add an example from the
php-src repository:
----------shipping.xml----------
<?xml version="1.0"?>
<shipOrder>
<shipTo>
<name>Tove Svendson</name>
<street>Ragnhildvei 2</street>
<address>4000 Stavanger</address>
<country>Norway</country>
</shipTo>
<items>
<item>
<title>Empire Burlesque</title>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</items>
</shipOrder>
----------shipping.xml----------
----------shipping.xsd----------
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="shipOrder" type="order"/>
<xsd:complexType name="order">
<xsd:all>
<xsd:element name="shipTo" type="shipAddress"/>
<xsd:element name="items" type="cdItems"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="shipAddress">
<xsd:all>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="address" type="xsd:string"/>
<xsd:element name="country" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="cdItems">
<xsd:sequence>
<xsd:element name="item" type="cdItem"
maxOccurs="unbounded" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="cdItem">
<xsd:all>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="quantity"
type="xsd:positiveInteger"/>
<xsd:element name="price" type="xsd:decimal"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
----------shipping.xsd----------
----------shipping.php----------
<?php
$dom = new domDocument;
$dom->load('shipping.xml');
if (!$dom->schemaValidate('shipping.xsd')) {
print "Document is not valid";
} else {
print "Document is valid";
}
----------shipping.php----------
--
Edit bug report at https://bugs.php.net/bug.php?id=75335&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75335&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75335&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75335&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75335&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75335&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75335&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75335&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75335&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75335&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75335&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75335&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75335&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75335&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75335&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75335&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75335&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75335&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75335&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75335&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75335&r=mysqlcfg