php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57804 Derived data type values aren't enforced
Submitted: 2007-08-28 16:56 UTC Modified: 2017-01-10 08:09 UTC
From: mattsch at gmail dot com Assigned:
Status: Suspended Package: SCA_SDO (PECL)
PHP Version: 5.2.3 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2007-08-28 16:56 UTC] mattsch at gmail dot com
Description:
------------
Derived string types liked normalizedString and token don't modify their values. 

http://www.w3.org/TR/xmlschema-2

3.3.1 normalizedString

[Definition:]   normalizedString represents white space normalized strings. The ?value space? of normalizedString is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters. The ?lexical space? of normalizedString is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters. The ?base type? of normalizedString is string


3.3.2 token

[Definition:]   token represents tokenized strings. The ?value space? of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. The ?lexical space? of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. The ?base type? of token is normalizedString

Reproduce code:
---------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="request" type="requestType"/>

<xsd:complexType name="requestType" abstract="true"/>

<xsd:complexType name="collectionInfo">
  <xsd:complexContent>
    <xsd:extension base="requestType">
      <xsd:sequence minOccurs="0" maxOccurs="unbounded">
        <xsd:element name="collection" type="xsd:token"/>
      </xsd:sequence>
      <xsd:attribute name="kind" type="xsd:string" fixed="collectionInfo"/>
    </xsd:extension>
  </xsd:complexContent>
</xsd:complexType>

<xsd:element name="request-list">
  <xsd:complexType>
     <xsd:sequence>
        <xsd:element ref="request" minOccurs="0" maxOccurs="unbounded"/>
     </xsd:sequence>
  </xsd:complexType>
</xsd:element>

</xsd:schema>

<?php

try {
	$xmldas = SDO_DAS_XML::create("request.xsd");
	try {
		$doc = $xmldas->createDocument('', 'request-list');
		$rdo = $doc->getRootDataObject();
		$request = $xmldas->createDataObject('', 'collectionInfo');
		$request->collection->insert('  
		foo        bar	
		  ');
		$request->kind = 'collectionInfo';
		$rdo->request->insert($request);
		print($xmldas->saveString($doc));
	} catch (SDO_Exception $e) {
		print($e);
	}
} catch (SDO_Exception $e) {
	print("Problem creating an XML document: " . $e->getMessage());
}

?>



Expected result:
----------------
The value for collection should trim the beginning and end and reduce the number of spaces between foo and bar to 2.

<?xml version="1.0" encoding="UTF-8"?>
<request-list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><request xsi:type="collectionInfo" kind="collectionInfo"><collection>foo  bar</collection></request></request-list>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<request-list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><request xsi:type="collectionInfo" kind="collectionInfo"><collection>
                foo     bar
                  </collection></request></request-list>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-28 16:57 UTC] mattsch at gmail dot com
Changed php version.
 [2007-08-29 07:09 UTC] gcc@php.net
The SDO C++ implementation does not currently preserve this additional type information (e.g. xsd:token) and therefore the serialization simply follows that for string.  

I'm not sure the serialization should modify the value as this could be risky in some circumstances.  I would however expect a warning or error stating that the data is not valid.

I've raised a Jira against Apache Tuscany SDO C++ as this is where the serialization is implemented.  See http://issues.apache.org/jira/browse/TUSCANY-1632 .
 [2007-08-29 10:15 UTC] mattsch at gmail dot com
You're right about the risk of modifying values.  I'm changing the subject to reflect this.
 [2017-01-10 08:09 UTC] kalle@php.net
-Status: Assigned +Status: Suspended -Assigned To: gcc +Assigned To:
 [2017-01-10 08:09 UTC] kalle@php.net
Suspending this report as the extension have not had a release for almost 9 years.  Please revive this if the extension once again shows life
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 08:01:28 2024 UTC