XML - Validacion XML-Schema?¿ por que no funciona..?

 
Vista:

Validacion XML-Schema?¿ por que no funciona..?

Publicado por Richard (1 intervención) el 15/02/2008 17:35:53
No se poruq no me funciona este pareja XML-esquema, cuando está posteado en la web en multiples lugares así y a mi simplemente no me funcoina con un error de "Invalid Schema" del compilador PHP... alguna idea? gracias por adelantado...

el codigo php

<?xml version="1.0" encoding="UTF-8"?>
<candidate>
<candidatename id='candid'>Robert</candidatename>
<candidatecity>New York</candidatecity>
<SSN>20072007</SSN>
<organization>XYZ Corp</organization>
</candidate>

el esquema

<?xml version="1.0" encoding="UTF-8"?>
<xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="SSN" type="xs:int"/>
<xs:element name="organization" type="xs:string"/>
<xs:element name="candidate">
<xs:complexType>
<xs:sequence>
<xs:element ref="candidatename"/>
<xs:element ref="candidatecity"/>
<xs:element ref="SSN"/>
<xs:element ref="organization"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="candidatecity" type="xs:string"/>
<xs:element name="candidatename">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>

el codigo php...

<?php
$xdoc = new DomDocument;
$xmlfile = 'C:/php/xmlfiles/candidate.xml';
$xmlschema = 'C:/php/xmlfiles/candidate.xsd';
//Load the xml document in the DOMDocument object
$xdoc->Load($xmlfile);
//Validate the XML file against the schema
if ($xdoc->schemaValidate($xmlschema)) {
print "$xmlfile is valid. ";
} else {
print "$xmlfile is invalid. ";
}
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder