Schematron Validation Slow in Editor 13

Having trouble installing Oxygen? Got a bug to report? Post it all here.
muchomagic
Posts: 2
Joined: Tue Nov 15, 2011 2:05 am

Schematron Validation Slow in Editor 13

Post by muchomagic »

I built an XSD with some embedded Schematron in the <xsd:appinfo>. The Schematron is extremely short (2 rules with 2 assertions each). Then, in an XML document, I added the declaration <?oxygen SCHSchema="temp.xsd"?> which points to the XSD with the embedded Schematron. In addition, I added the xsi:schemaLocation="tempuri.org temp.xsd". The XSD, Schematron rules, and XML instance document are all very short.

When I Document -> Validate -> Validate, it immediate says "Validation - in progress" at the bottom, but it takes a very long time to produce results (in this case it produced a "Document is valid"). I just timed it at 94 seconds. If I remove the "?oxygen" declaration at the top of the XML doc (so that Schematron won't be run...only XSD validation), and then re-run the validation, it produces results almost instantaneously (< 1 sec).

Does anyone know what's up with this? I pretty sure the bulk of the time is spent "compiling the Schematron", but it's completely excessive. The entire process of compiling the Schematron with Saxon and running the validation shouldn't take more than 5 sec (and indeed, it doesn't if I use Saxon outside of Oxygen).

Thanks.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: Schematron Validation Slow in Editor 13

Post by george »

It will be great if you can provide a sample to allow us to reproduce that situation, either here or on our support email at support@oxygenxml.com.

oXygen compiles the Schematron schema only once, then it reuses that if it is not modified.
If you cannot provide a sample then you may try to extract the Schematron rules in a separate schema and see if that makes a difference. Another thing that you can try is to go to Options->Preferences -- XML / XML Parser and play with the Schematron options, for example if you use ISO Schematron then you may try to enable the Optimize option or to enable Saxon-EE to be used.

Best Regards,
George
George Cristian Bina
muchomagic
Posts: 2
Joined: Tue Nov 15, 2011 2:05 am

Re: Schematron Validation Slow in Editor 13

Post by muchomagic »

Thanks for the response. I played around with the options, but it didn't help. I tried extracting the rules into their own Schematron file. That did fix the issue, so it has something to do with compiling the Schematron while inside an XSD. Included below is an XSD and sample document. This one takes about 45 sec to validate. Let me know if you can reproduce. Thanks!

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen SCHSchema="asset-reporting-format_1.1.0.xsd"?>
<asset-report-collection xmlns="http://scap.nist.gov/schema/asset-reporting-format/1.1"
xmlns:ai="http://scap.nist.gov/schema/asset-identification/1.1"
xmlns:core="http://scap.nist.gov/schema/reporting-core/1.1"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:arf-rel="http://scap.nist.gov/vocabulary/arf/relationships/1.0#"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://scap.nist.gov/schema/asset-reporting-format/1.1 asset-reporting-format_1.1.0.xsd">
<core:relationships>
<core:relationship type="arf-rel:isAbout" subject="a1">
<core:ref>id3</core:ref>
</core:relationship>
</core:relationships>
<assets>
<asset id="a1">
<ai:computing-device></ai:computing-device>
</asset>
</assets>
<reports>
<report id="id3">
<remote-resource xlink:type="simple" xlink:href="http://www.oxygenxml.com/"/>
</report>
</reports>
</asset-report-collection>

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:arf="http://scap.nist.gov/schema/asset-reporting-format/1.1"
xmlns:ai="http://scap.nist.gov/schema/asset-identification/1.1"
xmlns:core="http://scap.nist.gov/schema/reporting-core/1.1" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:sch="http://purl.oclc.org/dsdl/schematron"
targetNamespace="http://scap.nist.gov/schema/asset-reporting-format/1.1" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.1.0">
<xs:annotation>
<xs:appinfo>
<sch:ns prefix="xml" uri="http://www.w3.org/XML/1998/namespace"/>
<sch:ns prefix="xsd" uri="http://www.w3.org/2001/XMLSchema"/>
<sch:ns prefix="arf" uri="http://scap.nist.gov/schema/asset-reporting-format/1.1"/>
<sch:ns prefix="core" uri="http://scap.nist.gov/schema/reporting-core/1.1"/>
<sch:ns prefix="ai" uri="http://scap.nist.gov/schema/asset-identification/1.1"/>
<sch:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
<sch:ns prefix="xcf" uri="nist:scap:arf:xslt:function"/>
<sch:pattern>
<sch:let name="arf-namespace" value="string('http://scap.nist.gov/vocabulary/arf/relationships/1.0#')"/>
<sch:rule context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'isAbout' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:assets/arf:asset[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'retrievedFrom' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:assets/arf:asset[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'createdBy' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:assets/arf:asset[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'hasSource' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:assets/arf:asset[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'recordedBy' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:assets/arf:asset[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'initiatedBy' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:assets/arf:asset[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'createdFor' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:report-requests/arf:report-request[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
<sch:rule
context="core:relationship[fn:resolve-QName(@type, current()) eq fn:QName($arf-namespace,'hasMetadata' )]">
<sch:assert
test="exists(ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq current()/@subject])">
Fail!
</sch:assert>
<sch:assert
test="every $m in core:ref satisfies current()/ancestor::arf:asset-report-collection/arf:reports/arf:report[@id eq $m]">
Fail!
</sch:assert>
</sch:rule>
</sch:pattern>
</xs:appinfo>
</xs:annotation>

<xs:import namespace="http://scap.nist.gov/schema/asset-identification/1.1"
schemaLocation="http://scap.nist.gov/schema/asset-identification/1.1/asset-identification_1.1.0.xsd"/>
<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.w3.org/1999/xlink.xsd"/>
<xs:import namespace="http://scap.nist.gov/schema/reporting-core/1.1"
schemaLocation="http://scap.nist.gov/schema/reporting-core/1.1/reporting-core_1.1.0.xsd"/>
<xs:element name="asset-report-collection">
<xs:annotation>
<xs:documentation>The top-level report element.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="core:relationships-container-type">
<xs:sequence>
<xs:element name="report-requests" minOccurs="0">
<xs:annotation>
<xs:documentation>Contains one or more requests for reports. Each report request must be referenced in a
relationship on a report in the same asset-report-collection.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="report-request" type="arf:ReportRequestType" maxOccurs="unbounded"> </xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="assets">
<xs:annotation>
<xs:documentation>Contains the representation of one or more assets represented using the Asset
Identification format.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="asset">
<xs:complexType>
<xs:choice>
<xs:element ref="ai:asset"/>
<xs:element ref="arf:remote-resource"/>
</xs:choice>
<xs:attribute name="id" type="xs:NCName" use="required">
<xs:annotation>
<xs:documentation>An internal ID to identify this asset.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as
desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="reports">
<xs:annotation>
<xs:documentation>Contains one or more reports.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="report" type="arf:ReportType" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Contains a report, which is composed of zero or more relationships and a content
payload.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="extended-infos">
<xs:annotation>
<xs:documentation>Contain other information elements. Used as an extension point.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="extended-info">
<xs:annotation>
<xs:documentation>Contains other information. Use as an extension point for data that does not
fall into the categories defined in asset-report-collection.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other" processContents="lax"/>
</xs:sequence>
<xs:attribute name="id" type="xs:NCName" use="required">
<xs:annotation>
<xs:documentation>An internal ID to identify this object.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as
desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:NCName">
<xs:annotation>
<xs:documentation>The id for this collection.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:key name="idKey">
<xs:selector xpath=".//arf:report-request|.//arf:asset|.//arf:report|.//arf:extended-info"/>
<xs:field xpath="@id"/>
</xs:key>
<xs:keyref name="relSubjKeyRef" refer="arf:idKey">
<xs:selector xpath="core:relationships/core:relationship"/>
<xs:field xpath="@subject"/>
</xs:keyref>
<xs:keyref name="relObjKeyRef" refer="arf:idKey">
<xs:selector xpath="core:relationships/core:relationship/core:ref"/>
<xs:field xpath="."/>
</xs:keyref>
</xs:element>
<xs:complexType name="ReportRequestType">
<xs:choice>
<xs:element name="content">
<xs:annotation>
<xs:documentation>Contains the content of the report request.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other" processContents="lax">
<xs:annotation>
<xs:documentation>Holds the content of a report request.</xs:documentation>
</xs:annotation>
</xs:any>
</xs:sequence>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
<xs:element ref="arf:remote-resource"/>
</xs:choice>
<xs:attribute name="id" type="xs:NCName" use="required">
<xs:annotation>
<xs:documentation>An internal ID to identify this report request.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
<xs:complexType name="ReportType">
<xs:choice>
<xs:element name="content">
<xs:annotation>
<xs:documentation>Contains the content of the report.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other" processContents="lax"/>
</xs:sequence>
<xs:attribute name="data-valid-start-date" type="xs:date"/>
<xs:attribute name="data-valid-end-date" type="xs:date"/>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
<xs:element ref="arf:remote-resource"/>
</xs:choice>
<xs:attribute name="id" type="xs:NCName" use="required">
<xs:annotation>
<xs:documentation>An internal ID to identify this report.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
<xs:element name="object-ref">
<xs:annotation>
<xs:documentation>Report creators can embedding this element in a report with the @ref_id referencing the ID of an
asset, report, or report request. This element effectively acts as a pointer, allowing content produces to
reference higher level ARF constructs in a report, without duplicating the data in that ARF
construct.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="ref-id" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="remote-resource">
<xs:annotation>
<xs:documentation>Links to content stored external to this report.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute ref="xlink:type" use="required" fixed="simple">
<xs:annotation>
<xs:documentation>Fixed as a simple XLink.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute ref="xlink:href" use="required">
<xs:annotation>
<xs:documentation>A URI to the remote content. Producers and consumers should both know how to resolve the URI
in order to be interoperable.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##other">
<xs:annotation>
<xs:documentation>A placeholder so that content creators can add attributes as desired.</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:schema>
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: Schematron Validation Slow in Editor 13

Post by george »

I tried this sample but it validates instantly so I cannot reproduce the delay you are experimenting. We will test on a few more installations to see if we can reproduce the problem you described.

Now... I just looked closely into your XML Schema and it seems you have external references. It is possible that the time is spent on getting those files from the network - in my case they probably were cached by the web proxy I use and that is why I do not notice the issue. Please get these schemas locally and use a catalog file to map the remote locations to the local copies, that should solve the issue.

Best Regards,
George
George Cristian Bina
Post Reply