Project

Profile

Help

Bug #6036

closed

Undeclaration of default namespace is not reported to a SAXResult

Added by Radu Coravu about 1 year ago. Updated 9 months ago.

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

100%

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

Description

I need some advice, the problem might be on our side though... I have this XML:

<?xml version="1.0" encoding="UTF-8"?>
<colors>
    <red>10</red>
    <blue>20</blue>
    <green>15</green>  
</colors>

and this XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
        <svg xmlns="http://www.w3.org/2000/svg">
            <xsl:apply-templates/>
        </svg>
    </xsl:template>
    <xsl:template match="colors/*">
        <circle cx="{(position() - 1) * 100}" cy="100" r="{.}"/>
    </xsl:template>
</xsl:stylesheet>

For the Oxygen debugger we serialize the XML using the net.sf.saxon.event.ComplexContentOutputter class with a serializer. The resulting output is this one:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
   <circle cx="100" cy="100" r="10"/>
   <circle cx="300" cy="100" r="20"/>
   <circle cx="500" cy="100" r="15"/>
</svg>

which is incorrect because the "circle" element should have an empty xmlns="" set on it.

Lookin at the callbacks we receive in our content handler, we do not receive a startPrefixMapping("", "") before the startElement("circle") is received.

Looking at the code here: net.sf.saxon.event.ComplexContentOutputter.startContent() it does something like this:

        if (pendingStartTag.hasURI("") && !pendingNSMap.getDefaultNamespace().isEmpty()) {
            pendingNSMap = pendingNSMap.remove("");
        }

but I'm not sure it is to blame for the problem.

Please register to edit this issue

Also available in: Atom PDF