[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
RE: [xml] XSchema and libxml
- From: "Buchcik, Kasimier" <k buchcik 4commerce de>
- To: "Hei Chan" <structurechart yahoo com>
- Cc: xml gnome org
- Subject: RE: [xml] XSchema and libxml
- Date: Tue, 23 May 2006 22:07:54 +0200
Hi,
> -----Original Message-----
> From: Hei Chan [mailto:structurechart yahoo com]
>
> Hi Kasimier,
> I have a question about your really old post:
> http://mail.gnome.org/archives/xml/2005-March/msg00048.html
>
> I have tried your example with libxml 2.6.23. It
> gives me:
>
> test.xml:6: element note: Schemas validity error :
> Element '{http://www.w3schools.com}note': No matching
> global declaration available for the validation root.
> The document 'test.xml' is not valid.
I get the following with your scenario:
xmllint --noout --schema http://localhost:8080/text.xsd test.xml
test.xml validates
> Here is the XML:
> <?xml version="1.0"?>
>
> <note
> xmlns="http://www.w3schools.com"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://localhost/test.xsd">
>
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
>
> Here is the XSD:
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com"
> xmlns="http://www.w3schools.com"
> elementFormDefault="qualified">
>
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="to" type="xs:string"/>
> <xs:element name="from" type="xs:string"/>
> <xs:element name="heading" type="xs:string"/>
> <xs:element name="body" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
>
> If I do the following:
> pCtxt =
> xmlSchemaNewParserCtxt("http://localhost/test.xsd");
> schema = xmlSchemaParse(pCtxt);
> ctxt = xmlSchemaNewValidCtxt(scheam);
> ret = xmlSchemaValidateDoc(ctxt, doc);
> , then it works.
>
> Is there something wrong with my XML or XSD? Or is
> the feature(looking up XSD via xsi) turned off?
Right, with xmllint the XSI information is not processed
automatically; you need to specify explicitely both, the
schema and the instance. Actually this is a long-standing
enhancement request, and I currently could also use such a
mechanism in order to plug in Libxml2's XML Schema facility
into my favourite XML editor.
Daniel, would it be OK to add such an option to xmllint?
Relevant bugzilla-entries:
http://bugzilla.gnome.org/show_bug.cgi?id=157205
http://bugzilla.gnome.org/show_bug.cgi?id=157973
> In addition to that, is there a way to validate a XML
> against the corresponding schema(specified in the XML)
> automatcially regardless the type of the schema(e.g.
> DTD, XSD, RelaxNG or whatever)?
I don't think so. But you can try to write one.
Regards,
Kasimier
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]