Получение неудачного утверждения из файла sch

У меня есть файл .sch, предоставленный веб-сайтом PEPPOL: http://docs.peppol.eu/poacc/billing/3.0/files/PEPPOL-EN16931-UBL.sch, и нам нужно преобразовать его в .xsl. Мы сделали преобразование с помощью инструмента под названием oXygen.

Это вырезка из .sch, из которой создается [BR-S-06].

<rule context="cac:AllowanceCharge[cbc:ChargeIndicator=false()]/cac:TaxCategory[normalize-space(cbc:ID)='S'][cac:TaxScheme/normalize-space(upper-case(cbc:ID))='VAT']">
      <assert id="BR-S-06" flag="fatal" test="(cbc:Percent) > 0">[BR-S-06]-In a Document level allowance (BG-20) where the Document level allowance VAT category code (BT-95) is "Standard rated" the Document level allowance VAT rate (BT-96) shall be greater than zero.</assert>
    </rule>

Вот как я ожидаю, что правило будет отображаться как:

<!--ASSERT -->
<xsl:choose>
  <xsl:when test="@listID = 'UNCL1001'"/>
  <xsl:otherwise>
    <svrl:failed-assert xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="@listID = 'BR-S-06'">
      <xsl:attribute name="id">BR-S-06</xsl:attribute>
      <xsl:attribute name="flag">fatal</xsl:attribute>
      <xsl:attribute name="location">
        <xsl:apply-templates select="." mode="schematron-select-full-path"/>
      </xsl:attribute>
      <svrl:text>[BR-S-06]-In a Document level allowance (BG-20) where the Document level allowance VAT category code (BT-95) is "Standard rated" the Document level allowance VAT rate (BT-96) shall be greater than zero.</svrl:text>
    </svrl:failed-assert>
  </xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="@*|*" mode="M7"/>

This is how it is actually shown:

    <!--ASSERT -->
  <xsl:choose>
     <xsl:when test="(cbc:Percent) &gt; 0"/>
     <xsl:otherwise>
        <xsl:message xmlns:iso="http://purl.oclc.org/dsdl/schematron">
           <xsl:text>[BR-S-06]-In a Document level allowance (BG-20) where the Document level allowance VAT category code (BT-95) is "Standard rated" the Document level allowance VAT rate (BT-96) shall be greater than zero.</xsl:text>
        </xsl:message>
     </xsl:otherwise>
  </xsl:choose>
  <xsl:apply-templates select="@*|node()" mode="M10"/>

I am expecting to see the failed-assert element because it also contains the id/flag/location rather then what i currently get which is a message.

Для запуска проверки с помощью Saxon у нас есть следующий код:

public static Dictionary<string, List<ValidationResult>> ValidateXML(string xslTemplate, string xslName, XmlDocument document)
        {
            Dictionary<string, List<ValidationResult>> resultToReturn = new Dictionary<string, List<ValidationResult>>();

            XmlNamespaceManager xmlNamespacesForDocument = GetAllNamespaces(document);
            var transformAssertFailed = new List<ValidationResult>();
            var processor = new Processor();
            var compiler = processor.NewXsltCompiler();
            var executable = compiler.Compile(new MemoryStream(Encoding.UTF8.GetBytes(xslTemplate)));
            var destination = new DomDestination();

            MemoryStream xmlStream = new MemoryStream();
            document.Save(xmlStream);
            xmlStream.Position = 0;
            using (xmlStream)
            {
                var transformer = executable.Load();

                transformer.SetInputStream(xmlStream, new Uri("file:///C:/"));
                transformer.Run(destination);
            }
            return resultToReturn;
        }

Я не уверен, что здесь не так, может быть, файл .sch, с которого я начал, или, может быть, конвертер .sch в .xsl.


person Raul Junc    schedule 15.08.2019    source источник
comment
Существует более одного процессора Schematron, написанного на XSLT (то есть набор таблиц стилей, который преобразует схему Schematron в набор правил XSLT). Вы ничего не говорите нам о том, какой процессор Schematron вы используете. Возможно, ваш ожидаемый результат основан на одном, а ваш фактический результат — на другом?   -  person Michael Kay    schedule 17.08.2019


Ответы (1)


Я отправил тот же вопрос в форму oXygen здесь и получил ответ на свой вопрос.

person Raul Junc    schedule 23.08.2019