Page 1 of 1

QuickFix doesn't resolve substitution groups for missing ele

Posted: Thu May 28, 2015 10:53 am
by Patrik
Hi,

in my xml schema I'm using substitution groups, for instance "StandardSectionElement" which itself is an abstract element but p, ul, sl, ...are added to it as substitution elements. A section should contain at least a single StandardSectionElement after the title.
Now for a section with only a title there is a QuickFix generated that suggests to insert "StandardSectionElement". After executing this QuickFix I get - of course - this error message: "The value of {abstract} in the element declaration for 'StandardSectionElement' must be false". So it seems you don't resolve substitution groups when identifying the possible elements yet.

Actually I don't want the section content to be declared mandatory (I just wanted to check oxygens behavior), because I prefer that the document stays schema-valid while the user edits it. Thus, I only implemented a schematron check for this. But now I'd like to provide QuickFixes to insert any of the allowed elements. Since this information is present in the schema and you already use it to generate QuickFixes for mandatory elements, I'm wondering if I can access such a method as well!? (I have plenty other cases of choices without substitution groups, so the current implementation would lready help.)

Thanks and regards,
Patrik

Re: QuickFix doesn't resolve substitution groups for missing

Posted: Thu May 28, 2015 5:04 pm
by tavy
Hi Patrik,

For the first problem "QuickFix generated for an abstract element", I added an issue on our issue tracker. Unfortunately the validation doesn't tell us that the required element is abstract and we will need to determine this somehow.

For the second problem, to propose the substitution elements from a schematron quick fix, I think we should first allow this in the SQF specification. Now the "sqf:add" operation, in case you have a @node-type attribute set to "element", requires also the @target attribute to be set, to specify the element qualified name.
A solution can be to specify in the @target attribute value an "user-entry", which at quick fix execution will propose you the allowed elements. But you need to have a special type for the "user-entry", like "schema required elements".
Or another solution can be to allow the @node-type attribute value set to "element" even if the @target attribute is missing. And in this case the application should propose the possible elements that can be inserted at quick fix execution.

You can add an issue on SQF specification on github to discuss this: http://github.com/schematron-quickfix/sqf

Best Regards,
Octavian

Re: QuickFix doesn't resolve substitution groups for missing

Posted: Thu May 28, 2015 8:38 pm
by Patrik
Hi Octavian,

thanks for adding the issue.

About the sqf: You don't have to specify a target for adding a new element. You can simply call an xslt function in the select attribute - I just tested it:

Code: Select all

<xsl:function name="my:newElement" as="element()">
<xsl:param name="Name" as="xs:string"/>
<xsl:element name="{$Name}">New Element</xsl:element>
</xsl:function>

<sch:pattern>
<sch:rule context="sli">
<sch:report test="true()" sqf:fix="addSuccessor">
Not enough elements.
</sch:report>
<sqf:fix id="addSuccessor">
<sqf:description>
<sqf:title>Add Successor-Element</sqf:title>
</sqf:description>
<sqf:add match="." position="after" select="my:newElement(name(.))"/>
</sqf:fix>
</sch:rule>
</sch:pattern>
Thus, I could easily call an xsl function that uses a java function to find out the allowed elements.
Still missing is a (comfortable) ability to generate multiple quick fixes from a single sqf:fix element. But this is already added as issue #3 for sqf (And I successfully implemented and integrated localy a prototype of a solution).

However, I just had another idea: I could access the schema information from saxon by using the extension function saxon:type(). But since this returns a function pointer it requires xslt 3.0. And currently schematron only supports xslt 2.0. Would this be an issue for sqf as well? (My attempts to enhance iso-schematron where completely successless so far.)

Regards,
Patrik

Re: QuickFix doesn't resolve substitution groups for missing

Posted: Fri May 29, 2015 12:10 pm
by tavy
Hi Patrik,

Yes, this is another possibility, to obtain the allowed elements using an extension function. But you will need the multi-fix support in sqf (issue #3 for sqf specification).

Schematron supports only xslt 1.0 and 2.0, there is already an issue on our issue tracker to add also support for xslt 3.0. This is scheduled for the next oXygen release version. I increased the priority of the issue.

Best Regards,
Octavian

Re: QuickFix doesn't resolve substitution groups for missing ele

Posted: Mon Jan 04, 2016 6:32 pm
by tavy
Hello,

Please note the in oXygen 17.1 we added support for XPath/XSLT 3.0 in Schematron Schemas. You can define the version directly in the Schematron document using the queryBinding attribute or by using an option in the Schematron preferences page.

Best Regards,
Octavian