Project

Profile

Help

Maintenance: Planio will be observing a scheduled maintenance window this Sunday, November 10, 2024 from 20:00 UTC until 21:00 UTC to perform important network maintenance in our primary data center. Your Planio account will be unavailable for a few minutes during this maintenance window.

Bug #4996

closed

Namespace information missing from default XML Schema attribute added by validating XMLReader

Added by Philip Fearon over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2021-05-20
Due date:
% Done:

100%

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

Description

This issue is present in Saxon 10.5 but not in Saxon 9.8 or Saxon 9.9. It appears to be related to issue 4993

This case (source code/schema etc. attached in zip file) uses Java 1.8 with the default built-in Apache Xerces parser. The parser is configured to perform XML Schema validation. The notable feature of the XML Schema is that, for the 'html' element, it declares a default attribute in a specified namespace.

The result of an identity transform on the XML input using Saxon 10.5:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="mini-xhtml-default-att.xsd"
      test="yes">
   <head>
      <title>hello world</title>
   </head>
</html>

Note that in the result shown above the test attribute is in the 'null' namespace. With Saxon 9.8 we get the test attribute output correctly with the given namespace. Saxon supplies an arbitrary prefix _2 for the prefix/namespace-uri binding for this test attribute. The result from Saxon 9.8 is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:_2="http://com.deltaxml.test/namespace"
      xsi:noNamespaceSchemaLocation="mini-xhtml-default-att.xsd"
      _2:test="yes">
   <head>
      <title>hello world</title>
   </head>
</html>

Files

Saxon10Test.zip (8.08 KB) Saxon10Test.zip Philip Fearon, 2021-05-20 11:19

Related issues

Related to Saxon - Bug #4338: Prefixes for default attribute coming from associated XML Schema are no longer output in the output root elementClosedMichael Kay2019-10-11

Actions
Actions #1

Updated by Michael Kay over 3 years ago

Xerces is passing to the SAX ContentHandler interface a startElement event containing an attribute with local-name test, raw-name test, and URI http://com.deltaxml.test/namespace. There has been no startPrefixMapping call for this namespace.

This event clearly does not represent a valid XDM instance: it is not permissible in XDM for an attribute to have a namespace URI but no prefix, or for a namespace URI used in an attribute or element name to have not been declared using a startPrefixMapping() call.

Xerces is getting this wrong; the question is what Saxon should do about it.

If the Saxon schema validator is used in place of Xerces, the schema validator allocates a prefix and declares it, passing a valid XDM representation across to the transformer.

I guess that in earlier releases Saxon repaired the event stream by inserting a NamespaceReducer, which essentially performs the task of namespace fixup. The way in which namespace fixup is done has changed in 10.0, to reduce the amount of unnecessary and duplicated checking that goes on.

Actions #2

Updated by Michael Kay over 3 years ago

  • Related to Bug #4338: Prefixes for default attribute coming from associated XML Schema are no longer output in the output root element added
Actions #3

Updated by Michael Kay over 3 years ago

  • Category set to JAXP Java API
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch trunk added
  • Fix Committed on Branch 10, trunk added

I have added code to ReceivingContentHandler.makeAttributeMap() to detect and repair this situation: if a defaulted attribute (isSpecified()==false) is included in the startElement call having a namespace URI but no prefix, we invent and declare a prefix and change the attribute name.

Unit tests added to s9apitest/TestXMLParserOptions.

Actions #4

Updated by Norm Tovey-Walsh about 3 years ago

Added a fix to make sure that the code doesn't attempt to generate a prefix for the empty namespace.

Actions #5

Updated by O'Neil Delpratt about 3 years ago

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

Bug fix applied in the Saxon 10.6 maintenance release

Please register to edit this issue

Also available in: Atom PDF