Valid Xml not validate with xsd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi:

I am working with a xml document that is validate with a schema.

Within php the xml does not validate, but if i use a external validator the
same xml validates with no problems.

My Php is now 5.2.14, but i test with 5.3.1 and the same problem.

I create a small program as example:

libxml_use_internal_errors(true);
$xDocXml = 'test-file.xml'; // xml

$xmldoc = new DOMDocument();
$bErro = $xmldoc->load( $xDocXml ); // loads xml

if ( $bErro )
{
    $return = $xmldoc->schemaValidate( 'nfe_v2.00.xsd' );

    if ( !$return )
    {
        $aErros = libxml_get_errors();

        $sErro = '';
        foreach ( $aErros as $oErro )
        {
            switch ( $oErro->level )
            {
                case LIBXML_ERR_WARNING:
                    $sErrosErro .= ' Atenção ' . $oErro->code . ": \n";
                    break;
                case LIBXML_ERR_ERROR:
                    $sErro .= ' Erro ' . $oErro->code . ": \n";
                    break;
                case LIBXML_ERR_FATAL:
                    $sErro .= ' Erro Fatal ' . $oErro->code . ": \n";
                    break;
            }

            $sErro .= '--------------------------------------------' . "\n";
            $sErro .= $oErro->message;
            $sErro .= ' Line: ' . $oErro->line . "\n";
            $sErro .= ' Column: ' . $oErro->column . "\n";
            $sErro .= ' Level: ' . $oErro->level . "\n";
        }
        echo '<pre>';
        echo $sErro;
        echo '</pre>';
    } else
        echo 'VALID!!!!';
}

Result a this moment:

Erro 1839: 
--------------------------------------------
Element '{http://www.portalfiscal.inf.br/nfe}IE': [facet 'pattern'] The
value '' is not accepted by the pattern 'ISENTO|[0-9]{0,14}'.
 Line: 59
 Column: 0
 Level: 2
 Erro 1824: 
--------------------------------------------
Element '{http://www.portalfiscal.inf.br/nfe}IE': '' is not a valid value of
the atomic type '{http://www.portalfiscal.inf.br/nfe}TIeDest'.
 Line: 59
 Column: 0
 Level: 2

This is the rule that fails :

	<xs:simpleType name="TIeDest">
		<xs:annotation>
			<xs:documentation>Tipo Inscrição Estadual do
Destinatário</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:pattern value="ISENTO|[0-9]{0,14}"/>
		</xs:restriction>
	</xs:simpleType>


In the xml file the line 59 has : <IE></IE>

The pattern for this tag is : <xs:pattern value="ISENTO|[0-9]{0,14}"/>

When i change this <xs:pattern value="ISENTO|[0-9]{0,14}"/> to <xs:pattern
value="[0-9]{0,14}|ISENTO"/> work ok, buts each document that has
<IE>ISENTO</IE> fails validation.

I attached a small rar file with the test case.

How to change the pattern to meets the requirements: or value ISENTO ou
number [0-9]{0,14} or empty ?

Thanks in advance

Alejandro M.S.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux