QuickFix doesn't resolve substitution groups for missing ele

This should cover W3C XML Schema, Relax NG and DTD related problems.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

QuickFix doesn't resolve substitution groups for missing ele

Post 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
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

Re: QuickFix doesn't resolve substitution groups for missing

Post 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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: QuickFix doesn't resolve substitution groups for missing

Post 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
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

Re: QuickFix doesn't resolve substitution groups for missing

Post 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
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

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

Post 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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply