|
List Info
Thread: Re: schema validation
|
|
| Re: schema validation |

|
2007-01-24 16:43:11 |
|
Your code is ok, here my running result:
# schema x.xml x.xsd
Document validation completed: [x.xml][0]
I'm using 2.6.26.
> -----Original Message-----
> From: isil light [mailto:isil_light yahoo.com]
> Sent: Wednesday, January 24, 2007 1:29 PM
> To: Yong Chen (yongche)
> Subject: RE: [xml] schema validation
>
> "Yong Chen (yongche)" cisco.com> wrote:
>
> I have been using this api and have not had this problem.
>
> You may want to show your code.
>
> Yong Chen
>
> #include
>
> #include
> #include
>
> int main ( int argc, char *argv[] ) {
>
> int ret;
>
> xmlDocPtr doc;
>
> xmlSchemaParserCtxtPtr xsdpctx;
> xmlSchemaPtr xsdctx;
> xmlSchemaValidCtxtPtr xsd;
>
> if ( argc != 3 ) {
>
> fprintf ( stderr,
> "nusage: %s doc.xml schema.xsdnn",
> basename ( argv[0] ) );
>
> return ( -1 );
>
> }
>
> if ( ( xsdpctx = xmlSchemaNewParserCtxt ( argv[2] ) )
> == NULL ) {
>
> fprintf ( stderr,
> "Unable to create xsd context: [%s]n",
> argv[2] );
>
> return ( -1 );
>
> }
>
> if ( ( xsdctx = xmlSchemaParse ( xsdpctx ) ) == NULL ) {
>
> fprintf ( stderr,
> "Unable to parse xsd: [%s]n",
> argv[2] );
>
> xmlSchemaFreeParserCtxt ( xsdpctx );
>
> return ( -1 );
>
> }
>
> if ( ( xsd = xmlSchemaNewValidCtxt ( xsdctx ) ) == NULL ) {
>
> xmlSchemaFree ( xsdctx );
> xmlSchemaFreeParserCtxt ( xsdpctx );
>
> return ( -1 );
>
> }
>
>
> if ( ( doc = xmlParseFile ( argv[1] ) ) == NULL ) {
>
> fprintf ( stderr,
> "Unable to parse doc: [%s]n",
> argv[1] );
>
> xmlSchemaFreeValidCtxt ( xsd );
> xmlSchemaFree ( xsdctx );
> xmlSchemaFreeParserCtxt ( xsdpctx );
>
> return ( -1 );
>
> }
>
> ret = xmlSchemaValidateDoc ( xsd, doc );
>
> fprintf ( stderr,
> "Document validation completed: [%s][%d]n",
> argv[1],
> ret );
>
> xmlFreeDoc ( doc );
> xmlSchemaFreeValidCtxt ( xsd );
> xmlSchemaFree ( xsdctx );
> xmlSchemaFreeParserCtxt ( xsdpctx );
>
> return ( ret );
>
> }
>
>
> ________________________________
>
> Make free worldwide PC-to-PC calls. Try the new Yahoo! Canada
> Messenger with Voice
>
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome.org
http://mail.gnome.org/mailman/listinfo/xml
|
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|