Getting the failed-assert from the sch file
Oxygen general issues.
-
- Posts: 3
- Joined: Mon Aug 19, 2019 11:29 am
Getting the failed-assert from the sch file
I have an .sch file provided by PEPPOL website: http://docs.peppol.eu/poacc/billing/3.0 ... 31-UBL.sch and we need to convert it to .xsl. We have done the conversion using a tool called oXygen.
This is the snipped from .sch that generates the [BR-S-06]
This is how I am expecting a rule to show as:
This is how it is actually shown:
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.
To run the validation using Saxon we have the following code:
I am not sure what is wrong here, maybe the .sch file that I started with or maybe the .sch to .xsl converter.
This is the snipped from .sch that generates the [BR-S-06]
Code: Select all
<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>
Code: Select all
<!--RULE -->
<xsl:template match="//cbc:InvoiceTypeCode" priority="1012" mode="M7">
<svrl:fired-rule xmlns:svrl="http://purl.oclc.org/dsdl/svrl" context="//cbc:InvoiceTypeCode"/>
<!--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"/>
</xsl:template>
Code: Select all
<!--RULE -->
<xsl:template match="cac:AllowanceCharge[cbc:ChargeIndicator=false()]/cac:TaxCategory[normalize-space(cbc:ID)='S'][cac:TaxScheme/normalize-space(upper-case(cbc:ID))='VAT']"
priority="1006"
mode="M10">
<!--ASSERT -->
<xsl:choose>
<xsl:when test="(cbc:Percent) > 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"/>
</xsl:template>
To run the validation using Saxon we have the following code:
Code: Select all
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;
}
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Getting the failed-assert from the sch file
Hello,
The Schematron compilation provided in Oxygen does not generate an SVRL output, it generates only the messages.
If you want to generate an SVRL output you can use the Schematron compilation stylesheets from the Schematron Github page:
https://github.com/Schematron/ant-schematron
There is also a video presentation made by me where I explain how to generate an SVRL output:
https://youtu.be/w4jtBsSIiyw?t=2329
You can find the sample files here:
https://github.com/octavianN/Schematron-step-by-step
Best Regards,
Octavian
The Schematron compilation provided in Oxygen does not generate an SVRL output, it generates only the messages.
If you want to generate an SVRL output you can use the Schematron compilation stylesheets from the Schematron Github page:
https://github.com/Schematron/ant-schematron
There is also a video presentation made by me where I explain how to generate an SVRL output:
https://youtu.be/w4jtBsSIiyw?t=2329
You can find the sample files here:
https://github.com/octavianN/Schematron-step-by-step
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 3
- Joined: Mon Aug 19, 2019 11:29 am
Re: Getting the failed-assert from the sch file
Hello Tavy,
Thank you very much for the help! This is exactly what I was looking for, been struggling with this for a while.
This thread can now be closed.
Kind Regards,
Raul.
Thank you very much for the help! This is exactly what I was looking for, been struggling with this for a while.
This thread can now be closed.
Kind Regards,
Raul.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service