2

Schematron と組み合わせた SXD スキーマの検証に問題があります。

このガイド<xs:appinfo>で説明されている手順に従って、次のように XSD ドキュメントのタグの間にスキーマトロンを組み込みました。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="Test">

        <xs:annotation>
            <xs:appinfo>
                <sch:pattern name="Testing schematron" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
                    <sch:rule context="Test">
                        <sch:assert test="@Attribute1">Attribute 1 exists</sch:assert>
                    </sch:rule>
                </sch:pattern>
            </xs:appinfo>
        </xs:annotation>

        <xs:complexType> 
            <xs:attribute name="Attribute1" type="xs:string" use="optional"/>
            <xs:attribute name="Attribute2" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>

</xs:schema>

このドキュメントは、ドキュメントをテスト (または検証) することになっています

<?xml version="1.0" encoding="ISO-8859-1"?>
<Test Attribute1="attr1"/>

schematronページにリストされている単純な xsltproc ベースのスクリプトを使用します。残念ながら、スクリプトの最後のステップで次のエラー メッセージが表示されます。

step3.xsl:13: parser error : Extra content at the end of the document
plates select="*|comment()|processing-instruction()" mode="M0"/></axsl:template>
                                                                               ^
cannot parse step3.xsl

このエラーの原因を突き止める手助けをいただければ幸いです。

4

1 に答える 1

3

あなたのスキーマは正しく、それが意図したことを実行します...

問題はスクリプトにあります。このスクリプトはSchematronスキーマを受け取ることを想定しており、別の種類の獣であるルールが埋め込まれたXMLスキーマをスクリプトに与えます。

検証を行うには、XMLスキーマからSchematronを抽出し、この結果に対して検証を実行する最初の変換を実行する必要があります。

また、xmllint(libxml)を使用して、別の操作であるXMLスキーマに対してドキュメントを検証することもできます。

これを行うには、スクリプトのダウンロードExtractSchFromXSD.xslを次のように変更します。

#!/bin/bash

echo XSD validation
xmllint -schema $1 $2

echo Step0 ...
xsltproc ExtractSchFromXSD.xsl $1 > schema.sch

echo Step1 ...
xsltproc iso_dsdl_include.xsl schema.sch > 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 | tee result.svrl

または、スキーマに埋め込まれたSchematronルールをネイティブにサポートする実装またはoXygenなどのツールを使用することもできます。

于 2012-05-19T15:09:43.693 に答える