phax / ph-schematron

Java Schematron library that supports XSLT and native application
Apache License 2.0
110 stars 36 forks source link

sch:span use in 4.1.0 Pure #134

Closed scottbdr closed 1 year ago

scottbdr commented 1 year ago

Hi, we are using a 4.1.0 pure implementation that seems to dislike the presence of elements within and elements ("svrl:text is a simple type"). Has this changed since 4.1?

phax commented 1 year ago

Hi Scott, do you mean within a Schematron rule itself or within the SVRL? Can you please post a quick example here, then I can give you a bit more input - thx

scottbdr commented 1 year ago

Hi Phillip. The problem stems from the Schematron rule, but the error itself seems to be the parsing of the SVRL result. Basically, if I have an assert (or report) like:

<assert test="some test">some diagnostic message <sch:span>with a span</sch:span></assert> 

and that rule is triggered, it will error out when the SVRL is parsed. When the <sch:span> is removed, the error goes away. I don't have an copy of the java stack trace available to me now (I just work the Schematron itself, not the implementation of ph-schematron) but what I saw was it complaining about being a simple type that doesn't allow elements (only text). The is a valid Schematron element that presents no problems for me in other processing contexts like in OxygenXML Schematron validations. I'll see if I can get a stacktrace for you and a bit more about how we are implemented.

phax commented 1 year ago

What I found out so far: if a <sch:span> element is used, a class attribute must be provided. But even then, it is not copied to the SVRL in the pure implementation in the current version

scottbdr commented 1 year ago

So, in the case of the error we got in 4.1.0, it did have a class attribute. Below is an example of the sort of markup. Not really important for it to be copied to the SVRL - the practical effect of this for me now is I have to strip the tags in my build process (I construct the Schematron from many modules) to avoid issues during validation. It sounds like in your current version is not necessary as long as there is a @class value, correct?

          <sch:report test="true()" role="error">
              <sch:span class="RuleSummary">
                 Summary of the business rule here           
              </sch:span>
              More text and value-of elements here<sch:value-of select="'xpath here'" />
          </sch:report>
scottbdr commented 1 year ago

Hi, just learned our 4.1.0 implementation is using AbstractSchematronXSLTBasedResource, so looks like I was incorrect about the Java Pure (I had assumed they went for performance). It would make sense that your current software doesn't copy any elements to the SVRL since it's XML Schema requires just a string - perhaps earlier versions did this and it got addressed at some point. In any case, I don't think I need to bother you about it anymore - we may try upgrading. Thanks for looking at this!

phax commented 1 year ago

Okay cool. Well yes for the XSLT based transformation I am using the "Official" Schematron with a few minor fixes. But I don't think I have changed anything in this regards. Anyway, an update should not make things worse ;-)