OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Newbie question : using XML to validate grammar (Schematro

[ Lists Home | Date Index | Thread Index ]

MSXML does not have a Schematron validator. You will need to use some separate code or a dedicated Schematron processor. I use the Schematron skeleton XSLT to create an XSLT file, then process the document using  this. In a test environment, you can just use transformNodeToObject to create the stylesheet, then transformNode to provide a validation output. I have not tried the skeleton with embedded Schematron - you might need to modify it slightly or pre-process your schema to pull out the Schematron parts.
 
In a production environment, you would probably want to do the first transformation once only, then store the result. A quick google will find the skeleton and names of Schematron processors.
 
Paul
-----Original Message-----
From: samy sayag [mailto:samuelsayag@yahoo.fr]
Sent: 08 June 2006 09:06
To: xml-dev@lists.xml.org
Subject: [xml-dev] Newbie question : using XML to validate grammar (Schematron & XML Schema)

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) &lt; 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





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS