[oXygen-user] RelaxNG and Schematron
Sorin Ristache
Wed Mar 11 03:39:50 CDT 2009
Hello Christian,
You did not send layout_definitions.rng so I cannot test the whole
schema on an XML document. Your schema has at least two problems:
1. You have to use the ISO Schematron namespace in a RELAX NG schema,
not the Schematron 1.5 one, that is:
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
2. You have to specify the target namespace of the schema in the XPath
expressions:
<sch:ns prefix="layout" uri="http://www.docscape.de/layoutV4.2"/>
<sch:pattern>
<sch:rule context="//layout:Regel[@datensatz and @name]">
<sch:assert
test="count(//layout:Regel[@name=current()/@name and
@datensatz=current()/@datensatz]) le 1"
Regards,
Sorin
Christian Kosmowski wrote:
> Hi there!
>
> Due to some restrictions of XML Schema we are currently changing to
> RelaxNG. I now tried to take some Schematron rules of the old schema and
> put it in the new RelaxNG Schema to test if Schematron will work.
>
> This is my "root" File which includes other RelaxNG Schemas:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <grammar xmlns="http://relaxng.org/ns/structure/1.0"
> xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
> xmlns:sch="http://www.ascc.net/xml/schematron"
> datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
> ns="http://www.docscape.de/layoutV4.2">
>
> <include href="layout_definitions.rng"/>
>
> <sch:pattern>
> <sch:rule context="//Regel[@datensatz and @name]">
> <sch:assert test="count(//Regel[@name=current()/@name and
> @datensatz=current()/@datensatz]) le 1">Die Regel »<sch:value-of
> select="@name"/>« zu dem Datensatz »<sch:value-of select="@datensatz"/>«
> ist mehrfach vorhanden.</sch:assert>
> </sch:rule>
> <sch:rule context="//Regel[@datensatz and not(@name)]">
> <sch:assert test="count(//Regel[@datensatz=current()/@datensatz
> and not(@name)]) le 1">Die Regel zum Datensatz »<sch:value-of
> select="@datensatz"/>« ist mehrfach vorhanden.</sch:assert>
> </sch:rule>
> <sch:rule context="//Regel[@name and not(@datensatz)]">
> <sch:assert test="count(//Regel[@name=current()/@name and
> not(@datensatz)]) le 1">Die Regel »<sch:value-of select="@name"/>« ist
> mehrfach vorhanden.</sch:assert>
> </sch:rule>
> <sch:rule context="//Zuweisung">
> <sch:assert test="(//DefVariable[@name=current()/@name]) or
> exists(Name)">Variable »<sch:value-of select="@name"/>« nicht
> definiert.</sch:assert>
> </sch:rule>
> </sch:pattern>
> <start>
> <choice>
> <element name="Layout">
> <optional>
> <attribute name="version">
> <text/>
> </attribute>
> </optional>
> <optional><attribute name="datensatz"><text/></attribute></optional>
> <zeroOrMore>
> <interleave>
> <optional><ref name="g_Deklarationen"/></optional>
> <optional><ref name="g_Documentation"/></optional>
> <optional><ref name="x_Layoutinclude"/></optional>
> </interleave>
> </zeroOrMore>
> </element>
> <ref name="x_Layoutinclude"/>
> </choice>
> </start>
> </grammar>
>
> The're is just no effect to the validation. The rest of the Schema works
> fine but the schematron rules have no effect. They seme to be ignored.
>
> Any suggestions?
>
> Thanks, Christian
>
More information about the oXygen-user
mailing list