Finding the code from schematorn message

This should cover W3C XML Schema, Relax NG and DTD related problems.
Patrik
Posts: 216
Location: Hamburg/Germany

Finding the code from schematorn message

Mon Mar 02, 2015 9:45 am

Hi,

when the schematron validation fails it writes a message. When clicking on the message the cursor goes to the node that has been evaluated. Is there an easy way to jump to the schematron rule that generated this message?

Since my schema is quite complex with few schematron files and several xsd files with embeded schematron rules finding it manuelly already takes quite some time...

As a workaround I already considered marking each rule with a unique id so I can at least find it with "find in files". Do I have to add this into the text content of the assert/report element or is there any attribute that is passed to the output as well?

Thanks and regards,

Patrik
adrian
Posts: 2336

Re: Finding the code from schematorn message

Mon Mar 02, 2015 4:10 pm

Hello,

Patrik wrote:when the schematron validation fails it writes a message. When clicking on the message the cursor goes to the node that has been evaluated. Is there an easy way to jump to the schematron rule that generated this message?
I'm afraid there isn't. When you validate the XML instance with a Schematron schema the errors highlighted in the instance are not paired with the rule from the Schematron schema.
You've already identified a good workaround in using an error id to identify the location from the schema.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Patrik
Posts: 216
Location: Hamburg/Germany

Re: Finding the code from schematorn message

Sat Mar 28, 2015 10:29 am

After diving a little deeper into schematron I found out that it's actually quite easy to add the location information to the messages. I simply added the following code to the template "process-message":

Code: Select all

<xsl:if test="$show-code-pos = 'true'">
   <axsl:text>
      <xsl:text> [filename: </xsl:text>
      <xsl:value-of select="replace(@oxy:elementURI, '.*/', '')"/>
      <xsl:text>, line: </xsl:text>
      <xsl:value-of select="@oxy:elementLine"/>
      <xsl:text>, column: </xsl:text>
      <xsl:value-of select="@oxy:elementLine"/>
      <xsl:text>, uri: </xsl:text>
      <xsl:value-of select="@oxy:elementURI"/>
      <xsl:text>]</xsl:text>
   </axsl:text>
</xsl:if>


show-code-pos is a new parameter I had to set to "true" as default.

However, this is usually only interesting when you really have a problem with a schematron rule. Otherwiese the additional text is probably more annoying. Thus, an additional configuration parameter within oxygen would be nice to set the parameter show-code-pos accordingly.

Maybe you could consider adding this to oxygen.

Thanks and regards,

Patrik
radu_pisoi
Posts: 310
Location: Craiova

Re: Finding the code from schematorn message

Tue Mar 31, 2015 5:10 pm

Adding the possibility to identify the assert or report element that generates a certain Schematron message is a nice feature that will help Schematron developers to easily edit their schemas.

As you already noted, this feature can be annoying in some circumstances. So, there should be an option for enabling this support.

I will record an issue on our side.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 1 guest