Project

Profile

Help

Bug #2362

closed

"Illegal character in path at index 0" when setting xml:base through AVT

Added by Gerrit Imsieke almost 9 years ago. Updated almost 9 years ago.

Status:
Won't fix
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2015-04-25
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

If you invoke the following template

<xsl:template name="main">
  <out xml:base="{'out.xml'}"/>
</xsl:template>

it will fail with

java.lang.IllegalArgumentException: Illegal character in path at index 0: {'out.xml'}

    at java.net.URI.create(URI.java:859)

    at java.net.URI.resolve(URI.java:1043)

    at net.sf.saxon.style.UseWhenFilter.startElement(UseWhenFilter.java:130)

It seems as if the attribute value of xml:base (specifically, no other attributes seem to be affected so far) is checked before the AVT is evaluated, or the AVT isn’t evaluated at all.

This used to work in Saxon 9.5. Tested with (at least) PE 9.6.0.5J, HE 9.6.0.5J, and HE 9.6.0.4J and the the 9.6 HE version that shipped with XML Calabash 1.0.25 in February.

Actions #1

Updated by Michael Kay almost 9 years ago

This behaviour is correct according to the spec. See the note in 11.1.2:

Note:

The xml:base, xml:lang, xml:space, and xml:id attributes have two effects in XSLT. They behave as standard XSLT attributes, which means for example that if they appear on a literal result element, they will be copied to the result tree in the same way as any other attribute. In addition, they have their standard meaning as defined in the core XML specifications. Thus, an xml:base attribute in the stylesheet affects the base URI of the element on which it appears, and an xml:space attribute affects the interpretation of whitespace text nodes within that element. One consequence of this is that it is inadvisable to write these attributes as attribute value templates: although an XSLT processor will understand this notation, the XML parser will not. See also 11.1.5 Namespace Aliasing which describes how to use xsl:namespace-alias with these attributes.

You can avoid the problem by creating the attribute using xsl:attribute, or by using an xsl:namespace-alias for the XML namespace.

Actions #2

Updated by Gerrit Imsieke almost 9 years ago

  • Status changed from New to Won't fix
  • % Done changed from 0 to 100

Thanks for pointing this out. We’ll adapt the stylesheets accordingly – use xsl:attribute for generating xml:base in the result tree.

Actions #3

Updated by Michael Kay almost 9 years ago

I think the reason it used to work in 9.5 was that there was a bug. XPath expressions in use-when attributes are supposed to be evaluated with a static base URI equal to the base URI of the stylesheet element containing the use-when expression, and the base URI of an element in a stylesheet (like any other XML document) is affected by (the literal value of) its xml:base attribute. 9.5 was evaluating use-when attributes with a static XPath context that did not include the correct value for static base URI.

Please register to edit this issue

Also available in: Atom PDF