[
Lists Home |
Date Index |
Thread Index
]
- To: xml-dev@lists.xml.org
- Subject: Newbie question : using XML to validate grammar (Schematron & XML Schema)
- From: samy sayag <samuelsayag@yahoo.fr>
- Date: Thu, 8 Jun 2006 10:05:56 +0200 (CEST)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=jIleyV497X0YSxZkWfCHtQUXCiJcTyisaGwVKlVBAH1njt3O568J8Cds/7Kd/c/EVxnzi9ON4XaJkDMQoXVJ7GXDFYqpOaxE1AVgtHh8TvwMfjin2jaRGt/AkdGMcRrQq8xLItz+T9uoHP01N1cHIi2JlVCiELlTo0raEaq/z9g= ;
Hi everybody,
i've searched in the archive for an answer but couldn't find it so let me ask the following question :
I've learned how to embed basic Schematron patterns in W3C XML Schema but couldn't find how to validate it with MSXML (4.0 or 6.0) parser programmatically.
Dim objSchemaCache As New MSXML2.XMLSchemaCache60 Dim objXMLDoc As New MSXML2.DOMDocument60 objSchemaCache.Add "", nameOfSchemaFile Set objXMLDoc.Schemas = objSchemaCache objXMLDoc.async = False objXMLDoc.Load nameOfXMLFile
' I raise the error if it exist with : If objXMLDoc.parseError.errorCode <> 0
With a simple schema it works marvellously well but the problem is that the parser doesn't seem to "recognize" the Shematron pattern embedded in my Schema.
I used basic xml and xml schema to test it, here are the following files :
the xml file :
<?xml version="1.0" encoding="UTF-8"?> <AAA
xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\samuel\Bureau\outil_statistiques\XML\ambiguite_shematron\ambigu1.xsd"> <BBB> <CCC>0</CCC> <CCC>0</CCC> <CCC>0</CCC> </BBB> </AAA>
the schematron+w3c xml schema file :
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="CCCType"> <xs:restriction base="xs:byte"> <xs:enumeration value="0"/>
<xs:enumeration value="-1"/> </xs:restriction> </xs:simpleType> <xs:element name="BBB"> <xs:annotation> <xs:appinfo> <sch:pattern name="Sum inf -1"> <sch:rule context="//BBB"> <sch:assert test="sum(//CCC) = 0">0 result</sch:assert> <sch:assert test="sum(//CCC) < 0">under 0
result </sch:assert> </sch:rule> </sch:pattern> </xs:appinfo> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="CCC" type="CCCType" maxOccurs="3"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="AAA">
<xs:complexType> <xs:sequence> <xs:element ref="BBB"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
I'd like to raise the fact that the sum is equal to 0 but cannot catch it. If you can help...
thanks
sam
__________________________________________________ Do You Yahoo!? En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités http://mail.yahoo.fr Yahoo! Mail
|