Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule not fired when context is an attribute #123

Closed
Falcon2677 opened this issue Nov 24, 2021 · 4 comments
Closed

Rule not fired when context is an attribute #123

Falcon2677 opened this issue Nov 24, 2021 · 4 comments

Comments

@Falcon2677
Copy link

When using ph-schematron-xslt-6.2.5.jar with schematron rule using a context with an attribute and SchematronResourceSCH, rule is not fired.

I need to use SchematronResourceSCH and not SchematronResourcePure due to others rules not taken in charge in Pure.

It appears that the problem is link to the variable definition of context-path in file 20100710-xslt2/iso_schematron_skeleton_for_saxon.xsl.

When replacing:

         <xsl:if test="$attributes='true' and parent::node() ">@*|</xsl:if>

with

         <xsl:if test="$attributes='true'">@*|</xsl:if>

Rule using attribute in context is correctly fire.

See Files.zip which contains a sample of xml file and sch file.

@phax
Copy link
Owner

phax commented Nov 24, 2021

Existing SVRL output:

<?xml version="1.0" encoding="UTF-8"?>
<ns2:schematron-output xmlns:ns2="http://purl.oclc.org/dsdl/svrl" title="" schemaVersion="">
  <ns2:ns-prefix-in-attribute-values prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
  <ns2:ns-prefix-in-attribute-values prefix="message" uri="msg:ns" />
  <ns2:active-pattern document="C:\dev\git\ph-schematron\ph-schematron-xslt\src\test\resources\issues\github123\Data.xml" />
  <ns2:fired-rule context="//*[resolve-QName(@xsi:type,.)=QName('msg:line','Type')]/idType" />
  <ns2:fired-rule context="//*[resolve-QName(@xsi:type,.)=QName('msg:line','Type')]/idType" />
  <ns2:failed-assert location="/*[local-name()='Data']/body/content/objects/object[2]/idType" test="matches(.,'^1')">
    <ns2:text>Rule on node idType value must start with 1</ns2:text>
      <ns2:diagnostic-reference diagnostic="R2-en" xml:lang="en">
Rule on node idType value must start with 1</ns2:diagnostic-reference>
  </ns2:failed-assert>
</ns2:schematron-output>

with your modification it becomes:

<?xml version="1.0" encoding="UTF-8"?>
<ns2:schematron-output xmlns:ns2="http://purl.oclc.org/dsdl/svrl" title="" schemaVersion="">
  <ns2:ns-prefix-in-attribute-values prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
  <ns2:ns-prefix-in-attribute-values prefix="message" uri="msg:ns" />
  <ns2:active-pattern document="C:\dev\git\ph-schematron\ph-schematron-xslt\src\test\resources\issues\github123\Data.xml" />
  <ns2:fired-rule context="//*[resolve-QName(@xsi:type,.)=QName('msg:line','Type')]/@id" />
  <ns2:fired-rule context="//*[resolve-QName(@xsi:type,.)=QName('msg:line','Type')]/idType" />
  <ns2:fired-rule context="//*[resolve-QName(@xsi:type,.)=QName('msg:line','Type')]/@id" />
  <ns2:failed-assert location="2345" test="matches(.,'^1')">
    <ns2:text>Rule on id attribute value must start with 1</ns2:text>
      <ns2:diagnostic-reference diagnostic="R1-en" xml:lang="en">
Rule on id attribute value must start with 1</ns2:diagnostic-reference>
  </ns2:failed-assert>
  <ns2:fired-rule context="//*[resolve-QName(@xsi:type,.)=QName('msg:line','Type')]/idType" />
  <ns2:failed-assert location="/*[local-name()='Data']/body/content/objects/object[2]/idType" test="matches(.,'^1')">
    <ns2:text>Rule on node idType value must start with 1</ns2:text>
      <ns2:diagnostic-reference diagnostic="R2-en" xml:lang="en">
Rule on node idType value must start with 1</ns2:diagnostic-reference>
  </ns2:failed-assert>
</ns2:schematron-output>

Which is I think a good thing. I just can't image what the implications are.... I will leave it in an see :)

phax added a commit that referenced this issue Nov 24, 2021
phax added a commit that referenced this issue Nov 24, 2021
@Falcon2677
Copy link
Author

Great, you are very reactive 😄 .

When do you planned to release a 6.2.6 ?

@phax
Copy link
Owner

phax commented Nov 24, 2021

Work in progress :)

@phax phax closed this as completed Nov 24, 2021
@phax
Copy link
Owner

phax commented Nov 24, 2021

Should be on Maven Central in the next few minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants