Validation using schematron?

Discussion in 'XML' started by Marco Cyriacks, May 7, 2010.

    Hash: SHA1

    Dear all,

    within a C++ application I use xerces-c to validate XML instances
    against a XML schema. This works very fine for me but currently I try to
    realise the validation of some inner restricting for those XML
    instances. Some examples:

    1. If element 'PluginDescription' has the optional attribute 'attrPD'
    and this attribute is true, the child element 'Resources' has to have
    exactly one child element 'Resource' with an attribute 'attrR="AAA"'
    (check against existence and value of that attribute).

    <PluginDescription attrPD="true">
    <Resource attrR="AAA"/>

    2. If element 'PluginDescription' does not have the optional attribute
    'attrPD' or this attribute is false, the contents and number of child
    elements for 'Resources' is arbitrarily.

    <PluginDescription attrPD="false">
    <Resource attrR="AAA"/>
    <Resource attrR="BBB"/>

    <Resource attrR="AAA"/>


    Is it possible to validate a XML instance against these restrictions? If
    I'm right, it is not possible to do this using XML schema.

    My ideas on it:

    - - Implementation of the validation against those restrictions in my
    application using C++ and xerces-c

    This might by the easiest solution but will force application change
    and recompilation if the restrictions change.

    - - Creation of schematron

    During a web research I found informations on XML schematron.
    Unfortunately my first trials on that failed. Is it possible to validate
    my XML instances against the presented restrictions using schematron?

    Any help would be appreciated!

    Best regards,
    Version: GnuPG v1.4.10 (GNU/Linux)
    Comment: Using GnuPG with Fedora -

    -----END PGP SIGNATURE-----
    Marco Cyriacks, May 7, 2010
    1. Advertisements

  2. Hello Marco,

    Yes, no co-constraints can be implemented in XML Schema 1.0. You may
    have a look at XML Schema 1.1, it is enhanced with schematron-like
    Sorry, I can't help with the current files. My Saxon isn't that new.

    I use a slightly older version of the public XSLT scripts (by December
    15th, 2009) that work out of the box.

    You could post your Schematron file and the according XML file in order
    to check the syntax.
    Of course, your constraints are a nice task for Schematron.

    read you ...
    Susanne Wunsch, May 7, 2010
    1. Advertisements

    Hash: SHA1

    Hi Susanne,

    thanks for your reply!

    I did a short web search on that but I think that Xerces-C (the XML
    parser I use) is not yet able to handle XML schema 1.1, at least the
    version of xerces-c that is distributed with my operating system

    Currently and only for testing I use xsltproc
    ( that is only able to handle
    XSLT 1.0 therefore I took the reference implementation of schematron from

    This might be the same you use...?

    Obviously I had some syntax problems in my quick'n'dirty schematron.
    This afternoon I tried to check the example on

    I was able to validate that example using the following script:

    - ------------------------------------------------------

    echo Step1 ...
    xsltproc iso_dsdl_include.xsl $1 > step1.xsl

    echo Step2 ...
    xsltproc iso_abstract_expand.xsl step1.xsl > step2.xsl

    echo Step3 ...
    xsltproc iso_svrl_for_xslt1.xsl step2.xsl > step3.xsl

    echo Validation ...
    xsltproc step3.xsl $2 > result.svrl
    - ------------------------------------------------------

    Everything went fine and I got the expected result.

    Now I have to figure out how to create the correct schematron for my
    problem... ok, there are still some hours left today :)

    Best regards,
    Version: GnuPG v1.4.10 (GNU/Linux)
    Comment: Using GnuPG with Fedora -

    -----END PGP SIGNATURE-----
    Marco Cyriacks, May 7, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.