Reputation: 4737
I have this weird problem with Saxon's XSLT processor (latest version = 9.?)
Given this bogus XML (doesn't matter what it is):
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:bogus">bogus</root>
With this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<x:transform version="2.0"
xmlns:x="http://www.w3.org/1999/XSL/Transform"
xmlns:b="urn:bogus"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:foobar"
xpath-default-namespace="urn:foobar"
exclude-result-prefixes="#all">
<x:output method="xml" indent="yes" encoding="UTF-8" />
<x:template match="b:root">
<foo xsi:type="xs:string"><x:value-of select="."/></foo>
</x:template>
</x:transform>
Will actually drop the xmlns:xs="http://www.w3.org/2001/XMLSchema" declaration from the resulting XML because of exclude-result-prefixes="#all". Apparently this happens because it is used in an attribute value and not in an element or attribute.
Removing exclude-result-prefixes="#all" or specifying manually which prefixes to remove does work.
Is this intended behavior? I guess the processor treats all attribute values as random strings and doesn't take namespaces into account for them (it doesn't even notice it has one I assume).
Should there be special behavior for well known attributes like xsi:type?
Upvotes: 0
Views: 1369
Reputation: 167716
I don't see that http://www.w3.org/TR/xslt20/#namespace-fixup requires the processor to check attribute values for type names, as it says:
Namespace fixup is not used to create namespace declarations for xs:QName or xs:NOTATION values appearing in the content of an element or attribute.
Where values acquire such types as the result of validation, namespace fixup does not come into play, because namespace fixup happens before validation: in this situation, it is the user's responsibility to ensure that the element being validated has the required namespace nodes to enable validation to succeed.
Based on that I would say it is the responsibility of the stylesheet author to ensure that the xs
prefix is bound to the URI http://www.w3.org/2001/XMLSchema
.
Upvotes: 2