Project

Profile

Help

Bug #3199

closed

IllegalStateException using a sef package when a namespace contain a space character

Added by Rémi LEONARD about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
XSLT 3.0 packages
Sprint/Milestone:
-
Start date:
2017-04-12
Due date:
% Done:

100%

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

Description

Hello,

for a project i want to use the xsl in a sef package.

If a namespace contains a space character, the xsl is usable but not the sef. It give the following stacktrace

java.lang.IllegalStateException: ns=xsl=http://www.w3.org/1999/XSL/Transform xs=http://www.w3.org/2001/XMLSchema xd=http://www.oxygenxml.com/ns/doc/xsl bugsef=http://www.mybug.com/ spacebug/

    at com.saxonica.trans.PackageLoaderPE.makeRetainedStaticContext(PackageLoaderPE.java:981)

    at com.saxonica.trans.PackageLoaderPE.loadExpression(PackageLoaderPE.java:936)

    at com.saxonica.trans.PackageLoaderPE.readMode(PackageLoaderPE.java:702)

    at com.saxonica.trans.PackageLoaderPE.readComponents(PackageLoaderPE.java:403)

    at com.saxonica.trans.PackageLoaderPE.loadPackageElement(PackageLoaderPE.java:235)

    at com.saxonica.trans.PackageLoaderPE.loadPackageDoc(PackageLoaderPE.java:155)

    at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:246)

    at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:101)

    at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:858)

    at net.sf.saxon.Transform.doTransform(Transform.java:727)

    at net.sf.saxon.Transform.main(Transform.java:77)

Fatal error during transformation: java.lang.IllegalStateException: ns=xsl=http://www.w3.org/1999/XSL/Transform xs=http://www.w3.org/2001/XMLSchema xd=http://www.oxygenxml.com/ns/doc/xsl bugsef=http://www.mybug.com/ spacebug/

If the space is removed, no bug and we can use the sef file.

I join the xslt test case

Regards,

Rémi LEONARD.


Files

bug_sef_namespace.xsl (640 Bytes) bug_sef_namespace.xsl the test case Rémi LEONARD, 2017-04-12 10:29
Actions #1

Updated by Michael Kay about 7 years ago

I don't think that namespace names containing space characters are viable. All sorts of things will break - for example xsi:schemaLocation is a space-separated sequence of URIs.

Actions #2

Updated by Michael Kay about 7 years ago

There's a complex and not very savoury history of discussions about exactly what constitutes a valid namespace URI. Some products such as XOM take a very strict view and require it to be a valid URI (or in the case of Namespace 1.1, IRI), but most parsers accept any character string. In the XSD type system there are some particular things to note:

(a) the syntax of xsi:schemaLocation is a space-separated sequence of namespace URIs, therefore namespace URIs appearing in this attribute cannot contain whitespace.

(b) The type xs:QName is defined as: The ·value space· of QName is the set of tuples {namespace name, local part}, where namespace name is an anyURI and local part is an NCName; it then says: "Spaces are, in principle, allowed in the ·lexical space· of anyURI, however, their use is highly discouraged (unless they are encoded by '%20')".

The Namespaces recommendation itself says: "An XML namespace is identified by a URI reference [RFC3986]". (A URI reference cannot contain a space). It also says that in a namespace declaration, the namespace name is the normalized value of the attribute, which means that tabs and newline (if they are allowed at all) are replaced by spaces. It also contains the rule "The attribute's normalized value MUST be either a URI reference — the namespace name identifying the namespace — or an empty string." However, section 7 of the namespaces spec conspicuously does NOT say that a document violating this rule is non-conformant -- and I am told that this omission is deliberate.

XSLT never (I believe) uses a whitespace-separated list of namespace URIs, but it does use a whitespace-separated list of collation URIs, and it would be odd if the rules were different.

So the situation is pretty muddy.

I'm going to adopt the view that no-one in their right minds would use a namespace "URI" containing whitespace unless they were trying to break the system, and change Saxon so that export reports an error if such a namespace is present.

Actions #3

Updated by Michael Kay about 7 years ago

  • Category set to XSLT 3.0 packages
  • Assignee set to Michael Kay
  • Applies to branch 9.7, 9.8 added
  • Fix Committed on Branch 9.6, 9.7 added

Patch committed to detect the situation on export and report an error.

Actions #4

Updated by Michael Kay about 7 years ago

  • Status changed from New to Resolved

Marking as resolved. Feel free to reopen if you want to argue the case (for example, if you know of an established XML vocabulary that relies on a namespace name containing a space).

Actions #5

Updated by O'Neil Delpratt almost 7 years ago

  • Applies to branch deleted (9.8)
Actions #6

Updated by O'Neil Delpratt almost 7 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.7.0.19 added

Bug fix applied in the 9.7.0.19 maintenance release.

Please register to edit this issue

Also available in: Atom PDF