Is this a PHP bug?
Posted: Sat Oct 16, 2010 10:11 pm
<daysupply>1</daysupply> doesn't pass the schema validation below, but <daysupply>1.</daysupply> does. Is this a PHP bug?
// MySchema.xsd
// schemaValidate.php
// MySchema.xsd
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="mytype">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+(\.|)[0-9]*"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="daysupply" type="mytype"/>
</xs:schema>
Code: Select all
<?php
$xmlString = '<?xml version="1.0" encoding="utf-8"?>
<daysupply>1</daysupply>';
$xml = new DOMDocument();
$xml->loadXML($xmlString);
if (!$xml->schemaValidate('MySchema.xsd'))
{
echo 'schemaValidate() Generated Errors!';
return false;
}
echo 'XML is valid';
?>