phax / ph-schematron

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

On preprocessing - keep foreign namespace elements #51

Closed phax closed 5 years ago

phax commented 7 years ago

As outlined in #48; Currently the following example:

<?xml version="1.0" encoding="utf-8"?>
<sch:schema xmlns="http://purl.oclc.org/dsdl/schematron" xmlns:sch="http://purl.oclc.org/dsdl/schematron"
  queryBinding="xslt2"
  xmlns:sqf="http://example.org/sqf">

  <sch:ns prefix="sqf" uri="http://example.org/sqf" />

  <sch:pattern name="Customer">
    <sch:rule context="/file/Customer">
      <sch:assert test="base-uri()" role="fatal">
        base-uri is '<sch:value-of select="base-uri()" />'
        <sqf:fix id="a12"/>
      </sch:assert>
    </sch:rule>
  </sch:pattern>
</sch:schema> 

is preprocessed to

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
  <ns prefix="sqf" uri="http://example.org/sqf" />
  <pattern name="Customer">
    <rule context="/file/Customer">
      <assert test="base-uri()" role="fatal">
        <ns0:fix xmlns:ns0="http://example.org/sqf" id="a12" />
        base-uri is '<value-of select="base-uri()" />'

            </assert>
    </rule>
  </pattern>
</schema>

so the <sqf:fix id="a12"/> was moved and the namespace prefix went away...

fviolette commented 7 years ago

I actually only declare xmlns:sqf in <schema> this should be taken into account, if that behaves differently. I need to double check if my use or is affected as well.

phax commented 5 years ago

The problem is the underyling data model, because the order of elements is not maintained in the PSAssertReport class - the foreign elements are always at the end

phax commented 5 years ago

Fixed in 5.0.10 - the order of foreign elements is now more flexible and not so strict. According to the RNG, foreign elements are usually only supported at the beginning of an element.