Page 1 of 1

Is this a PHP bug?

Posted: Sat Oct 16, 2010 10:11 pm
by wenrd
<daysupply>1</daysupply> doesn't pass the schema validation below, but <daysupply>1.</daysupply> does. Is this a PHP bug?
// 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>
// schemaValidate.php

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';
?>

Re: Is this a PHP bug?

Posted: Sat Oct 16, 2010 10:49 pm
by Weirdan
No, it's your regexp being weird. What are you trying to achieve?

Re: Is this a PHP bug?

Posted: Sat Oct 16, 2010 11:04 pm
by wenrd
Weirdan wrote:No, it's your regexp being weird. What are you trying to achieve?
I know the regexp looks weird, it is in a XSD file from 3th party. I need to validate XML files agaist it. It works fine in C# though.