Is this a PHP bug?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wenrd
Forum Newbie
Posts: 2
Joined: Sat Oct 16, 2010 9:50 pm

Is this a PHP bug?

Post 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';
?>
Last edited by Weirdan on Sat Oct 16, 2010 10:48 pm, edited 2 times in total.
Reason: [syntax] tags
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Is this a PHP bug?

Post by Weirdan »

No, it's your regexp being weird. What are you trying to achieve?
wenrd
Forum Newbie
Posts: 2
Joined: Sat Oct 16, 2010 9:50 pm

Re: Is this a PHP bug?

Post 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.
Post Reply