Reputation: 593
We have a schematron with the xsi namespace declared as follows
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding='xslt2'>
<ns prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance"/>
We do this because we want to define context-based rules as follows:
<rule context="*[@xsi:type='DATA_TYPE']">...</rule>
These rules worked fine for the past XML files we received so far. However, we recently received a XML whose xsi namespace is defined as:
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
This 'new' xsi namespace causes the rules defined above to not be fired (as rules do not share the same xsi). Is there a way to define schematron namespaces in a way that the rules would be fired independently of the xsi namespace?
There is always the option of defining the rules based on the local-name()="type" instead of using the xsi:type, but I was wondering if there is a correct (and better) way of achieving this.
Upvotes: 1
Views: 291
Reputation: 111491
That's a version of the XMLSchema-instance
namespace from an older spec.
You can add another prefix declaration for it:
<ns prefix="xsi_old" uri="http://www.w3.org/2000/10/XMLSchema-instance"/>
And then adjust your rules to test for both:
<rule context="*[@xsi:type='DATA_TYPE' or @xsi_old:type='DATA_TYPE']">...</rule>
Upvotes: 1